#include <BESUncompressManager.h>
Inheritance diagram for BESUncompressManager:
Public Member Functions | |
virtual bool | add_method (const string &name, p_bes_uncompress method) |
add a uncompress method to the list | |
virtual void | dump (ostream &strm) const |
dumps information about this object | |
virtual p_bes_uncompress | find_method (const string &name) |
returns the uncompression method specified | |
virtual string | get_method_names () |
returns the comma separated list of all uncompression methods currently registered. | |
virtual bool | remove_method (const string &name) |
removes a uncompress method from the list | |
virtual bool | uncompress (const string &src, string &target, BESCache &cache) |
find the method that can uncompress the specified src and pass control to that method. | |
virtual | ~BESUncompressManager (void) |
Static Public Member Functions | |
static BESUncompressManager * | TheManager () |
Protected Member Functions | |
BESUncompressManager (void) | |
constructs an uncompression manager adding gz, z, and bz2 uncompression methods by default. |
The BESUncompressManager allows the developer to add or remove named uncompression methods from the list for this server. By default a gz and bz2 and Z function is provided.
What is actually added to the list are static uncompression functions. Each of these functions is responsible for uncompressing a specific type of compressed file. The manager knows which type to uncompress by the file extension. All extensions are converted to lower case in order to make a match, so, for example, all .Z compressed files will be matched with the static function registered with the name z.
Definition at line 66 of file BESUncompressManager.h.
BESUncompressManager::BESUncompressManager | ( | void | ) | [protected] |
constructs an uncompression manager adding gz, z, and bz2 uncompression methods by default.
Adds methods to uncompress gz, bz2, and Z files.
Looks for a configuration parameter for the number of times to try to lock the cache (BES.Uncompress.NumTries) and the time in microseconds between tries (BES.Uncompress.Retry).
Definition at line 57 of file BESUncompressManager.cc.
References add_method(), BESKeys::get_value(), TheBESKeys::TheKeys(), BESUncompressZ::uncompress(), BESUncompressBZ2::uncompress(), and BESUncompressGZ::uncompress().
Here is the call graph for this function:
virtual BESUncompressManager::~BESUncompressManager | ( | void | ) | [inline, virtual] |
Definition at line 79 of file BESUncompressManager.h.
bool BESUncompressManager::add_method | ( | const string & | name, | |
p_bes_uncompress | method | |||
) | [virtual] |
add a uncompress method to the list
This method actually adds to the list a static method that knows how to uncompress a particular type of file. For example, a .gz or .bz2 file.
name | name of the method to add to the list | |
method | the static function that uncompress the particular type of file |
Definition at line 101 of file BESUncompressManager.cc.
Referenced by BESUncompressManager().
void BESUncompressManager::dump | ( | ostream & | strm | ) | const [virtual] |
dumps information about this object
Displays the pointer value of this instance along with the names of the registered uncompression methods.
strm | C++ i/o stream to dump the information to |
Implements BESObj.
Definition at line 318 of file BESUncompressManager.cc.
References BESIndent::Indent(), BESIndent::LMarg(), and BESIndent::UnIndent().
Here is the call graph for this function:
p_bes_uncompress BESUncompressManager::find_method | ( | const string & | name | ) | [virtual] |
returns the uncompression method specified
This method looks up the uncompression method with the given name and returns that method.
name | name of the uncompression method to find |
Definition at line 144 of file BESUncompressManager.cc.
Referenced by uncompress().
string BESUncompressManager::get_method_names | ( | ) | [virtual] |
returns the comma separated list of all uncompression methods currently registered.
Definition at line 161 of file BESUncompressManager.cc.
bool BESUncompressManager::remove_method | ( | const string & | name | ) | [virtual] |
removes a uncompress method from the list
The static method that knows how to uncompress the specified type of file is removed from the list.
name | name of the method to remove |
Definition at line 123 of file BESUncompressManager.cc.
BESUncompressManager * BESUncompressManager::TheManager | ( | ) | [static] |
bool BESUncompressManager::uncompress | ( | const string & | src, | |
string & | target, | |||
BESCache & | cache | |||
) | [virtual] |
find the method that can uncompress the specified src and pass control to that method.
First, the cache passed is locked to make sure no one else attempts to purge the cache at the same time we're checking the cache.
Secondly, the cache is checked to determine if the target file already exists. The check method on the cache returns the target file, whether it is cached or not. If it is cached then that target file is returned and the cache is unlocked.
If it is not cached then it is uncompressed using the static function registered with the same name as the file extension to be uncomressed (converted to lower case). For example, if the source file is a .GZ file (gzipped file) then we find the uncompress function with the name gz. The cache is then unlocked and the target returned.
If the file extension cannot be found in the list then the source file is returned as the target file. If, for example, a compressed file with the extension .bozo is passed as the source file, and there is no uncompression function with the name bozo, then the src file with the extension .bozo is returned as is.
src | file to be uncompressed | |
target | target file to uncompress into | |
cache | BESCache object to uncompress the src file in |
BESInternalError | if there is a problem uncompressing the file. |
Definition at line 207 of file BESUncompressManager.cc.
References BESDEBUG, BESCache::cache_dir(), find_method(), BESCache::is_cached(), BESCache::lock(), BESCache::purge(), and BESCache::unlock().
Referenced by BESFileContainer::access().
Here is the call graph for this function: