ldas-tools-diskcacheAPI  2.7.1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
diskCache::Cache::Directory Class Reference

Directory caching scheme. More...

#include <Directory.hh>

Classes

class  FileCacheError
 Exception thrown when a file could not be added to a cache. More...
 
class  StartIsNotADirectoryError
 The top most entry is not a directory. More...
 
class  SymbolicLinkError
 Report symbolic links as errors. More...
 

Public Types

enum  { MODIFIED_RESET, MODIFIED_NEW_DIRECTORY, MODIFIED_OFFLINE }
 
enum  { MODIFIED_RESET, MODIFIED_NEW_DIRECTORY, MODIFIED_OFFLINE }
 
enum  { MODIFIED_RESET, MODIFIED_NEW_DIRECTORY, MODIFIED_OFFLINE }
 

Public Member Functions

 Directory ()
 Default Constructor.
 
 Directory (const std::string &Path, const std::string &Root)
 Constructor with a directory path. More...
 
 Directory (const std::string &Path, dirref_type Parent)
 Constructor with a directory path and parent. More...
 
virtual ~Directory ()
 Destructor.
 
template<typename Op >
void Children (Op &Operation) const
 Iterate over the collection of subdirectories. More...
 
template<typename Op >
void ChildrenReverse (Op &Operation) const
 Reverse iterate over the collection of subdirectories. More...
 
virtual bool Configure (const std::string &Variable, const std::string &Value)
 Allow for customization. More...
 
void Find (QueryAnswer &Answer) const
 Find a collection of files. More...
 
const std::string & Fullname () const
 Return the fully qualified name of the directory. More...
 
bool IsRoot () const
 Return true if this object represents a root directory.
 
bool IsOffline () const
 Return true if the directory is offline.
 
const std::string & Name () const
 Return the relative name of the directory. More...
 
template<typename StreamT >
StreamT & Read (StreamT &Stream)
 Read the common information from a stream.
 
const std::string & Root () const
 Retrieve the directory where this tree is rooted. More...
 
dirref_type Scan (DirectoryManager &DirectoryCollection, ScanResults &Results, const std::string &Caller, const std::string &JobInfo) const
 Scan current directory directory. More...
 
timestamp_type TimeModified () const
 Report the last time the directory had been modified.
 
template<typename StreamT >
StreamT & Write (StreamT &Stream) const
 Write the information out to a stream.
 
 Directory ()
 Default Constructor.
 
 Directory (const std::string &Path, const std::string &Root)
 Constructor with a directory path. More...
 
 Directory (const std::string &Path, dirref_type Parent)
 Constructor with a directory path and parent. More...
 
virtual ~Directory ()
 Destructor.
 
template<typename Op >
void Children (Op &Operation) const
 Iterate over the collection of subdirectories. More...
 
template<typename Op >
void ChildrenReverse (Op &Operation) const
 Reverse iterate over the collection of subdirectories. More...
 
virtual bool Configure (const std::string &Variable, const std::string &Value)
 Allow for customization. More...
 
void Find (QueryAnswer &Answer) const
 Find a collection of files. More...
 
const std::string & Fullname () const
 Return the fully qualified name of the directory.
 
bool IsRoot () const
 Return true if this object represents a root directory.
 
bool IsOffline () const
 Return true if the directory is offline.
 
const std::string & Name () const
 Return the relative name of the directory. More...
 
template<typename StreamT >
StreamT & Read (StreamT &Stream)
 Read the common information from a stream.
 
const std::string & Root () const
 Retrieve the directory where this tree is rooted. More...
 
dirref_type Scan (DirectoryManager &DirectoryCollection, ScanResults &Results, const std::string &Caller, const std::string &JobInfo) const
 Scan current directory directory. More...
 
timestamp_type TimeModified () const
 Report the last time the directory had been modified.
 
template<typename StreamT >
StreamT & Write (StreamT &Stream) const
 Write the information out to a stream.
 
 Directory ()
 Default Constructor.
 
 Directory (const std::string &Path, const std::string &Root)
 Constructor with a directory path. More...
 
 Directory (const std::string &Path, dirref_type Parent)
 Constructor with a directory path and parent. More...
 
virtual ~Directory ()
 Destructor.
 
template<typename Op >
void Children (Op &Operation) const
 Iterate over the collection of subdirectories. More...
 
template<typename Op >
void ChildrenReverse (Op &Operation) const
 Reverse iterate over the collection of subdirectories. More...
 
virtual bool Configure (const std::string &Variable, const std::string &Value)
 Allow for customization. More...
 
void Find (QueryAnswer &Answer) const
 Find a collection of files. More...
 
