ldas-tools-diskcacheAPI  2.6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | 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  ScanResults
 
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  file_type { UNKNOWN_TYPE, FILE_TYPE, DIRECTORY_TYPE }
 
enum  directory_state { DIRECTORY_NEW, DIRECTORY_UPDATED, DIRECTORY_REMOVED, DIRECTORY_OFFLINE }
 
typedef boost::shared_ptr
< Directory
dirref_type
 
typedef INT_4U size_type
 
typedef INT_4U timestamp_type
 
typedef std::set< std::string > children_type
 
typedef std::set< std::string > ignored_type
 
typedef RegistrySingleton::id_type search_id_type
 
typedef boost::shared_ptr
< Streams::Streamable
search_data_type
 
typedef
LDASTools::AL::unordered_map
< search_id_type,
search_data_type
index_container_type
 
typedef std::list< std::string > excluded_directories_type
 
typedef
LDASTools::AL::ReadWriteLockVariable
< LDASTools::AL::ReadWriteLock::WRITE,
excluded_directories_type
excluded_directories_rw_type
 
typedef
LDASTools::AL::ReadWriteLockVariable
< LDASTools::AL::ReadWriteLock::READ,
excluded_directories_type
excluded_directories_ro_type
 

Public Member Functions

 Directory ()
 Default Constructor. More...
 
 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. More...
 
void AddSubdirectory (dirref_type Dir)
 
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...
 
size_type DirectoryCount () const
 
void Find (QueryAnswer &Answer) const
 Find a collection of files. More...
 
size_type FileCount () const
 
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. More...
 
bool IsOffline () const
 Return true if the directory is offline. More...
 
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. More...
 
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. More...
 
template<typename StreamT >
StreamT & Write (StreamT &Stream) const
 Write the information out to a stream. More...
 
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. More...
 
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. More...
 
const children_typechildren () const
 Retrieve the set of children. More...
 
search_data_type searchData (search_id_type Key)
 

Friends

class functor_reset
 

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 Typedef Documentation

typedef std::set< std::string > diskCache::Cache::Directory::children_type
typedef LDASTools::AL::ReadWriteLockVariable< LDASTools::AL::ReadWriteLock::READ, excluded_directories_type > diskCache::Cache::Directory::excluded_directories_ro_type
typedef LDASTools::AL::ReadWriteLockVariable< LDASTools::AL::ReadWriteLock::WRITE, excluded_directories_type > diskCache::Cache::Directory::excluded_directories_rw_type
typedef std::set< std::string > diskCache::Cache::Directory::ignored_type

Member Enumeration Documentation

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.

Enumerator
DIRECTORY_NEW 
DIRECTORY_UPDATED 
DIRECTORY_REMOVED 
DIRECTORY_OFFLINE 
Enumerator
UNKNOWN_TYPE 
FILE_TYPE 
DIRECTORY_TYPE 

Constructor & Destructor Documentation

diskCache::Cache::Directory::Directory ( )

Default Constructor.

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
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
diskCache::Cache::Directory::~Directory ( )
virtual

Destructor.

Member Function Documentation

void diskCache::Cache::Directory::AddSubdirectory ( dirref_type  Dir)
inline
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.
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.

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.
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.
Directory::size_type diskCache::Cache::Directory::DirectoryCount ( ) const
inline
const Directory::excluded_directories_ro_type diskCache::Cache::Directory::ExcludedDirectories ( )
inlinestatic

Obtain patterns of directories to exclude.

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.
Directory::size_type diskCache::Cache::Directory::FileCount ( ) const
inline
void diskCache::Cache::Directory::Find ( QueryAnswer Answer) const

Find a collection of files.

Parameters
[in]AnswerLocal storage for query and answer.
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.

bool diskCache::Cache::Directory::IsOffline ( ) const
inline

Return true if the directory is offline.

bool diskCache::Cache::Directory::IsRoot ( ) const
inline

Return true if this object represents a root directory.

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.

boost::shared_ptr< Directory > diskCache::Cache::Directory::parent ( ) const
protected

Return the parent associated with this directory.

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.
template<typename StreamT >
StreamT& diskCache::Cache::Directory::Read ( StreamT &  Stream)

Read the common information from a stream.

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.

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.
Directory::search_data_type diskCache::Cache::Directory::searchData ( search_id_type  Key)
inlineprotected
Directory::timestamp_type diskCache::Cache::Directory::TimeModified ( ) const
inline

Report the last time the directory had been modified.

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

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
template<typename StreamT >
StreamT& diskCache::Cache::Directory::Write ( StreamT &  Stream) const

Write the information out to a stream.

Friends And Related Function Documentation

friend class functor_reset
friend

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