Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

fsc_FileExpiration Class Reference
[File System Catalog]

<Description:> Enables building up a directory tree with expiration ages. More...

#include <fsc_FileExpiration.h>

List of all members.

Public Types

typedef vector
< fsc_FileExpiration
fsc_FileExpiration_v_t
typedef
fsc_FileExpiration_v_t::iterator 
fsc_FileExpiration_v_i

Public Member Functions

 fsc_FileExpiration (const cmn_Path &a_path="", const UInt32_t a_age=cfg_INFINITE, bool a_configured=false)
virtual ~fsc_FileExpiration ()
void SetExpirationAge (const cmn_Path &a_path, const UInt32_t a_age)
 Sets expiration age for the specified path.
UInt32_t GetExpirationAge (const cmn_Path &a_path)
 Returns expiration age of the specified path.
UInt32_t GetExpirationAgeRecursive (const cmn_Path a_path)
void Clear ()
 Clear root and remove others.
void DbgDump (ostream &a_os, int a_deep=0)
 Dumps all items beneath this one from the tree into debug.

Protected Member Functions

void SetExpirationAgeRecursive (const cmn_Path a_file, const UInt32_t a_age)
void SetExpirationAgeRecursive (const UInt32_t a_age)
 Sets expiration age of an aitem and all the items beneath it.

Private Member Functions

void RemoveItems ()
 Removes all items beneath this one from the tree.

Private Attributes

 log_CLASSID_m
bool m_configured
string m_path
UInt32_t m_age
fsc_FileExpiration_v_t m_items

Detailed Description

<Description:> Enables building up a directory tree with expiration ages.

Author:
Zeljko Jovic, HERMES SoftLab

Definition at line 55 of file fsc_FileExpiration.h.


Member Typedef Documentation

typedef fsc_FileExpiration_v_t::iterator fsc_FileExpiration::fsc_FileExpiration_v_i

Definition at line 58 of file fsc_FileExpiration.h.

Definition at line 57 of file fsc_FileExpiration.h.


Constructor & Destructor Documentation

fsc_FileExpiration::fsc_FileExpiration ( const cmn_Path a_path = "",
const UInt32_t  a_age = cfg_INFINITE,
bool  a_configured = false 
) [inline]

Definition at line 60 of file fsc_FileExpiration.h.

Referenced by SetExpirationAgeRecursive().

        : m_configured(a_configured),
          m_path(a_path),
          m_age(a_age) {
        // empty
    };

Here is the caller graph for this function:

virtual fsc_FileExpiration::~fsc_FileExpiration (  )  [inline, virtual]

Definition at line 68 of file fsc_FileExpiration.h.

                                  {
    };


Member Function Documentation

void fsc_FileExpiration::Clear ( void   ) 

Clear root and remove others.

Definition at line 181 of file fsc_FileExpiration.cpp.

References log_FUNC_m, m_age, m_configured, and RemoveItems().