const std::string & Fullname () const
 Return the fully qualified name of the directory.
 
bool IsRoot () const
 Return true if this object represents a root directory.
 
bool IsOffline () const
 Return true if the directory is offline.
 
const std::string & Name () const
 Return the relative name of the directory. More...
 
template<typename StreamT >
StreamT & Read (StreamT &Stream)
 Read the common information from a stream.
 
const std::string & Root () const
 Retrieve the directory where this tree is rooted. More...
 
dirref_type Scan (DirectoryManager &DirectoryCollection, ScanResults &Results, const std::string &Caller, const std::string &JobInfo) const
 Scan current directory directory. More...
 
timestamp_type TimeModified () const
 Report the last time the directory had been modified.
 
template<typename StreamT >
StreamT & Write (StreamT &Stream) const
 Write the information out to a stream.
 
template<>
OASCII & Write (OASCII &Stream) const
 
template<>
IBinary & Read (IBinary &Stream)
 
template<>
OBinary & Write (OBinary &Stream) const
 

Static Public Member Functions

static const excluded_directories_ro_type ExcludedDirectories ()
 Obtain patterns of directories to exclude.
 
static void ExcludedDirectories (excluded_directories_type &Dirs)
 Modify the list of directories to be excluded. More...
 
static const excluded_directories_ro_type ExcludedDirectories ()
 Obtain patterns of directories to exclude.
 
static void ExcludedDirectories (excluded_directories_type &Dirs)
 Modify the list of directories to be excluded. More...
 
static const excluded_directories_ro_type ExcludedDirectories ()
 Obtain patterns of directories to exclude.
 
static void ExcludedDirectories (excluded_directories_type &Dirs)
 Modify the list of directories to be excluded. More...
 

Protected Member Functions

boost::shared_ptr< Directoryparent () const
 Return the parent associated with this directory.
 
const children_type & children () const
 Retrieve the set of children. More...
 
boost::shared_ptr< Directoryparent () const
 Return the parent associated with this directory.
 
const children_type & children () const
 Retrieve the set of children.
 
boost::shared_ptr< Directoryparent () const
 Return the parent associated with this directory.
 
const children_type & children () const
 Retrieve the set of children.
 

Detailed Description

Directory caching scheme.

This caching scheme is for the caching of directory information. It is not used directly by end users to search for files, but instead is used as the driver for detecting changes to the file system and causing search caches to be updated.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MODIFIED_RESET 

Directory needs to be rescanned.

This state is useful for flagging a single directory for rescanning. Some examples of when a directory would be flagged in this manor would be the:

  • one second bug
  • Symbolic links appear in the directory.
MODIFIED_NEW_DIRECTORY 

Directory has been newly created.

When a directory is first seen, it is given this state. This allows for some optimization as it does not need to Calculate any differences.

MODIFIED_OFFLINE 

A timeout occured during reading.

This error indicates that a directory or subdirectory received a timeout error condition during a scan. The mount point was flagged as being offline and flagged with this state. Once the mount point becomes available, the entire mount point is rescanned.

◆ anonymous enum

anonymous enum
Enumerator
MODIFIED_RESET 

Directory needs to be rescanned.

This state is useful for flagging a single directory for rescanning. Some examples of when a directory would be flagged in this manor would be the:

  • one second bug
  • Symbolic links appear in the directory.
MODIFIED_NEW_DIRECTORY 

Directory has been newly created.

When a directory is first seen, it is given this state. This allows for some optimization as it does not need to Calculate any differences.

MODIFIED_OFFLINE 

A timeout occured during reading.

This error indicates that a directory or subdirectory received a timeout error condition during a scan. The mount point was flagged as being offline and flagged with this state. Once the mount point becomes available, the entire mount point is rescanned.

◆ anonymous enum

anonymous enum
Enumerator
MODIFIED_RESET 

Directory needs to be rescanned.

This state is useful for flagging a single directory for rescanning. Some examples of when a directory would be flagged in this manor would be the:

  • one second bug
  • Symbolic links appear in the directory.
MODIFIED_NEW_DIRECTORY 

Directory has been newly created.

When a directory is first seen, it is given this state. This allows for some optimization as it does not need to Calculate any differences.

MODIFIED_OFFLINE 

A timeout occured during reading.

This error indicates that a directory or subdirectory received a timeout error condition during a scan. The mount point was flagged as being offline and flagged with this state. Once the mount point becomes available, the entire mount point is rescanned.

Constructor & Destructor Documentation

◆ Directory() [1/6]

diskCache::Cache::Directory::Directory ( const std::string &  Path,
const std::string &  Root 
)

Constructor with a directory path.

Parameters
[in]PathThe fully qualified path.
[in]RootThe root directory

