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

SIO_blockManager Class Reference

#include <SIO_blockManager.h>

Collaboration diagram for SIO_blockManager:

Collaboration graph
[legend]
List of all members.

Static Public Member Functions

SIO_blockadd (SIO_block *)
SIO_blockget (const char *)
SIO_verbosity getVerbosity ()
unsigned int remove (const char *)
unsigned int remove (SIO_block *)
SIO_verbosity setVerbosity (SIO_verbosity)

Static Private Attributes

blockMap_cblockMap = NULL
SIO_verbosity verbosity = SIO_SILENT

Member Function Documentation

SIO_block * SIO_blockManager::add SIO_block  )  [static]
 

Definition at line 34 of file SIO_blockManager.cc.

References blockMap_c, SIO_block::getName(), SIO_ALL, SIO_ERRORS, and SIO_functions::validateName().

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

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

SIO_block * SIO_blockManager::get const char *   )  [static]
 

Definition at line 115 of file SIO_blockManager.cc.

References blockMap_i, and SIO_ALL.

Referenced by SIO_record::connect(), SIO_record::disconnect(), SIO_record::read(), and SIO_block::~SIO_block().

00118 {
00119 
00120   //
00121   // Search the map (if it exists yet!)
00122   //
00123   if( blockMap != NULL )
00124     {
00125       blockMap_i
00126         iter;
00127 
00128       std::string
00129         s_name = i_name;
00130 
00131       if( (iter = blockMap->find( s_name )) != blockMap->end() )
00132         {
00133           if( verbosity >= SIO_ALL )
00134             {
00135               std::cout << "SIO: [Block Manager] Block "
00136                         << i_name
00137                         << " is defined (pointer returned)"
00138                         << std::endl;
00139             }
00140           return( iter->second );
00141         }
00142     }
00143 
00144   if( verbosity >= SIO_ALL )
00145     {
00146       std::cout << "SIO: [Block Manager] Block "
00147                 << i_name
00148                 << " has not been defined"
00149                 << std::endl;
00150     }
00151 
00152   //
00153   // That's all folks!
00154   //
00155   return( NULL );
00156 }

SIO_verbosity SIO_blockManager::getVerbosity  )  [static]
 

Definition at line 161 of file SIO_blockManager.cc.

References SIO_verbosity, and verbosity.

00161 { return( verbosity ); }

unsigned int SIO_blockManager::remove SIO_block  )  [static]
 

Definition at line 232 of file SIO_blockManager.cc.

00235 { return( remove( block->getName()->c_str() ) ); }

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

Definition at line 167 of file SIO_blockManager.cc.

References blockMap_i, SIO_recordManager::disconnect(), SIO_ALL, SIO_BLOCK_NOTFOUND, SIO_BLOCK_SUCCESS, and SIO_ERRORS.

Referenced by SIO_block::~SIO_block().

00170 {
00171 
00172   //
00173   // Search the map (if it exists!)
00174   //
00175   if( blockMap != NULL )
00176     {
00177       blockMap_i
00178         iter;
00179 
00180       std::string
00181         s_name = i_name;
00182 
00183       if( (iter = blockMap->find( s_name )) != blockMap->end() )
00184         {
00185 
00186           //
00187           // The block is in the list.  Before removing it, ensure that it
00188           // isn't connected to any records.
00189           //
00190           SIO_recordManager::disconnect( i_name );
00191 
00192 
00193           //
00194           // OK, remove it from management.
00195           //
00196           blockMap->erase( iter );
00197 
00198           if( verbosity >= SIO_ALL )
00199             {
00200               std::cout << "SIO: [Block Manager] Removed block "
00201                         << i_name
00202                         << std::endl;
00203             }
00204 
00205           if( blockMap->size() == 0 )
00206             {
00207               delete blockMap;
00208               blockMap = NULL;
00209             }
00210           return( SIO_BLOCK_SUCCESS );
00211         }
00212     }
00213 
00214   if( verbosity >= SIO_ERRORS )
00215     {
00216       std::cout << "SIO: [Block Manager] Cannot remove block "
00217                 << i_name
00218                 << " (it was never added)"
00219                 << std::endl;
00220     }
00221 
00222   //
00223   // That's all folks!
00224   //
00225   return( SIO_BLOCK_NOTFOUND );
00226 }

SIO_verbosity SIO_blockManager::setVerbosity SIO_verbosity   )  [static]
 

Definition at line 241 of file SIO_blockManager.cc.

References SIO_verbosity.

Referenced by LCDG4_SIOglobal::LCDG4_SIOglobal().

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


Member Data Documentation

blockMap_c * SIO_blockManager::blockMap = NULL [static, private]
 

Definition at line 27 of file SIO_blockManager.cc.

SIO_verbosity SIO_blockManager::verbosity = SIO_SILENT [static, private]
 

Definition at line 28 of file SIO_blockManager.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