#include <SIO_blockManager.h>
Collaboration diagram for SIO_blockManager:

Static Public Member Functions | |
| SIO_block * | add (SIO_block *) |
| SIO_block * | get (const char *) |
| SIO_verbosity | getVerbosity () |
| unsigned int | remove (const char *) |
| unsigned int | remove (SIO_block *) |
| SIO_verbosity | setVerbosity (SIO_verbosity) |
Static Private Attributes | |
| blockMap_c * | blockMap = NULL |
| SIO_verbosity | verbosity = SIO_SILENT |
|
|
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 }
|
|
|
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 }
|
|
|
Definition at line 161 of file SIO_blockManager.cc. References SIO_verbosity, and verbosity.
00161 { return( verbosity ); }
|
|
|
Definition at line 232 of file SIO_blockManager.cc.
|
|
|
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 }
|
|
|
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 ); }
|
|
|
Definition at line 27 of file SIO_blockManager.cc. |
|
|
Definition at line 28 of file SIO_blockManager.cc. Referenced by getVerbosity(). |
1.3.4