Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

SIO_recordManager Class Reference

#include <SIO_recordManager.h>

Collaboration diagram for SIO_recordManager:

Collaboration graph
[legend]
List of all members.

Static Public Member Functions

SIO_recordadd (const char *)
SIO_recordget (const char *)
SIO_verbosity getVerbosity ()
unsigned int remove (const char *)
unsigned int remove (SIO_record *)
SIO_verbosity setVerbosity (SIO_verbosity)

Static Private Member Functions

void disconnect (const char *)

Static Private Attributes

recordMap_crecordMap = NULL
SIO_verbosity verbosity = SIO_ERRORS

Friends

class SIO_blockManager

Member Function Documentation

SIO_record * SIO_recordManager::add const char *   )  [static]
 

Definition at line 33 of file SIO_recordManager.cc.

References recordMap_c, SIO_ALL, SIO_ERRORS, and SIO_functions::validateName().

Referenced by LCDG4EventAction::EndOfEventAction(), and LCDG4_SIOglobal::LCDG4_SIOglobal().

00036 {
00037 
00038   //
00039   // Local variables.
00040   //
00041   std::pair< recordMap_i, bool >
00042     status;
00043 
00044   std::string
00045     s_name = i_name;
00046 
00047   //
00048   // Check the name for validity.
00049   //
00050   if( !SIO_functions::validateName( i_name ) )
00051     {
00052       if( verbosity >= SIO_ERRORS )
00053         {
00054           std::cout << "SIO: [Record Manager] "
00055                     << "Invalid record name"
00056                     << i_name
00057                     << std::endl;
00058         }
00059       return( NULL );
00060     }
00061 
00062   //
00063   // If the map's never been instantiated, do it now!
00064   //
00065   if( recordMap == NULL )
00066     recordMap = new recordMap_c;
00067 
00068   //
00069   // Initialize the map entry.
00070   //
00071   std::pair< std::string const, SIO_record* >
00072     entry( s_name, NULL );
00073 
00074   //
00075   // Insert the entry.  This may or may not succeed depending on whether the
00076   // named record pre-exists.  If it does pre-exist, print a warning and return
00077   // a NULL pointer (that should get the caller's attention).
00078   //
00079   status = recordMap->insert( entry );
00080   if( !status.second )
00081     {
00082       if( verbosity >= SIO_ERRORS )
00083         {
00084           std::cout << "SIO: [Record Manager] Record"
00085                     << i_name
00086                     << "not added (already exists)"
00087                     << std::endl;
00088         }
00089       return( NULL );
00090     }
00091 
00092   //
00093   // Create the record to go with this map entry.
00094   //
00095   (status.first)->second = new SIO_record( i_name, verbosity );
00096 
00097   if( verbosity >= SIO_ALL )
00098     {
00099       std::cout << "SIO: [Record Manager] Added record "
00100                 << i_name
00101                 << std::endl;
00102     }
00103 
00104   //
00105   // That's all folks!
00106   //
00107   return (status.first)->second;
00108 }

void SIO_recordManager::disconnect const char *   )  [static, private]
 

Definition at line 114 of file SIO_recordManager.cc.

References recordMap_i, and SIO_ALL.

Referenced by SIO_blockManager::remove().

00117 {
00118 
00119   //
00120   // Loop over the map (if it exists yet!)
00121   //
00122   if( recordMap != NULL )
00123     {
00124       recordMap_i
00125         iter;
00126 
00127       for( iter = recordMap->begin(); iter != recordMap->end(); iter++ )
00128         {
00129           if( iter->second->getConnect( i_name ) != NULL )
00130             iter->second->disconnect( i_name );
00131         }
00132     }
00133 
00134   if( verbosity >= SIO_ALL )
00135     {
00136       std::cout << "SIO: [Record Manager] Block "
00137                 << i_name
00138                 << " disconnected from all records"
00139                 << std::endl;
00140     }
00141 
00142   //
00143   // That's all folks!
00144   //
00145   return;
00146 }

SIO_record * SIO_recordManager::get const char *   )  [static]
 

Definition at line 152 of file SIO_recordManager.cc.

References recordMap_i, SIO_ALL, and SIO_ERRORS.

