LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Attributes
LogCabin::Tree::Internal::Directory Class Reference

An interior object in the Tree; stores other Directories and Files. More...

#include <Tree.h>

List of all members.

Public Member Functions

 Directory ()
 Default constructor.
std::vector< std::string > getChildren () const
 List the contents of the directory.
DirectorylookupDirectory (const std::string &name)
 Find the child directory by the given name.
const DirectorylookupDirectory (const std::string &name) const
 Find the child directory by the given name (const version).
DirectorymakeDirectory (const std::string &name)
 Find the child directory by the given name, or create it if it doesn't exist.
void removeDirectory (const std::string &name)
 Remove the child directory by the given name, if any.
FilelookupFile (const std::string &name)
 Find the child file by the given name.
const FilelookupFile (const std::string &name) const
 Find the child file by the given name (const version).
FilemakeFile (const std::string &name)
 Find the child file by the given name, or create it if it doesn't exist.
bool removeFile (const std::string &name)
 Remove the child file by the given name, if any.
void dumpSnapshot (Core::ProtoBuf::OutputStream &stream) const
 Write the directory and its children to the stream.
void loadSnapshot (Core::ProtoBuf::InputStream &stream)
 Load the directory and its children from the stream.

Private Attributes

std::map< std::string, Directorydirectories
 Map from names of child directories (without trailing slashes) to the Directory objects.
std::map< std::string, Filefiles
 Map from names of child files to the File objects.

Detailed Description

An interior object in the Tree; stores other Directories and Files.

Pointers returned by this class are valid until the File or Directory they refer to is removed.

Definition at line 123 of file Tree.h.


Constructor & Destructor Documentation

Default constructor.

Definition at line 94 of file Tree.cc.


Member Function Documentation

std::vector< std::string > LogCabin::Tree::Internal::Directory::getChildren ( ) const

List the contents of the directory.

Returns:
The names of the directories and files that this directory immediately contains. The names of directories in this listing will have a trailing slash. The order is first directories (sorted lexicographically), then files (sorted lexicographically).

Definition at line 101 of file Tree.cc.

Find the child directory by the given name.

Parameters:
nameMust not contain a trailing slash.
Returns:
The directory by the given name, or NULL if it is not found or a file exists by that name.

Definition at line 112 of file Tree.cc.

const Directory * LogCabin::Tree::Internal::Directory::lookupDirectory ( const std::string &  name) const

Find the child directory by the given name (const version).

Parameters:
nameMust not contain a trailing slash.
Returns:
The directory by the given name, or NULL if it is not found or a file exists by that name.

Definition at line 119 of file Tree.cc.

Find the child directory by the given name, or create it if it doesn't exist.

Parameters:
nameMust not contain a trailing slash.
Returns:
The directory by the given name, or NULL if a file exists by that name.

Definition at line 131 of file Tree.cc.

void LogCabin::Tree::Internal::Directory::removeDirectory ( const std::string &  name)

Remove the child directory by the given name, if any.

This will remove all the contents of the directory as well.

Parameters:
nameMust not contain a trailing slash.

Definition at line 141 of file Tree.cc.

File * LogCabin::Tree::Internal::Directory::lookupFile ( const std::string &  name)

Find the child file by the given name.

Parameters:
nameMust not contain a trailing slash.
Returns:
The file by the given name, or NULL if it is not found or a directory exists by that name.

Definition at line 149 of file Tree.cc.

const File * LogCabin::Tree::Internal::Directory::lookupFile ( const std::string &  name) const

Find the child file by the given name (const version).

Parameters:
nameMust not contain a trailing slash.
Returns:
The file by the given name, or NULL if it is not found or a directory exists by that name.

Definition at line 156 of file Tree.cc.

File * LogCabin::Tree::Internal::Directory::makeFile ( const std::string &  name)

Find the child file by the given name, or create it if it doesn't exist.

Parameters:
nameMust not contain a trailing slash.
Returns:
The file by the given name, or NULL if a directory exists by that name.

Definition at line 167 of file Tree.cc.

bool LogCabin::Tree::Internal::Directory::removeFile ( const std::string &  name)

Remove the child file by the given name, if any.

Parameters:
nameMust not contain a trailing slash.
Returns:
True if child file removed, false if no such file existed. This is mostly useful for counting statistics.

Definition at line 177 of file Tree.cc.

Write the directory and its children to the stream.

Definition at line 185 of file Tree.cc.

Load the directory and its children from the stream.

Definition at line 205 of file Tree.cc.


Member Data Documentation

Map from names of child directories (without trailing slashes) to the Directory objects.

Definition at line 217 of file Tree.h.

std::map<std::string, File> LogCabin::Tree::Internal::Directory::files [private]

Map from names of child files to the File objects.

Definition at line 221 of file Tree.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines