OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESUncompressManager Class Reference

List of all registered uncompress methods. More...

#include <BESUncompressManager.h>

Inheritance diagram for BESUncompressManager:
Inheritance graph
Collaboration diagram for BESUncompressManager:
Collaboration graph

List of all members.

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 BESUncompressManagerTheManager ()

Protected Member Functions

 BESUncompressManager (void)
 constructs an uncompression manager adding gz, z, and bz2 uncompression methods by default.

Detailed Description

List of all registered uncompress methods.

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.

See also:
BESUncompressGZ
BESUncompressBZ2
BESUncompressZ
BESCache

Definition at line 66 of file BESUncompressManager.h.


Constructor & Destructor Documentation

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(), BESUncompressGZ::uncompress(), and BESUncompressBZ2::uncompress().

Referenced by TheManager().

Here is the call graph for this function:

virtual BESUncompressManager::~BESUncompressManager ( void  )
inlinevirtual

Definition at line 79 of file BESUncompressManager.h.


Member Function Documentation

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.

Parameters:
namename of the method to add to the list
methodthe static function that uncompress the particular type of file
Returns:
true if successfully added, false if it already exists

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.

Parameters:
strmC++ i/o stream to dump the information to

Implements BESObj.

Definition at line 331 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.

Parameters:
namename of the uncompression method to find
Returns:
the function of type p_bes_uncompress

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.

Returns:
comma separated list of uncompression method names

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.

Parameters:
namename of the method to remove
Returns:
true if successfully removed, false if it doesn't exist in the list

Definition at line 123 of file BESUncompressManager.cc.

BESUncompressManager * BESUncompressManager::TheManager ( )
static

Definition at line 356 of file BESUncompressManager.cc.

References BESUncompressManager().

Referenced by BESFileContainer::access().

Here is the call graph for this function:

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.

If there is a problem uncompressing the file, the uncompress code is responsible for closing the source file, the target file, AND REMOVING THE TARGET FILE. If the target file is left in place after an error, then the cache might use that file in the future for a request.

Parameters:
srcfile to be uncompressed
targettarget file to uncompress into
cacheBESCache object to uncompress the src file in
Returns:
full path to the uncompressed file
Exceptions:
BESInternalErrorif there is a problem uncompressing the file.

Definition at line 213 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:


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