Referenced by CalorimeterSIO::CalorimeterSIO(), MCPrintSIO::MCPrintSIO(), MuonSIO::MuonSIO(), SIO_stream::read(), TrackerSIO::TrackerSIO(), VxdSIO::VxdSIO(), and SIO_stream::write().

00155 {
00156 
00157   //
00158   // Search the map (if it exists yet!)
00159   //
00160   if( recordMap != NULL )
00161     {
00162       recordMap_i
00163         iter;
00164 
00165       std::string
00166         s_name = i_name;
00167 
00168       if( (iter = recordMap->find( s_name )) != recordMap->end() )
00169         {
00170           if( verbosity >= SIO_ALL )
00171             {
00172               std::cout << "SIO: [Record Manager] Record "
00173                         << i_name
00174                         << " is defined (pointer returned)"
00175                         << std::endl;
00176             }
00177           return( iter->second );
00178         }
00179     }
00180 
00181   if( verbosity >= SIO_ERRORS )
00182     {
00183       std::cout << "SIO: [Record Manager] Record "
00184                 << i_name
00185                 << " has not been defined"
00186                 << std::endl;
00187     }
00188 
00189   //
00190   // That's all folks!
00191   //
00192   return( NULL );
00193 }

SIO_verbosity SIO_recordManager::getVerbosity  )  [static]
 

Definition at line 198 of file SIO_recordManager.cc.

References SIO_verbosity, and verbosity.

00198 { return( verbosity ); }

unsigned int SIO_recordManager::remove SIO_record  )  [static]
 

Definition at line 259 of file SIO_recordManager.cc.

00262 { return( remove( record->getName()->c_str() ) ); }

unsigned int SIO_recordManager::remove const char *   )  [static]
 

Definition at line 204 of file SIO_recordManager.cc.

References recordMap_i, SIO_ALL, SIO_ERRORS, SIO_RECORD_NOTFOUND, and SIO_RECORD_SUCCESS.

Referenced by LCDG4EventAction::EndOfEventAction(), and LCDG4_SIOglobal::LCDG4_SIOglobal().

00207 {
00208 
00209   //
00210   // Search the map (if it exists!)
00211   //
00212   if( recordMap != NULL )
00213     {
00214       recordMap_i
00215         iter;
00216 
00217       std::string
00218         s_name = i_name;
00219 
00220       if( (iter = recordMap->find( s_name )) != recordMap->end() )
00221         {
00222           delete iter->second;
00223           recordMap->erase( iter );
00224 
00225           if( verbosity >= SIO_ALL )
00226             {
00227               std::cout << "SIO: [Record Manager] Removed record "
00228                         << s_name
00229                         << std::endl;
00230             }
00231 
00232           if( recordMap->size() == 0 )
00233             {
00234               delete recordMap;
00235               recordMap = NULL;
00236             }
00237           return( SIO_RECORD_SUCCESS );
00238         }
00239     }
00240 
00241   if( verbosity >= SIO_ERRORS )
00242     {
00243       std::cout << "SIO: [Record Manager] Cannot remove record "
00244                 << i_name
00245                 << " (it was never added)"
00246                 << std::endl;
00247     }
00248 
00249   //
00250   // That's all folks!
00251   //
00252   return( SIO_RECORD_NOTFOUND );
00253 }

SIO_verbosity SIO_recordManager::setVerbosity SIO_verbosity   )  [static]
 

Definition at line 268 of file SIO_recordManager.cc.

References SIO_verbosity.

Referenced by LCDG4_SIOglobal::LCDG4_SIOglobal().

00271 { SIO_verbosity o_verb = verbosity; verbosity = i_verb; return( o_verb ); }


Friends And Related Function Documentation

friend class SIO_blockManager [friend]
 

Definition at line 41 of file SIO_recordManager.h.


Member Data Documentation

recordMap_c * SIO_recordManager::recordMap = NULL [static, private]
 

Definition at line 26 of file SIO_recordManager.cc.

SIO_verbosity SIO_recordManager::verbosity = SIO_ERRORS [static, private]
 

Definition at line 27 of file SIO_recordManager.cc.

Referenced by getVerbosity().


The documentation for this class was generated from the following files:
Generated on Thu Oct 7 18:45:10 2004 for LCDG4 by doxygen 1.3.4