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

SIO_streamManager Class Reference

#include <SIO_streamManager.h>

Collaboration diagram for SIO_streamManager:

Collaboration graph
[legend]
List of all members.

Static Public Member Functions

SIO_streamadd (const char *)
SIO_streamadd (const char *, unsigned int)
SIO_streamget (const char *)
SIO_verbosity getVerbosity ()
unsigned int remove (const char *)
unsigned int remove (SIO_stream *)
SIO_verbosity setVerbosity (SIO_verbosity)

Static Private Attributes

streamMap_cstreamMap = NULL
SIO_verbosity verbosity = SIO_ERRORS

Member Function Documentation

SIO_stream * SIO_streamManager::add const char *  ,
unsigned  int
[static]
 

Definition at line 42 of file SIO_streamManager.cc.

References SIO_ALL, SIO_ERRORS, SIO_KBYTE, streamMap_c, and SIO_functions::validateName().

00046 {
00047 
00048   //
00049   // Local variables.
00050   //
00051   std::pair< streamMap_i, bool >
00052     status;
00053 
00054   std::string
00055     s_name = i_name;
00056 
00057   //
00058   // Check the name for validity.
00059   //
00060   if( !SIO_functions::validateName( i_name ) )
00061     {
00062       if( verbosity >= SIO_ERRORS )
00063         {
00064           std::cout << "SIO: [Stream Manager] "
00065                     << "Invalid stream name "
00066                     << i_name
00067                     << std::endl;
00068         }
00069       return( NULL );
00070     }
00071 
00072   //
00073   // Ensure a minimum 4 kByte buffer.
00074   //
00075   if( i_reserve < 4 * SIO_KBYTE )
00076     i_reserve = 4 * SIO_KBYTE;
00077 
00078   //
00079   // If the map's never been instantiated, do it now!
00080   //
00081   if( streamMap == NULL )
00082     streamMap = new streamMap_c;
00083 
00084   //
00085   // Initialize the map entry.
00086   //
00087   std::pair< std::string const, SIO_stream* >
00088     entry( s_name, NULL );
00089 
00090   //
00091   // Insert the entry.  This may or may not succeed depending on whether the
00092   // named stream pre-exists.  If it does pre-exist, print a warning and return
00093   // a NULL pointer (that should get the caller's attention).
00094   //
00095   status = streamMap->insert( entry );
00096   if( !status.second )
00097     {
00098       if( verbosity >= SIO_ERRORS )
00099         {
00100           std::cout << "SIO: [Stream Manager] Stream "
00101                     << i_name
00102                     << " not added (already exists)"
00103                     << std::endl;
00104         }
00105       return( NULL );
00106     }
00107 
00108   //
00109   // Create the stream to go with this map entry.
00110   //
00111   (status.first)->second = new SIO_stream( i_name, i_reserve, verbosity );
00112 
00113   if( verbosity >= SIO_ALL )
00114     {
00115       std::cout << "SIO: [Stream Manager] Added stream "
00116                 << i_name
00117                 << std::endl;
00118     }
00119 
00120   //
00121   // That's all folks!
00122   //
00123   return (status.first)->second;
00124 }

SIO_stream * SIO_streamManager::add const char *   )  [static]
 

Definition at line 33 of file SIO_streamManager.cc.

References SIO_KBYTE.

Referenced by LCDG4_SIOglobal::LCDG4_SIOglobal().

00036 { return add( i_name, 4 * SIO_KBYTE ); }

SIO_stream * SIO_streamManager::get const char *   )  [static]
 

Definition at line 130 of file SIO_streamManager.cc.

References SIO_ALL, SIO_ERRORS, and streamMap_i.

00133 {
00134 
00135   //
00136   // Search the map (if it exists yet!)
00137   //
00138   if( streamMap != NULL )
00139     {
00140       streamMap_i
00141         iter;
00142 
00143       std::string
00144         s_name = i_name;
00145 
00146       if( (iter = streamMap->find( s_name )) != streamMap->end() )
00147         {
00148           if( verbosity >= SIO_ALL )
00149             {
00150               std::cout << "SIO: [Stream Manager] Stream "
00151                         << i_name
00152                         << " is defined (pointer returned)"
00153                         << std::endl;
00154             }
00155           return( iter->second );
00156         }
00157     }
00158 
00159   if( verbosity >= SIO_ERRORS )
00160     {
00161       std::cout << "SIO: [Stream Manager] Stream "
00162                 << i_name
00163                 << " has not been defined"
00164                 << std::endl;
00165     }
00166 
00167   //
00168   // That's all folks!
00169   //
00170   return( NULL );
00171 }

SIO_verbosity SIO_streamManager::getVerbosity  )  [static]
 

Definition at line 176 of file SIO_streamManager.cc.

References SIO_verbosity, and verbosity.

00176 { return( verbosity ); }

unsigned int SIO_streamManager::remove SIO_stream  )  [static]
 

Definition at line 237 of file SIO_streamManager.cc.

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

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

Definition at line 182 of file SIO_streamManager.cc.

References SIO_ALL, SIO_ERRORS, SIO_STREAM_NOTFOUND, SIO_STREAM_SUCCESS, and streamMap_i.

00185 {
00186 
00187   //
00188   // Search the map (if it exists!)
00189   //
00190   if( streamMap != NULL )
00191     {
00192       streamMap_i
00193         iter;
00194 
00195       std::string
00196         s_name = i_name;
00197 
00198       if( (iter = streamMap->find( s_name )) != streamMap->end() )
00199         {
00200           delete iter->second;
00201           streamMap->erase( iter );
00202 
00203           if( verbosity >= SIO_ALL )
00204             {
00205               std::cout << "SIO: [Stream Manager] Removed stream "
00206                         << i_name
00207                         << std::endl;
00208             }
00209 
00210           if( streamMap->size() == 0 )
00211             {
00212               delete streamMap;
00213               streamMap = NULL;
00214             }
00215           return( SIO_STREAM_SUCCESS );
00216         }
00217     }
00218 
00219   if( verbosity >= SIO_ERRORS )
00220     {
00221       std::cout << "SIO: [Stream Manager] Cannot remove stream "
00222                 << i_name
00223                 << " (it was never added)"
00224                 << std::endl;
00225     }
00226 
00227   //
00228   // That's all folks!
00229   //
00230   return( SIO_STREAM_NOTFOUND );
00231 }

SIO_verbosity SIO_streamManager::setVerbosity SIO_verbosity   )  [static]
 

Definition at line 246 of file SIO_streamManager.cc.

References SIO_verbosity.

Referenced by LCDG4_SIOglobal::LCDG4_SIOglobal().

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


Member Data Documentation

streamMap_c * SIO_streamManager::streamMap = NULL [static, private]
 

Definition at line 26 of file SIO_streamManager.cc.

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

Definition at line 27 of file SIO_streamManager.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