| Octane v1.01.20 - The Open Compression Toolkit for C++ | http://octane.sourceforge.net/ |
#include <compressormanager.hpp>
Inheritance diagram for CompressorManager:

Definition at line 38 of file compressormanager.hpp.
Public Member Functions | |
| CompressorManager () | |
| Constructor. | |
| ~CompressorManager () | |
| Destructor. | |
| int | GetBaseCompressorCount () |
| accessor for instantiated compressor vector size | |
| int | GetInstantiatedCompressorCount () |
| accessor for instantiated compressor vector size | |
| OctaneCompressor * | GetBaseCompressorp (int index) |
| accessor for instantiated compressor vector | |
| OctaneCompressor * | GetInstantiatedCompressorp (int index) |
| accessor for instantiated compressor vector | |
| OctaneCompressor * | FindBaseCompressorClass (const std::string &compressorname) |
| Find a base compressor for subsequent operations. | |
| OctaneCompressor * | FindInstantiatedCompressorpFromStringId (std::string idstring) |
| Find the pointer to the instantiated compressor referred to by idstring idstring can be [$name|$num|G$guid]. | |
| OctaneCompressor * | FindInstantiatedCompressorpFromGuid (unsigned short int guidindex) |
| Find the pointer to the instantiated compressor referred to by a guid. | |
| void | RegisterBaseCompressor (OctaneCompressor *compressorp) |
| Register a new compressor. | |
| void | UnRegisterBaseCompressor (OctaneCompressor *compressorp) |
| Unregister a new compressor. | |
| void | Initialize () |
| Initialize the compressdecompress manager before using it. | |
| void | DeInitialize () |
| Deinitialize the compressdecompress manager when done with it. | |
| OctaneCompressor * | CreateCompressorFromSavedStream (bitreader &from) |
| Create a new compressor based on file info and load state. | |
| bool | AddCompressor (OctaneCompressor *compressorp) |
| Add an instantiated compressor to our instantiated list. | |
| bool | DeleteCompressor (OctaneCompressor *compressorp) |
| Delete an instantiated compressor to our instantiated list. | |
Protected Attributes | |
| std::vector< OctaneCompressor * > | compressorvector_basetypes |
| Vector holding the registered base compressor types. | |
| std::vector< OctaneCompressor * > | compressorvector_instantiated |
| Vector holding the registered compressors. | |
|
|
Find a base compressor for subsequent operations.
Definition at line 96 of file compressormanager.cpp. References compressorvector_basetypes. Referenced by CreateCompressorFromSavedStream(), and OctaneTester::RunCommand_CreateCompressor().
00097 {
00098 // remove a compressor from our list of registered components.
00099 // you don't have to call this on exit of the program, only if you are for some reason
00100 // removing compressors during the execution of the program.
00101 vector<OctaneCompressor*>::iterator index;
00102 for (index=compressorvector_basetypes.begin();index!=compressorvector_basetypes.end();++index)
00103 {
00104 if ((*index)->GetClassName()==compressorname)
00105 return (*index);
00106 }
00107 return NULL;
00108 }
|
|
|
Find the pointer to the instantiated compressor referred to by idstring idstring can be [$name|$num|G$guid].
Definition at line 193 of file compressormanager.cpp. References compressorvector_instantiated. Referenced by OctaneTester::RunCommand_DeleteCompressor(), and OctaneTester::SelectInstantiatedCompressor().
00194 {
00195 // look up a compressor based on different strings
00196 if (idstring=="")
00197 return NULL;
00198
00199 // there are 3 ways to specify an instantiated compressor
00200 OctaneCompressor* compressorp=NULL;
00201 int indexnum;
00202 indexnum = atoi(idstring.c_str());
00203
00204 if (indexnum>0 || idstring=="0")
00205 {
00206 // user gave us an index
00207 if (indexnum<0 || (unsigned int)indexnum>=compressorvector_instantiated.size())
00208 return NULL;
00209 compressorp=compressorvector_instantiated[indexnum];
00210 return compressorp;
00211 }
00212
00213 // ok its either a full name or a guid
00214 // first we try to look it up by name
00215 vector<OctaneCompressor*>::iterator index;
00216 for (index=compressorvector_instantiated.begin();index!=compressorvector_instantiated.end();++index)
00217 {
00218 if ((*index)->GetInstantiatedName()==idstring)
00219 return (*index);
00220 }
00221
00222 // we didn't find it, so try to check its guid
00223 if (idstring[0]!='g' && idstring[0]!='G')
00224 return NULL;
00225 idstring=idstring.substr(1,idstring.length()-1);
00226 indexnum=atoi(idstring.c_str());
00227 if (indexnum>0 || idstring=="0")
00228 {
00229 for (index=compressorvector_instantiated.begin();index!=compressorvector_instantiated.end();++index)
00230 {
00231 if ((*index)->GetGuid()==indexnum)
00232 return (*index);
00233 }
00234 }
00235 return NULL;
00236 }
|
|
|
Find the pointer to the instantiated compressor referred to by a guid.
Definition at line 239 of file compressormanager.cpp. References compressorvector_instantiated. Referenced by OctaneTester::RunCommand_Decompress().
00240 {
00241 // Find the pointer to the instantiated compressor referred to by a guid
00242 // return NULL if not found
00243 vector<OctaneCompressor*>::iterator index;
00244 for (index=compressorvector_instantiated.begin();index!=compressorvector_instantiated.end();++index)
00245 {
00246 if ((*index)->GetGuid()==guidindex)
00247 return (*index);
00248 }
00249 return NULL;
00250 }
|
|
|
Create a new compressor based on file info and load state.
Definition at line 115 of file compressormanager.cpp. References FindBaseCompressorClass(), bitreader::get(), OctaneCompressor::LoadState(), OctaneCompressor::MakeCompressorInstantiation(), and OctaneCompressor::SetInfo(). Referenced by OctaneTester::RunCommand_Decompress(), and OctaneTester::RunCommand_LoadCompressor().
00116 {
00117 // in the saved stream we expect to find a 'header' which tells us the 1)compressorclass, 2)compressorname, and 3)compressorguid
00118 // then we create a compressor of that type, and tell it to read its state info from the remainder of stream
00119
00120 // read standard compressor header (see OctaneCompressor::Save() for where this is written)
00121 string compressorclassname;
00122 string compressorname;
00123 short int compressorguid;
00124 from.get(compressorclassname);
00125 from.get(compressorname);
00126 from.get(compressorguid);
00127
00128 // select base compressor class type
00129 OctaneCompressor *compressorp = FindBaseCompressorClass(compressorclassname);
00130 if (compressorp==NULL)
00131 {
00132 // couldn't find base class
00133 cout << "ERROR: compressor in file is based on compressor class '"<<compressorclassname<<"' which is not known."<<endl;
00134 return NULL;
00135 }
00136
00137 // ask base class to make us a derived class
00138 compressorp=compressorp->MakeCompressorInstantiation();
00139 if (compressorp==NULL)
00140 {
00141 // couldn't find base class
00142 cout << "ERROR: failed to instantiate a derived compressor from base class '"<<compressorclassname<<"'."<<endl;
00143 return NULL;
00144 }
00145
00146 // now set details (compressor name and guid) from file
00147 compressorp->SetInfo(compressorname,compressorguid);
00148
00149 // now load the details from the file
00150 bool bretv=compressorp->LoadState(from);
00151 if (!bretv)
00152 {
00153 delete compressorp;
00154 compressorp=NULL;
00155 }
00156
00157 // return pointer to newly created compressor
00158 return compressorp;
00159 }
|
|
|
Add an instantiated compressor to our instantiated list.
Definition at line 163 of file compressormanager.cpp. References compressorvector_instantiated. Referenced by OctaneTester::RunCommand_CreateCompressor(), and OctaneTester::RunCommand_LoadCompressor().
00164 {
00165 // just add a compressor to the instantiated vector
00166 // show some debug info?
00167 // cout << "$DEBUG Adding instantiated compressor '" << compressorp->get_compressor_name() << "'."<<endl;
00168 compressorvector_instantiated.push_back(compressorp);
00169 return true;
00170 }
|
|
|
Delete an instantiated compressor to our instantiated list.
Definition at line 174 of file compressormanager.cpp. References compressorvector_instantiated. Referenced by OctaneTester::RunCommand_DeleteCompressor().
00175 {
00176 // just add a compressor to the instantiated vector
00177 vector<OctaneCompressor*>::iterator index;
00178 for (index=compressorvector_instantiated.begin();index!=compressorvector_instantiated.end();++index)
00179 {
00180 if (*index==compressorp)
00181 {
00182 // found it, so remove it
00183 compressorvector_instantiated.erase(index);
00184 return true;
00185 }
00186 }
00187 return false;
00188 }
|