◆ Directory() [2/6]

diskCache::Cache::Directory::Directory ( const std::string &  Path,
dirref_type  Parent 
)

Constructor with a directory path and parent.

Parameters
[in]PathThe fully qualified path.
[in]ParentThe parent of this node

◆ Directory() [3/6]

diskCache::Cache::Directory::Directory ( const std::string &  Path,
const std::string &  Root 
)

Constructor with a directory path.

Parameters
[in]PathThe fully qualified path.
[in]RootThe root directory

◆ Directory() [4/6]

diskCache::Cache::Directory::Directory ( const std::string &  Path,
dirref_type  Parent 
)

Constructor with a directory path and parent.

Parameters
[in]PathThe fully qualified path.
[in]ParentThe parent of this node

◆ Directory() [5/6]

diskCache::Cache::Directory::Directory ( const std::string &  Path,
const std::string &  Root 
)

Constructor with a directory path.

Parameters
[in]PathThe fully qualified path.
[in]RootThe root directory

◆ Directory() [6/6]

diskCache::Cache::Directory::Directory ( const std::string &  Path,
dirref_type  Parent 
)

Constructor with a directory path and parent.

Parameters
[in]PathThe fully qualified path.
[in]ParentThe parent of this node

Member Function Documentation

◆ Children() [1/3]

template<typename Op >
void diskCache::Cache::Directory::Children ( Op &  Operation) const
inline

Iterate over the collection of subdirectories.

Parameters
[out]OperationThis is the action that should be taken for each subdirectory.

◆ Children() [2/3]

template<typename Op >
void diskCache::Cache::Directory::Children ( Op &  Operation) const

Iterate over the collection of subdirectories.

Parameters
[out]OperationThis is the action that should be taken for each subdirectory.

◆ Children() [3/3]

template<typename Op >
void diskCache::Cache::Directory::Children ( Op &  Operation) const

Iterate over the collection of subdirectories.

Parameters
[out]OperationThis is the action that should be taken for each subdirectory.

◆ children()

const Directory::children_type & diskCache::Cache::Directory::children ( ) const
inlineprotected

Retrieve the set of children.

Retrieve a collection of directories that are children of this directory.

◆ ChildrenReverse() [1/3]

template<typename Op >
void diskCache::Cache::Directory::ChildrenReverse ( Op &  Operation) const

Reverse iterate over the collection of subdirectories.

Parameters
[out]OperationThis is the action that should be taken for each subdirectory.

◆ ChildrenReverse() [2/3]

template<typename Op >
void diskCache::Cache::Directory::ChildrenReverse ( Op &  Operation) const

Reverse iterate over the collection of subdirectories.

Parameters
[out]OperationThis is the action that should be taken for each subdirectory.

◆ ChildrenReverse() [3/3]

template<typename Op >
void diskCache::Cache::Directory::ChildrenReverse ( Op &  Operation) const
inline

Reverse iterate over the collection of subdirectories.

Parameters
[out]OperationThis is the action that should be taken for each subdirectory.

◆ Configure() [1/3]

bool diskCache::Cache::Directory::Configure ( const std::string &  Variable,
const std::string &  Value 
)
virtual

Allow for customization.

Parameters
[in]VariableName of the option to modify
[in]ValueThe ascii string representation of the value for the option.
Returns
Upon successful setting of the option, true is returned; false otherwise.

Configuration of the directory cache understands the following variables:

  • exclude - A colon separated list of patterns which describe directories to be ignored.

◆ Configure() [2/3]

virtual bool diskCache::Cache::Directory::Configure ( const std::string &  Variable,
const std::string &  Value 
)
virtual

Allow for customization.

Parameters
[in]VariableName of the option to modify
[in]ValueThe ascii string representation of the value for the option.
Returns
Upon successful setting of the option, true is returned; false otherwise.

◆ Configure() [3/3]

virtual bool diskCache::Cache::Directory::Configure ( const std::string &  Variable,
const std::string &  Value 
)
virtual

Allow for customization.

Parameters
[in]VariableName of the option to modify
[in]ValueThe ascii string representation of the value for the option.
Returns
Upon successful setting of the option, true is returned; false otherwise.

◆ ExcludedDirectories() [1/3]

static void diskCache::Cache::Directory::ExcludedDirectories ( excluded_directories_type &  Dirs)
static

Modify the list of directories to be excluded.

Parameters
[in,out]DirsThe list of new directories to be excluded. The list passed by this variable will be swapped with the current list of directories to be excluded.

◆ ExcludedDirectories() [2/3]

static void diskCache::Cache::Directory::ExcludedDirectories ( excluded_directories_type &  Dirs)
static