Referenced by i_PartitionManager_i::BuildExpirationTree().

                               {
    log_FUNC_m(Clear);
    m_configured = false;
    m_age        = cfg_INFINITE;
    RemoveItems();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_FileExpiration::DbgDump ( ostream &  a_os,
int  a_deep = 0 
)

Dumps all items beneath this one from the tree into debug.

Definition at line 203 of file fsc_FileExpiration.cpp.

References cfg_INFINITE, m_age, m_configured, m_items, and m_path.

Referenced by i_PartitionManager_i::BuildExpirationTree().

                                                          {

    if (a_deep == 0) {
        a_os << "  Age[d] Config    #mem Item" << endl
             << "----------------------------" << endl;
    }    
    
    if (m_age != cfg_INFINITE) {
        a_os << setw(8) << (m_age / 86400);
    }
    else {
        a_os << setw(8) << "INFINITE";
    }
    
    a_os << setw(7) << boolalpha << m_configured
         << setw(8) << int(m_items.size())
         << string(a_deep * 2, ' ') 
         << " '" << m_path  << "'" << endl;

    fsc_FileExpiration::fsc_FileExpiration_v_i iter;    
    for (iter = m_items.begin(); iter != m_items.end(); ++iter) {
        iter->DbgDump(a_os, a_deep + 1);
    }
}

Here is the caller graph for this function:

UInt32_t fsc_FileExpiration::GetExpirationAge ( const cmn_Path a_path  ) 

Returns expiration age of the specified path.

The path is searched in the tree beneath this item. If path doesn't exist in the tree function returns age of the last item from the path that was found in the tree.

Parameters:
a_path specifies path

Definition at line 132 of file fsc_FileExpiration.cpp.

References GetExpirationAgeRecursive(), cmn_Path::HostPathSeparator(), log_FUNC_A_m, PATH_SEPARATOR, and cmn_Path::RemoveTrailingPathSeparator().

Referenced by i_PartitionManager_i::GetExpirationAge(), and fsc_ColectorExpFile::ProcDirElement().

                                                                    {
    log_FUNC_A_m(GetExpirationAge, "path=" << a_path);

    cmn_Path item(a_path);
    item.HostPathSeparator();
    item.RemoveTrailingPathSeparator();
    // remove leading separator
    if (  (item.length() > 0)
       && (item[0] == PATH_SEPARATOR)) {
        item = item.substr(1);
    }
    return GetExpirationAgeRecursive(item);
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt32_t fsc_FileExpiration::GetExpirationAgeRecursive ( const cmn_Path  a_path  ) 

Definition at line 146 of file fsc_FileExpiration.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_A_m, m_age, m_items, and PATH_SEPARATOR.

Referenced by GetExpirationAge().

                                                                            {
    log_FUNC_A_m(GetExpirationAgeRecursive, "path=" << a_path);

    if (a_path.length() == 0) {
        return m_age;
    }
    
    cmn_Path next;
    cmn_Path restPath;
    
    UInt32_t ipos = a_path.find_first_of(PATH_SEPARATOR);
    if (ipos != string::npos) {
        next = a_path.substr(0, ipos);
        restPath = a_path.substr(ipos + 1);
    }
    else {
        next = a_path;
        // restPath is empty
    }
    log_DBG_m(dbg_DETAIL, "next '" << next << "'");
    log_DBG_m(dbg_DETAIL, "restPath '" << restPath << "'");
    
    fsc_FileExpiration::fsc_FileExpiration_v_i iter;    
    for (iter = m_items.begin(); iter != m_items.end(); ++iter) {
        if (iter->m_path == next) {
            return iter->GetExpirationAgeRecursive(restPath);
        }
    }
    
    return m_age;
}

Here is the caller graph for this function:

void fsc_FileExpiration::RemoveItems (  )  [private]

Removes all items beneath this one from the tree.

Definition at line 191 of file fsc_FileExpiration.cpp.

References index, log_FUNC_m, and m_items.

Referenced by Clear().

                                     {
    log_FUNC_m(RemoveItems);
    for (UInt32_t index = 0; index < m_items.size(); index++) {
        m_items[index].RemoveItems();
    }
    m_items.clear();
}

Here is the caller graph for this function:

void fsc_FileExpiration::SetExpirationAge ( const cmn_Path a_path,
const UInt32_t  a_age 
)

Sets expiration age for the specified path.

The path is searched in the tree beneath this item. If path doesnt exist it will be added.

Parameters:
a_path specifies path
a_age specifies expiration age

Definition at line 55 of file fsc_FileExpiration.cpp.

References cmn_Path::HostPathSeparator(), log_FUNC_A_m, PATH_SEPARATOR, cmn_Path::RemoveTrailingPathSeparator(), and SetExpirationAgeRecursive().

Referenced by i_PartitionManager_i::BuildExpirationTree().

                                                                 {
    log_FUNC_A_m(SetExpirationAge, "path=" << a_path << ", age=" << a_age);

    cmn_Path item(a_path);
    item.HostPathSeparator();
    item.RemoveTrailingPathSeparator();
    // remove leading separator
    if (  (item.length() > 0)
       && (item[0] == PATH_SEPARATOR)) {
        item = item.substr(1);
    }

    SetExpirationAgeRecursive(item, a_age);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_FileExpiration::SetExpirationAgeRecursive ( const cmn_Path  a_file,
const UInt32_t  a_age 
) [protected]

Definition at line 71 of file fsc_FileExpiration.cpp.

References dbg_DETAIL, fsc_FileExpiration(), log_DBG_m, log_FUNC_A_m, m_age, m_configured, m_items, and PATH_SEPARATOR.

Referenced by SetExpirationAge(), and SetExpirationAgeRecursive().

                                                                 {
    log_FUNC_A_m(SetExpirationAgeRecursive, "path=" << a_path << ", age=" << a_age);

    if (a_path.length() == 0) {
        m_configured = true; // set by config file
        SetExpirationAgeRecursive(a_age);
        return;
    }
    
    cmn_Path next;
    cmn_Path restPath;
    
    UInt32_t ipos = a_path.find_first_of(PATH_SEPARATOR);
    if (ipos != string::npos) {
        next = a_path.substr(0, ipos);
        restPath = a_path.substr(ipos + 1);
    }
    else {
        next = a_path;
        // restPath is empty
    }
    log_DBG_m(dbg_DETAIL, "next '" << next << "'");
    log_DBG_m(dbg_DETAIL, "restPath '" << restPath << "'");
    
    fsc_FileExpiration::fsc_FileExpiration_v_i iter;    
    for (iter = m_items.begin(); iter != m_items.end(); ++iter) {
        if (iter->m_path == next) {
            iter->SetExpirationAgeRecursive(restPath, a_age);
            return;
        }
    }
    
    m_items.push_back(fsc_FileExpiration(next, m_age)); // inherit age of parent
    m_items.back().SetExpirationAgeRecursive(restPath, a_age);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_FileExpiration::SetExpirationAgeRecursive ( const UInt32_t  a_age  )  [protected]

Sets expiration age of an aitem and all the items beneath it.

Sub-item's expiration age will be set/updated only in case it is cfg_INFINITE (default value).

Definition at line 114 of file fsc_FileExpiration.cpp.

References index, log_FUNC_A_m, m_age, m_configured, m_items, and SetExpirationAgeRecursive().

                                                                       {
    log_FUNC_A_m(SetExpirationAgeRecursive, "age=" << a_age);

    m_age = a_age;
    for (UInt32_t index = 0; index < m_items.size(); index++) {
        if (!m_items[index].m_configured) {
            // reset all inherited items that are not configured by config file
            m_items[index].SetExpirationAgeRecursive(a_age);
        }
    }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 86 of file fsc_FileExpiration.h.

Definition at line 89 of file fsc_FileExpiration.h.

Referenced by Clear(), DbgDump(), and SetExpirationAgeRecursive().

string fsc_FileExpiration::m_path [private]

Definition at line 90 of file fsc_FileExpiration.h.

Referenced by DbgDump().


The documentation for this class was generated from the following files: