35 using std::istringstream ;
64 string key =
"BES.Uncompress.Retry" ;
67 if( !found || val.empty() )
73 istringstream is( val ) ;
77 key =
"BES.Uncompress.NumTries" ;
80 if( !found || val.empty() )
86 istringstream is( val ) ;
104 BESUncompressManager::UCIter i ;
105 i = _uncompress_list.find( name ) ;
106 if( i == _uncompress_list.end() )
108 _uncompress_list[name] = method ;
125 BESUncompressManager::UIter i ;
126 i = _uncompress_list.find( name ) ;
127 if( i != _uncompress_list.end() )
129 _uncompress_list.erase( i ) ;
146 BESUncompressManager::UCIter i ;
147 i = _uncompress_list.find( name ) ;
148 if( i != _uncompress_list.end() )
164 bool first_name = true ;
165 BESUncompressManager::UCIter i = _uncompress_list.begin() ;
166 for( ; i != _uncompress_list.end(); i++ )
216 BESDEBUG(
"bes",
"BESUncompressManager::uncompress - src = " << src << endl ) ;
217 string::size_type dot = src.rfind(
"." ) ;
218 if( dot != string::npos )
220 string ext = src.substr( dot+1, src.length() - dot ) ;
225 for(
int i = 0; i < static_cast<int>(ext.length()); i++ )
227 ext[i] = tolower( ext[i] ) ;
242 if( cache.
lock( _retry, _num_tries ) )
249 BESDEBUG(
"bes",
"BESUncompressManager::uncompress - is cached? " << src << endl ) ;
252 BESDEBUG(
"bes",
"BESUncompressManager::uncompress - " <<
"is cached " << target << endl ) ;
260 BESDEBUG(
"bes",
"BESUncompressManager::uncompress - " <<
"purging cache" << endl ) ;
264 BESDEBUG(
"bes",
"BESUncompressManager::uncompress - "
265 <<
"uncompress to " << target
266 <<
" using " << ext <<
" uncompression"
295 string err = (string)
"Problem working with the cache, "
298 throw BESInternalError(
"Problem working with the cache, unknown error", __FILE__,__LINE__);
303 string err =
"Unable to lock the cache "
310 BESDEBUG(
"bes",
"BESUncompressManager::uncompress - not compressed " << endl ) ;
315 BESDEBUG(
"bes",
"BESUncompressmanager::uncompress - not file extension" << endl ) ;
319 string err =
"Unable to determine type of file from "
339 << (
void *)
this <<
")" << endl ;
341 if( _uncompress_list.size() )
345 BESUncompressManager::UCIter i = _uncompress_list.begin() ;
346 BESUncompressManager::UCIter ie = _uncompress_list.end() ;
347 for( ; i != ie; i++ )
static BESUncompressManager * TheManager()
static void uncompress(const string &src, const string &target)
uncompress a file with the .gz file extension
virtual bool remove_method(const string &name)
removes a uncompress method from the list
static void uncompress(const string &src, const string &target)
uncompress a file with the .bz2 file extension
exception thrown if inernal error encountered
virtual bool lock(unsigned int retry_ms, unsigned int num_tries)
lock the cache using a file lock
virtual void dump(ostream &strm) const
dumps information about this object
virtual void purge()
Check to see if the cache size exceeds the size specified in the constructor and purge older files un...
Implementation of a caching mechanism.
List of all registered uncompress methods.
Abstract exception class for the BES with basic string message.
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 string get_method_names()
returns the comma separated list of all uncompression methods currently registered.
static ostream & LMarg(ostream &strm)
virtual bool add_method(const string &name, p_bes_uncompress method)
add a uncompress method to the list
virtual bool unlock()
unlock the cache
virtual p_bes_uncompress find_method(const string &name)
returns the uncompression method specified
static void uncompress(const string &src, const string &target)
uncompress a file with the .gz file extension
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
virtual bool is_cached(const string &src, string &target)
Determine if the file specified by src is cached.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
static BESKeys * TheKeys()
void(* p_bes_uncompress)(const string &src, const string &target)
BESUncompressManager(void)
constructs an uncompression manager adding gz, z, and bz2 uncompression methods by default...