Modify the list of directories to be excluded.

Parameters
[in,out]DirsThe list of new directories to be excluded. The list passed by this variable will be swapped with the current list of directories to be excluded.

◆ ExcludedDirectories() [3/3]

void diskCache::Cache::Directory::ExcludedDirectories ( excluded_directories_type &  Dirs)
inlinestatic

Modify the list of directories to be excluded.

Parameters
[in,out]DirsThe list of new directories to be excluded. The list passed by this variable will be swapped with the current list of directories to be excluded.

◆ Find() [1/3]

void diskCache::Cache::Directory::Find ( QueryAnswer &  Answer) const

Find a collection of files.

Parameters
[in]AnswerLocal storage for query and answer.

◆ Find() [2/3]

void diskCache::Cache::Directory::Find ( QueryAnswer &  Answer) const

Find a collection of files.

Parameters
[in]AnswerLocal storage for query and answer.

◆ Find() [3/3]

void diskCache::Cache::Directory::Find ( QueryAnswer &  Answer) const

Find a collection of files.

Parameters
[in]AnswerLocal storage for query and answer.

◆ Fullname()

const std::string & diskCache::Cache::Directory::Fullname ( ) const
inline

Return the fully qualified name of the directory.

Retieve the fully pathed name for the requested directory. This is achieved by walking up the geneology until the root node.

◆ Name() [1/3]

const std::string& diskCache::Cache::Directory::Name ( ) const

Return the relative name of the directory.

Returns
The relative name of the directory.

◆ Name() [2/3]

const std::string & diskCache::Cache::Directory::Name ( ) const
inline

Return the relative name of the directory.

Returns
The relative name of the directory.

The relative name is simple the name associated with this directory information as referenced by its parent. A root directory name must be fully qualified.

◆ Name() [3/3]

const std::string& diskCache::Cache::Directory::Name ( ) const

Return the relative name of the directory.

Returns
The relative name of the directory.

◆ Read()

template<>
IBinary& diskCache::Cache::Directory::Read ( IBinary &  Stream)

Initialize the memory contents from the stream. This reads the contents for a single directory.

Todo:
This can be optimized by reading the root followed by reading the path relative to the root. The current implementation is waistful as the root portion is in both names.

◆ Root() [1/3]

const std::string& diskCache::Cache::Directory::Root ( ) const

Retrieve the directory where this tree is rooted.

Returns
The name of the earliest node in the tree.

◆ Root() [2/3]

const std::string & diskCache::Cache::Directory::Root ( ) const
inline

Retrieve the directory where this tree is rooted.

Returns
The name of the earliest node in the tree.

The root name is the name of the node that appears highest in the tree. Taking any node as a start, the tree is assended until the one with no parent is reached. It is the name of this node which is returned.

◆ Root() [3/3]

const std::string& diskCache::Cache::Directory::Root ( ) const

Retrieve the directory where this tree is rooted.

Returns
The name of the earliest node in the tree.

◆ Scan() [1/3]

dirref_type diskCache::Cache::Directory::Scan ( DirectoryManager &  DirectoryCollection,
ScanResults &  Results,
const std::string &  Caller,
const std::string &  JobInfo 
) const

Scan current directory directory.

Returns
If differences are found while scanning, then a new node is returned which reflects the current status of the directory. All other cases result a NULL node being returned.

◆ Scan() [2/3]

dirref_type diskCache::Cache::Directory::Scan ( DirectoryManager &  DirectoryCollection,
ScanResults &  Results,
const std::string &  Caller,
const std::string &  JobInfo 
) const

Scan current directory directory.

Returns
If differences are found while scanning, then a new node is returned which reflects the current status of the directory. All other cases result a NULL node being returned.

◆ Scan() [3/3]

Directory::dirref_type diskCache::Cache::Directory::Scan ( DirectoryManager &  DirectoryCollection,
ScanResults &  Results,
const std::string &  Caller,
const std::string &  JobInfo 
) const

Scan current directory directory.

Returns
If differences are found while scanning, then a new node is returned which reflects the current status of the directory. All other cases result a NULL node being returned.

◆ Write() [1/2]

template<>
OASCII& diskCache::Cache::Directory::Write ( OASCII &  Stream) const
Todo:
Loop over all of the associated indexes and have them dump their information to the Stream NOTE: This currently only dumps the SDTx information

◆ Write() [2/2]

template<>
OBinary& diskCache::Cache::Directory::Write ( OBinary &  Stream) const
Todo:
This can be optimized by writing the root followed by Writing the path relative to the root. The current implementation is waistful as the root portion is in both names.
Todo:
Loop over all of the associated indexes and have them dump their information to the Stream

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