Gaudi Framework, version v23r3

Home   Generated: Thu Jun 28 2012

TupleObj.cpp

Go to the documentation of this file.
00001 // $Id: TupleObj.cpp,v 1.8 2007/09/28 11:47:29 marcocle Exp $
00002 // ============================================================================
00003 // Include files
00004 // ============================================================================
00005 // STD & STL
00006 // ============================================================================
00007 #include <cstdarg>
00008 #include <algorithm>
00009 #include <map>
00010 // ============================================================================
00011 // GaudiKernel
00012 // ============================================================================
00013 #include "GaudiKernel/GaudiException.h"
00014 // ============================================================================
00015 // GaudiAlg
00016 // ============================================================================
00017 #include "GaudiAlg/Tuples.h"
00018 #include "GaudiAlg/TupleObj.h"
00019 // ============================================================================
00020 // Boost
00021 // ============================================================================
00022 #include  "boost/integer_traits.hpp"
00023 #include  "boost/static_assert.hpp"
00024 // ============================================================================
00032 // ============================================================================
00033 namespace Tuples
00034 {
00035   namespace Local
00036   {
00037     class Counter
00038     {
00039     public:
00040       // constructor
00041       Counter ( const std::string& msg = " Misbalance ")
00042         : m_map     ()
00043         , m_message ( msg )
00044       {}
00045       // destructor
00046       ~Counter() { report() ; m_map.clear() ;}
00047       // make the increment
00048       long increment ( const std::string& object ) { return ++m_map[object] ; }
00049       // make the decrement
00050       long decrement ( const std::string& object ) { return --m_map[object] ; }
00051       // current count
00052       long counts    ( const std::string& object ) { return   m_map[object] ; }
00053       // make a report
00054       void report() const
00055       {
00056         for ( Map::const_iterator entry = m_map.begin() ;
00057               m_map.end() != entry ; ++entry )
00058         {
00059           if( 0 == entry->second ) { continue ; }
00060           std::cout << "Tuples::TupleObj WARNING "          << m_message
00061                     << "'" << entry->first << "' Counts = " << entry->second
00062                     << std::endl ;
00063         }
00064       };
00065 
00066     private:
00067       typedef std::map<std::string,long> Map;
00068       Map         m_map     ;
00069       std::string m_message ;
00070     };
00071 
00077     static Counter s_InstanceCounter ( " Create/Destroy      (mis)balance " ) ;
00078   }
00079 }
00080 // ============================================================================
00081 // Standard constructor
00082 // ============================================================================
00083 Tuples::TupleObj::TupleObj
00084 ( const std::string&    name  ,
00085   NTuple::Tuple*        tuple ,
00086   const CLID&           clid  ,
00087   const Tuples::Type    type  )
00088 //
00089   : m_name     ( name )
00090   , m_tuple    ( tuple )
00091   , m_clid     ( clid )
00092   , m_type     ( type )
00093 // for error handling
00094   , m_refCount ( 0 )
00095 // columns
00096   , m_bools     ()
00097   , m_chars     ()
00098   , m_uchars    ()
00099   , m_shorts    ()
00100   , m_ushorts   ()
00101   , m_ints      ()
00102   , m_uints     ()
00103   , m_longlongs ()
00104   , m_ulonglongs()
00105   , m_floats    ()
00106   , m_doubles   ()
00107   , m_addresses ()
00108   , m_farrays   ()
00109   , m_arraysf   ()
00110   , m_fmatrices ()
00111   , m_matricesf ()
00112 //
00113   , m_items     ()
00114 {
00115   // make counts
00116   Tuples::Local::s_InstanceCounter.increment ( m_name ) ;
00117 }
00118 // ============================================================================
00119 // destructor
00120 // ============================================================================
00121 Tuples::TupleObj::~TupleObj()
00122 {
00123   {// delete 'bool' columns
00124     for( Bools::iterator it = m_bools.begin() ;
00125          m_bools.end() != it ; ++it )
00126     { if( 0 != it->second ) { delete it->second ; } }
00127     m_bools.clear() ;
00128   }
00129   {// delete 'char' columns
00130     for( Chars::iterator it = m_chars.begin() ;
00131          m_chars.end() != it ; ++it )
00132     { if( 0 != it->second ) { delete it->second ; } }
00133     m_chars.clear() ;
00134   }
00135   {// delete 'unsigned char' columns
00136     for( UChars::iterator it = m_uchars.begin() ;
00137          m_uchars.end() != it ; ++it )
00138     { if( 0 != it->second ) { delete it->second ; } }
00139     m_uchars.clear() ;
00140   }
00141   {// delete 'short' columns
00142     for( Shorts::iterator it = m_shorts.begin() ;
00143          m_shorts.end() != it ; ++it )
00144     { if( 0 != it->second ) { delete it->second ; } }
00145     m_shorts.clear() ;
00146   }
00147   {// delete 'unsigned short' columns
00148     for( UShorts::iterator it = m_ushorts.begin() ;
00149          m_ushorts.end() != it ; ++it )
00150     { if( 0 != it->second ) { delete it->second ; } }
00151     m_ushorts.clear() ;
00152   }
00153   {// delete 'int' columns
00154     for( Ints::iterator it = m_ints.begin() ;
00155          m_ints.end() != it ; ++it )
00156     { if( 0 != it->second ) { delete it->second ; } }
00157     m_ints.clear() ;
00158   }
00159   {// delete 'unsigned int' columns
00160     for( UInts::iterator it = m_uints.begin() ;
00161          m_uints.end() != it ; ++it )
00162     { if( 0 != it->second ) { delete it->second ; } }
00163     m_uints.clear() ;
00164   }
00165   {// delete 'longlong' columns
00166     for( LongLongs::iterator it = m_longlongs.begin() ;
00167          m_longlongs.end() != it ; ++it )
00168     { if( 0 != it->second ) { delete it->second ; } }
00169     m_longlongs.clear() ;
00170   }
00171   {// delete 'ulonglong' columns
00172     for( ULongLongs::iterator it = m_ulonglongs.begin() ;
00173          m_ulonglongs.end() != it ; ++it )
00174     { if( 0 != it->second ) { delete it->second ; } }
00175     m_ulonglongs.clear() ;
00176   }
00177   {// delete 'float' columns
00178     for( Floats::iterator it = m_floats.begin() ;
00179          m_floats.end() != it ; ++it )
00180     { if( 0 != it->second ) { delete it->second ; } }
00181     m_floats.clear() ;
00182   }
00183   {// delete 'double' columns
00184     for( Doubles::iterator it = m_doubles.begin() ;
00185          m_doubles.end() != it ; ++it )
00186     { if( 0 != it->second ) { delete it->second ; } }
00187     m_doubles.clear() ;
00188   }
00189   {// delete 'fArray' columns
00190     for( FArrays::iterator it = m_farrays.begin() ;
00191          m_farrays.end() != it ; ++it )
00192     { if( 0 != it->second ) { delete it->second ; } }
00193     m_farrays.clear() ;
00194   }
00195   {// delete 'fArray' columns
00196     for( FArrays::iterator it = m_arraysf.begin() ;
00197          m_arraysf.end() != it ; ++it )
00198     { if( 0 != it->second ) { delete it->second ; } }
00199     m_arraysf.clear() ;
00200   }
00201   { // destroy and clean all "addresses"
00202     for( Addresses::iterator it = m_addresses.begin() ;
00203          m_addresses.end() != it ; ++it )
00204     { if( 0 != it->second ) { delete it->second ; } }
00205     m_addresses.clear();
00206   }
00207   { // destroy and clean all "matrices"
00208     for( FMatrices::iterator it = m_fmatrices.begin() ;
00209          m_fmatrices.end() != it ; ++it )
00210     { if( 0 != it->second ) { delete it->second ; } }
00211     m_fmatrices.clear();
00212   }
00213   { // destroy and clean all "matrices" (fixed)
00214     for( FMatrices::iterator it = m_matricesf.begin() ;
00215          m_matricesf.end() != it ; ++it )
00216     { if( 0 != it->second ) { delete it->second ; } }
00217     m_matricesf.clear();
00218   }
00219 
00220   // make counts
00221   Tuples::Local::s_InstanceCounter.decrement ( m_name ) ;
00222 }
00223 // ============================================================================
00224 // release the reference to TupleObj
00225 // if reference counter becomes zero,
00226 // object will be automatically deleted
00227 // ============================================================================
00228 void Tuples::TupleObj::release ()
00229 {
00230   // decrease the reference counter
00231   if( 0 < refCount() ) { --m_refCount; }
00232   // check references
00233   if( 0 != refCount() ) { return; }
00234   // delete the object
00235   delete this  ;
00236 }
00237 // ============================================================================
00238 // write a record to NTuple
00239 // ============================================================================
00240 StatusCode Tuples::TupleObj::write ()
00241 {
00242   if ( invalid()  ) { return InvalidTuple ; }
00243   return tuple()->write() ;
00244 }
00245 // ============================================================================
00246 namespace
00247 {
00249   typedef std::vector<std::string> Tokens;
00254   size_t tokenize( const std::string& value            ,
00255                    Tokens&            tokens           ,
00256                    const std::string& separators = " " )
00257   {
00258     // reset the existing tokens
00259     tokens.clear();
00260     if( value       .empty () ) { return tokens.size () ; }
00261     std::string::const_iterator it1 = value.begin() ;
00262     std::string::const_iterator it2 = value.begin() ;
00263     while( value.end() != it1 && value.end() != it2 )
00264     {
00265       it2 = std::find_first_of( it1                  ,
00266                                 value.end         () ,
00267                                 separators.begin  () ,
00268                                 separators.end    () ) ;
00269       if( it2 != it1 )
00270       {
00271         std::string aux( value , it1 - value.begin() , it2 - it1 ) ;
00272         tokens.push_back( aux ) ;
00273         it1  = it2 ;
00274       }
00275       else { ++it1 ; }
00276 
00277     }
00278     return tokens.size();
00279   }
00280 }
00281 // ============================================================================
00282 StatusCode Tuples::TupleObj::fill( const char*  format ... )
00283 {
00284   // check the underlying tuple
00285   if ( invalid()      ) { return InvalidTuple ; }
00286   // decode format string into tokens
00287   Tokens tokens ;
00288   tokenize( format , tokens , " ,;" );
00289   if ( tokens.empty() ) { return StatusCode::SUCCESS ; }
00291   va_list valist ;
00292   va_start( valist , format ) ;
00293   // loop over all tokens
00294   StatusCode status = StatusCode::SUCCESS ;
00295   for( Tokens::const_iterator token = tokens.begin() ;
00296        tokens.end() != token && status.isSuccess() ; ++token )
00297   {
00298     const double val = va_arg( valist , double );
00299     status = column( *token , val );
00300     if( status.isFailure() )
00301     { Error ( "fill(): Can not add column '" + *token + "' " ) ; }
00302   }
00303   // mandatory !!!
00304   va_end( valist );
00305   //
00306   return status ;
00307 }
00308 
00309 // ============================================================================
00310 // put IOpaqueAddress in NTuple (has sense only for Event tag collection Ntuples)
00311 // ============================================================================
00312 StatusCode Tuples::TupleObj::column
00313 ( const std::string&    name    ,
00314   IOpaqueAddress*       address )
00315 {
00316   if (  invalid    () ) { return InvalidTuple     ; }
00317   if ( !evtColType () ) { return InvalidOperation ; }
00318   if ( 0 == address )
00319   { return Error ( "column('" + name +
00320                    "') IOpaqueAddress* is NULL!" , InvalidObject ) ; }
00321   Address* item = addresses( name );
00322   if ( 0 == item      ) { return InvalidItem      ; }
00323   *item = address ;
00324   return StatusCode::SUCCESS ;
00325 }
00326 
00327 // ============================================================================
00328 // put IOpaqueAddress in NTuple (has sense only for Event tag collection Ntuples)
00329 // ============================================================================
00330 StatusCode Tuples::TupleObj::column
00331 ( IOpaqueAddress*       address )
00332 {
00333   return column ( "Address" , address ) ;
00334 }
00335 
00336 // ============================================================================
00337 StatusCode Tuples::TupleObj::column ( const std::string& name   ,
00338                                       const float        value  )
00339 {
00340   if ( invalid() ) { return InvalidTuple  ; }
00341   Float* item = floats ( name ) ;
00342   if ( !item )     { return InvalidColumn ; }
00343   *item = value ;
00344   return StatusCode::SUCCESS ;
00345 }
00346 // ============================================================================
00347 StatusCode Tuples::TupleObj::column ( const std::string& name   ,
00348                                       const double       value  )
00349 {
00350   if ( invalid() ) { return InvalidTuple  ; }
00351   Double * item = doubles ( name ) ;
00352   if ( !item )     { return InvalidColumn ; }
00353   *item = value ;
00354   return StatusCode::SUCCESS ;
00355 }
00356 // ============================================================================
00357 StatusCode Tuples::TupleObj::column ( const std::string&  name  ,
00358                                       const char          value )
00359 {
00360   if ( invalid() ) { return InvalidTuple  ; }
00361   Char* item = chars( name ) ;
00362   if ( !item )     { return InvalidColumn ; }
00363   *item = value ;
00364   return StatusCode::SUCCESS ;
00365 }
00366 // ============================================================================
00367 StatusCode Tuples::TupleObj::column ( const std::string& name  ,
00368                                       const char         value ,
00369                                       const char         minv  ,
00370                                       const char         maxv  )
00371 {
00372   if ( invalid() ) { return InvalidTuple  ; }
00373   Char* item = chars ( name , minv , maxv ) ;
00374   if ( !item )     { return InvalidColumn ; }
00375   *item = value ;
00376   return StatusCode::SUCCESS ;
00377 }
00378 // ============================================================================
00379 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00380                                       const unsigned char value )
00381 {
00382   if ( invalid() ) { return InvalidTuple  ; }
00383   UChar* item = uchars( name ) ;
00384   if ( !item )     { return InvalidColumn ; }
00385   *item = value ;
00386   return StatusCode::SUCCESS ;
00387 }
00388 // ============================================================================
00389 StatusCode Tuples::TupleObj::column ( const std::string&   name ,
00390                                       const unsigned char value ,
00391                                       const unsigned char minv  ,
00392                                       const unsigned char maxv  )
00393 {
00394   if ( invalid() ) { return InvalidTuple  ; }
00395   UChar* item = uchars ( name , minv , maxv ) ;
00396   if ( !item )     { return InvalidColumn ; }
00397   *item = value ;
00398   return StatusCode::SUCCESS ;
00399 }
00400 // ============================================================================
00401 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00402                                       const short          value )
00403 {
00404   if ( invalid() ) { return InvalidTuple  ; }
00405   Short* item = shorts( name ) ;
00406   if ( !item )     { return InvalidColumn ; }
00407   *item = value ;
00408   return StatusCode::SUCCESS ;
00409 }
00410 // ============================================================================
00411 StatusCode Tuples::TupleObj::column ( const std::string&  name  ,
00412                                       const short         value ,
00413                                       const short         minv  ,
00414                                       const short         maxv  )
00415 {
00416   if ( invalid() ) { return InvalidTuple  ; }
00417   Short* item = shorts ( name , minv , maxv ) ;
00418   if ( !item )     { return InvalidColumn ; }
00419   *item = value ;
00420   return StatusCode::SUCCESS ;
00421 }
00422 // ============================================================================
00423 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00424                                       const unsigned short value )
00425 {
00426   if ( invalid() ) { return InvalidTuple  ; }
00427   UShort* item = ushorts( name ) ;
00428   if ( !item )     { return InvalidColumn ; }
00429   *item = value ;
00430   return StatusCode::SUCCESS ;
00431 }
00432 // ============================================================================
00433 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00434                                       const unsigned short value ,
00435                                       const unsigned short minv  ,
00436                                       const unsigned short maxv  )
00437 {
00438   if ( invalid() ) { return InvalidTuple  ; }
00439   UShort* item = ushorts ( name , minv , maxv ) ;
00440   if ( !item )     { return InvalidColumn ; }
00441   *item = value ;
00442   return StatusCode::SUCCESS ;
00443 }
00444 // ============================================================================
00445 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00446                                       const int            value )
00447 {
00448   if ( invalid() ) { return InvalidTuple  ; }
00449   Int* item = ints( name ) ;
00450   if ( !item ) { return InvalidColumn ; }
00451   *item = value ;
00452   return StatusCode::SUCCESS ;
00453 }
00454 // ============================================================================
00455 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00456                                       const int            value ,
00457                                       const int            minv  ,
00458                                       const int            maxv  )
00459 {
00460   if ( invalid() ) { return InvalidTuple  ; }
00461   Int* item = ints ( name , minv , maxv ) ;
00462   if ( !item )     { return InvalidColumn ; }
00463   *item = value ;
00464   return StatusCode::SUCCESS ;
00465 }
00466 // ============================================================================
00467 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00468                                       const unsigned int   value )
00469 {
00470   if ( invalid() ) { return InvalidTuple  ; }
00471   UInt* item = uints( name ) ;
00472   if ( !item )     { return InvalidColumn ; }
00473   *item = value ;
00474   return StatusCode::SUCCESS ;
00475 }
00476 // ============================================================================
00477 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00478                                       const unsigned int   value ,
00479                                       const unsigned int   minv  ,
00480                                       const unsigned int   maxv  )
00481 {
00482   if ( invalid() ) { return InvalidTuple  ; }
00483   UInt* item = uints ( name , minv , maxv ) ;
00484   if ( !item )     { return InvalidColumn ; }
00485   *item = value ;
00486   return StatusCode::SUCCESS ;
00487 }
00488 // ============================================================================
00489 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00490                                       const long           value )
00491 {
00492   Warning( "'long' has different sizes on 32/64 bit systems. Casting '" +
00493            name + "' to 'long long'", StatusCode::SUCCESS ).ignore();
00494   return column( name, (long long)value );
00495 }
00496 // ============================================================================
00497 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00498                                       const long           value ,
00499                                       const long           minv  ,
00500                                       const long           maxv  )
00501 {
00502   Warning( "'long' has different sizes on 32/64 bit systems. Casting '" +
00503            name + "' to 'long long'", StatusCode::SUCCESS ).ignore();
00504   return column( name, 
00505                  (long long)value, 
00506                  (long long)minv, 
00507                  (long long)maxv );
00508 }
00509 // ============================================================================
00510 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00511                                       const unsigned long  value )
00512 {
00513   Warning( "'unsigned long' has different sizes on 32/64 bit systems. Casting '" +
00514            name  + "' to 'unsigned long long'", StatusCode::SUCCESS ).ignore();
00515   return column( name, (unsigned long long)value );
00516 }
00517 // ============================================================================
00518 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00519                                       const unsigned long  value ,
00520                                       const unsigned long  minv  ,
00521                                       const unsigned long  maxv  )
00522 {
00523   Warning( "'unsigned long' has different sizes on 32/64 bit systems. Casting '" +
00524            name + "' to 'unsigned long long'", StatusCode::SUCCESS ).ignore();
00525   return column( name, 
00526                  (unsigned long long)value, 
00527                  (unsigned long long)minv, 
00528                  (unsigned long long)maxv );
00529 }
00530 // ============================================================================
00531 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00532                                       const long long      value )
00533 {
00534   if ( invalid() ) { return InvalidTuple  ; }
00535   LongLong* item = longlongs( name ) ;
00536   if ( !item )     { return InvalidColumn ; }
00537   *item = value ;
00538   return StatusCode::SUCCESS ;
00539 }
00540 // ============================================================================
00541 StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
00542                                       const long long      value ,
00543                                       const long long      minv  ,
00544                                       const long long      maxv  )
00545 {
00546   if ( invalid() ) { return InvalidTuple  ; }
00547   LongLong* item = longlongs ( name , minv , maxv ) ;
00548   if ( !item )     { return InvalidColumn ; }
00549   *item = value ;
00550   return StatusCode::SUCCESS ;
00551 }
00552 // ============================================================================
00553 StatusCode Tuples::TupleObj::column ( const std::string&       name  ,
00554                                       const unsigned long long value )
00555 {
00556   if ( invalid() ) { return InvalidTuple  ; }
00557   ULongLong* item = ulonglongs( name ) ;
00558   if ( !item )     { return InvalidColumn ; }
00559   *item = value ;
00560   return StatusCode::SUCCESS ;
00561 }
00562 // ============================================================================
00563 StatusCode Tuples::TupleObj::column ( const std::string&       name  ,
00564                                       const unsigned long long value ,
00565                                       const unsigned long long minv  ,
00566                                       const unsigned long long maxv  )
00567 {
00568   if ( invalid() ) { return InvalidTuple  ; }
00569   ULongLong* item = ulonglongs ( name , minv , maxv ) ;
00570   if ( !item )     { return InvalidColumn ; }
00571   *item = value ;
00572   return StatusCode::SUCCESS ;
00573 }
00574 // ============================================================================
00575 StatusCode Tuples::TupleObj::column ( const std::string& name  ,
00576                                       const bool         value )
00577 {
00578   if ( invalid() ) { return InvalidTuple  ; }
00579   Bool* item = bools( name ) ;
00580   if ( !item )     { return InvalidColumn ; }
00581   *item = value ;
00582   return StatusCode::SUCCESS ;
00583 }
00584 // ============================================================================
00585 Tuples::TupleObj::Float* Tuples::TupleObj::floats
00586 ( const std::string& name )
00587 {
00588   Floats::iterator found = m_floats.find( name ) ;
00589   if ( m_floats.end() != found ) { return found->second ; }
00590   Float* item = new Float() ;
00591   m_floats[ name ] = item ;
00592   const StatusCode sc = tuple()->addItem( name , *item );
00593   if ( sc.isFailure() )
00594   { Error ( "floats ('" + name + "'): item is not added",  sc ) ; }
00595   if ( !addItem ( name , "F" ) )
00596   { Error ( "floats ('" + name + "'): item is not unique"     ) ; }
00597   return item ;
00598 }
00599 // ============================================================================
00600 Tuples::TupleObj::Double*   Tuples::TupleObj::doubles
00601 ( const std::string& name )
00602 {
00603   Doubles::iterator found = m_doubles.find( name ) ;
00604   if ( m_doubles.end() != found ) { return found->second ; }
00605   Double* item = new Double() ;
00606   m_doubles[ name ] = item ;
00607   const StatusCode sc = tuple()->addItem( name , *item );
00608   if ( sc.isFailure() )
00609   { Error ( "doubles ('" + name + "'): item is not added",  sc ) ; }
00610   if ( !addItem ( name , "D" ) )
00611   { Error ( "doubles ('" + name + "'): item is not unique"     ) ; }
00612   return item ;
00613 }
00614 // ============================================================================
00615 Tuples::TupleObj::Bool*   Tuples::TupleObj::bools
00616 ( const std::string& name )
00617 {
00618   Bools::iterator found = m_bools.find( name ) ;
00619   if( m_bools.end() != found ) { return found->second ; }
00620   Bool* item = new Bool() ;
00621   m_bools[ name ] = item ;
00622   StatusCode sc = tuple()->addItem( name , *item );
00623   if( sc.isFailure() )
00624   { Error ( "bools ('" + name + "'): item is not added",  sc ) ; }
00625   if ( !addItem ( name , "I" ) )
00626   { Error ( "bools ('" + name + "'): item is not unique"     ) ; }
00627   return item ;
00628 }
00629 // ============================================================================
00630 Tuples::TupleObj::Char*   Tuples::TupleObj::chars
00631 ( const std::string& name )
00632 {
00633   Chars::iterator found = m_chars.find( name ) ;
00634   if( m_chars.end() != found ) { return found->second ; }
00635   Char* item = new Char() ;
00636   m_chars[ name ] = item ;
00637   StatusCode sc = tuple()->addItem( name , *item );
00638   if( sc.isFailure() )
00639   { Error ( "chars ('" + name + "'): item is not added",  sc ) ; }
00640   if ( !addItem ( name , "I" ) )
00641   { Error ( "chars ('" + name + "'): item is not unique"     ) ; }
00642   return item ;
00643 }
00644 // ============================================================================
00645 Tuples::TupleObj::Char* Tuples::TupleObj::chars
00646 ( const std::string& name ,
00647   const char         minv ,
00648   const char         maxv )
00649 {
00650   Chars::iterator found = m_chars.find( name ) ;
00651   if( m_chars.end() != found ) { return found->second ; }
00652   Char* item = new Char() ;
00653   m_chars[ name ] = item ;
00654   const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
00655   if( sc.isFailure() )
00656   { Error ( "chars ('" + name + "'): item is not added",  sc ) ; }
00657   if ( !addItem ( name , "I" ) )
00658   { Error ( "chars ('" + name + "'): item is not unique"     ) ; }
00659   return item ;
00660 }
00661 // ============================================================================
00662 Tuples::TupleObj::UChar* Tuples::TupleObj::uchars
00663 ( const std::string& name )
00664 {
00665   UChars::iterator found = m_uchars.find( name ) ;
00666   if( m_uchars.end() != found ) { return found->second ; }
00667   UChar* item = new UChar() ;
00668   m_uchars[ name ] = item ;
00669   StatusCode sc = tuple()->addItem( name , *item );
00670   if( sc.isFailure() )
00671   { Error ( "uchars ('" + name + "'): item is not added",  sc ) ; }
00672   if ( !addItem ( name , "I" ) )
00673   { Error ( "uchars ('" + name + "'): item is not unique"     ) ; }
00674   return item ;
00675 }
00676 // ============================================================================
00677 Tuples::TupleObj::UChar* Tuples::TupleObj::uchars
00678 ( const std::string&  name ,
00679   const unsigned char minv ,
00680   const unsigned char maxv )
00681 {
00682   UChars::iterator found = m_uchars.find( name ) ;
00683   if( m_uchars.end() != found ) { return found->second ; }
00684   UChar* item = new UChar() ;
00685   m_uchars[ name ] = item ;
00686   const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
00687   if( sc.isFailure() )
00688   { Error ( "uchars ('" + name + "'): item is not added",  sc ) ; }
00689   if ( !addItem ( name , "I" ) )
00690   { Error ( "uchars ('" + name + "'): item is not unique"     ) ; }
00691   return item ;
00692 }
00693 // ============================================================================
00694 Tuples::TupleObj::Short*   Tuples::TupleObj::shorts
00695 ( const std::string& name )
00696 {
00697   Shorts::iterator found = m_shorts.find( name ) ;
00698   if( m_shorts.end() != found ) { return found->second ; }
00699   Short* item = new Short() ;
00700   m_shorts[ name ] = item ;
00701   StatusCode sc = tuple()->addItem( name , *item );
00702   if( sc.isFailure() )
00703   { Error ( "shorts ('" + name + "'): item is not added",  sc ) ; }
00704   if ( !addItem ( name , "I" ) )
00705   { Error ( "shorts ('" + name + "'): item is not unique"     ) ; }
00706   return item ;
00707 }
00708 // ============================================================================
00709 Tuples::TupleObj::Short* Tuples::TupleObj::shorts
00710 ( const std::string& name ,
00711   const short        minv ,
00712   const short        maxv )
00713 {
00714   Shorts::iterator found = m_shorts.find( name ) ;
00715   if( m_shorts.end() != found ) { return found->second ; }
00716   Short* item = new Short() ;
00717   m_shorts[ name ] = item ;
00718   const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
00719   if( sc.isFailure() )
00720   { Error ( "shorts ('" + name + "'): item is not added",  sc ) ; }
00721   if ( !addItem ( name , "I" ) )
00722   { Error ( "shorts ('" + name + "'): item is not unique"     ) ; }
00723   return item ;
00724 }
00725 // ============================================================================
00726 Tuples::TupleObj::UShort* Tuples::TupleObj::ushorts
00727 ( const std::string& name )
00728 {
00729   UShorts::iterator found = m_ushorts.find( name ) ;
00730   if( m_ushorts.end() != found ) { return found->second ; }
00731   UShort* item = new UShort() ;
00732   m_ushorts[ name ] = item ;
00733   StatusCode sc = tuple()->addItem( name , *item );
00734   if( sc.isFailure() )
00735   { Error ( "ushorts ('" + name + "'): item is not added",  sc ) ; }
00736   if ( !addItem ( name , "I" ) )
00737   { Error ( "ushorts ('" + name + "'): item is not unique"     ) ; }
00738   return item ;
00739 }
00740 // ============================================================================
00741 Tuples::TupleObj::UShort* Tuples::TupleObj::ushorts
00742 ( const std::string&   name ,
00743   const unsigned short minv ,
00744   const unsigned short maxv )
00745 {
00746   UShorts::iterator found = m_ushorts.find( name ) ;
00747   if( m_ushorts.end() != found ) { return found->second ; }
00748   UShort* item = new UShort() ;
00749   m_ushorts[ name ] = item ;
00750   const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
00751   if( sc.isFailure() )
00752   { Error ( "ushorts ('" + name + "'): item is not added",  sc ) ; }
00753   if ( !addItem ( name , "I" ) )
00754   { Error ( "ushorts ('" + name + "'): item is not unique"     ) ; }
00755   return item ;
00756 }
00757 // ============================================================================
00758 Tuples::TupleObj::Int*   Tuples::TupleObj::ints
00759 ( const std::string& name )
00760 {
00761   Ints::iterator found = m_ints.find( name ) ;
00762   if( m_ints.end() != found ) { return found->second ; }
00763   Int* item = new Int() ;
00764   m_ints[ name ] = item ;
00765   StatusCode sc = tuple()->addItem( name , *item );
00766   if( sc.isFailure() )
00767   { Error ( "ints ('" + name + "'): item is not added",  sc ) ; }
00768   if ( !addItem ( name , "I" ) )
00769   { Error ( "ints ('" + name + "'): item is not unique"     ) ; }
00770   return item ;
00771 }
00772 // ============================================================================
00773 Tuples::TupleObj::Int* Tuples::TupleObj::ints
00774 ( const std::string& name ,
00775   const int          minv ,
00776   const int          maxv )
00777 {
00778   Ints::iterator found = m_ints.find( name ) ;
00779   if( m_ints.end() != found ) { return found->second ; }
00780   Int* item = new Int() ;
00781   m_ints[ name ] = item ;
00782   const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
00783   if( sc.isFailure() )
00784   { Error ( "ints ('" + name + "'): item is not added",  sc ) ; }
00785   if ( !addItem ( name , "I" ) )
00786   { Error ( "ints ('" + name + "'): item is not unique"     ) ; }
00787   return item ;
00788 }
00789 // ============================================================================
00790 Tuples::TupleObj::UInt*   Tuples::TupleObj::uints
00791 ( const std::string& name )
00792 {
00793   UInts::iterator found = m_uints.find( name ) ;
00794   if( m_uints.end() != found ) { return found->second ; }
00795   UInt* item = new UInt() ;
00796   m_uints[ name ] = item ;
00797   StatusCode sc = tuple()->addItem( name , *item );
00798   if( sc.isFailure() )
00799   { Error ( "uints ('" + name + "'): item is not added",  sc ) ; }
00800   if ( !addItem ( name , "I" ) )
00801   { Error ( "uints ('" + name + "'): item is not unique"     ) ; }
00802   return item ;
00803 }
00804 // ============================================================================
00805 Tuples::TupleObj::UInt* Tuples::TupleObj::uints
00806 ( const std::string& name ,
00807   const unsigned int minv ,
00808   const unsigned int maxv )
00809 {
00810   UInts::iterator found = m_uints.find( name ) ;
00811   if( m_uints.end() != found ) { return found->second ; }
00812   UInt* item = new UInt() ;
00813   m_uints[ name ] = item ;
00814   const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
00815   if( sc.isFailure() )
00816   { Error ( "uints ('" + name + "'): item is not added",  sc ) ; }
00817   if ( !addItem ( name , "I" ) )
00818   { Error ( "uints ('" + name + "'): item is not unique"     ) ; }
00819   return item ;
00820 }
00821 // ============================================================================
00822 Tuples::TupleObj::LongLong* Tuples::TupleObj::longlongs
00823 ( const std::string& name )
00824 {
00825   LongLongs::iterator found = m_longlongs.find( name ) ;
00826   if( m_longlongs.end() != found ) { return found->second ; }
00827   LongLong* item = new LongLong() ;
00828   m_longlongs[ name ] = item ;
00829   StatusCode sc = tuple()->addItem( name , *item );
00830   if( sc.isFailure() )
00831   { Error ( "ints ('" + name + "'): item is not added",  sc ) ; }
00832   if ( !addItem ( name , "ULL" ) )
00833   { Error ( "ints ('" + name + "'): item is not unique"     ) ; }
00834   return item ;
00835 }
00836 // ============================================================================
00837 Tuples::TupleObj::LongLong* Tuples::TupleObj::longlongs
00838 ( const std::string&       name ,
00839   const long long minv ,
00840   const long long maxv )
00841 {
00842   LongLongs::iterator found = m_longlongs.find( name ) ;
00843   if( m_longlongs.end() != found ) { return found->second ; }
00844   LongLong* item = new LongLong() ;
00845   m_longlongs[ name ] = item ;
00846   const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
00847   if( sc.isFailure() )
00848   { Error ( "longlongs ('" + name + "'): item is not added",  sc ) ; }
00849   if ( !addItem ( name , "ULL" ) )
00850   { Error ( "longlongs ('" + name + "'): item is not unique"     ) ; }
00851   return item ;
00852 }
00853 // ============================================================================
00854 Tuples::TupleObj::ULongLong* Tuples::TupleObj::ulonglongs
00855 ( const std::string& name )
00856 {
00857   ULongLongs::iterator found = m_ulonglongs.find( name ) ;
00858   if( m_ulonglongs.end() != found ) { return found->second ; }
00859   ULongLong* item = new ULongLong() ;
00860   m_ulonglongs[ name ] = item ;
00861   StatusCode sc = tuple()->addItem( name , *item );
00862   if( sc.isFailure() )
00863   { Error ( "ulonglongs ('" + name + "'): item is not added",  sc ) ; }
00864   if ( !addItem ( name , "ULL" ) )
00865   { Error ( "ulonglongs ('" + name + "'): item is not unique"     ) ; }
00866   return item ;
00867 }
00868 // ============================================================================
00869 Tuples::TupleObj::ULongLong* Tuples::TupleObj::ulonglongs
00870 ( const std::string&       name ,
00871   const unsigned long long minv ,
00872   const unsigned long long maxv )
00873 {
00874   ULongLongs::iterator found = m_ulonglongs.find( name ) ;
00875   if( m_ulonglongs.end() != found ) { return found->second ; }
00876   ULongLong* item = new ULongLong() ;
00877   m_ulonglongs[ name ] = item ;
00878   const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
00879   if( sc.isFailure() )
00880   { Error ( "ulonglongs ('" + name + "'): item is not added",  sc ) ; }
00881   if ( !addItem ( name , "ULL" ) )
00882   { Error ( "ulonglongs ('" + name + "'): item is not unique"     ) ; }
00883   return item ;
00884 }
00885 // ============================================================================
00886 Tuples::TupleObj::Address* Tuples::TupleObj::addresses
00887 ( const std::string& name )
00888 {
00889   Addresses::iterator found = m_addresses.find( name ) ;
00890   if( m_addresses.end() != found ) { return found->second ; }
00891   Address* item = new Address() ;
00892   m_addresses[ name ] = item ;
00893   const StatusCode sc = tuple()->addItem( name , *item );
00894   if( sc.isFailure() )
00895   { Error ( "addresses ('" + name + "'): item is not added",  sc ) ; }
00896   if ( !addItem ( name , "IOpaqueAddress*" ) )
00897   { Error ( "addresses ('" + name + "'): item is not unique"     ) ; }
00898   return item ;
00899 }
00900 // ============================================================================
00901 // retrieve (book on demand) array-items for ntuple
00902 // ============================================================================
00903 Tuples::TupleObj::FArray* Tuples::TupleObj::fArray
00904 ( const std::string&      name  ,
00905   Tuples::TupleObj::Int* length )
00906 {
00907   // existing array ?
00908   FArrays::iterator found = m_farrays.find( name ) ;
00909   if( m_farrays.end() != found ) { return found->second ; }
00910   // create new array
00911   FArray* array = new FArray () ;
00912   m_farrays[ name] =      array    ;
00913   const StatusCode sc = tuple() -> addIndexedItem( name , *length , *array) ;
00914   if( sc.isFailure() )
00915   { Error ( "farray ('" + name + "'): item is not added",  sc ) ; }
00916   if ( !addItem ( name , "FArray" ) )
00917   { Error ( "farray ('" + name + "'): item is not unique"     ) ; }
00918   return array ;
00919 }
00920 // ============================================================================
00921 // retrieve (book on demand) array-items for ntuple (fixed)
00922 // ============================================================================
00923 Tuples::TupleObj::FArray* Tuples::TupleObj::fArray
00924 ( const std::string&              name ,
00925   const Tuples::TupleObj::MIndex& rows )
00926 {
00927   // existing array ?
00928   FArrays::iterator found = m_arraysf.find( name ) ;
00929   if( m_arraysf.end() != found ) { return found->second ; }
00930   // create new array
00931   FArray* array = new FArray () ;
00932   m_arraysf[ name] =      array    ;
00933   const StatusCode sc = tuple() -> addItem ( name , rows , *array) ;
00934   if( sc.isFailure() )
00935   { Error ( "array ('" + name + "'): item is not added",  sc ) ; }
00936   if ( !addItem ( name , "FArray" ) )
00937   { Error ( "array ('" + name + "'): item is not unique"     ) ; }
00938   return array ;
00939 }
00940 // ============================================================================
00941 // retrieve (book on demand) matrix-items for ntuple
00942 // ============================================================================
00943 Tuples::TupleObj::FMatrix*
00944 Tuples::TupleObj::fMatrix
00945 ( const std::string&              name   ,
00946   Tuples::TupleObj::Int*          length ,
00947   const Tuples::TupleObj::MIndex& cols   )
00948 {
00949   // existing array ?
00950   FMatrices::iterator found = m_fmatrices.find( name ) ;
00951   if( m_fmatrices.end() != found ) { return found->second ; }
00952   // create new array
00953   FMatrix* matrix = new FMatrix () ;
00954   m_fmatrices[ name] =  matrix   ;
00955   const StatusCode sc =
00956     tuple() -> addIndexedItem( name , *length , cols , *matrix ) ;
00957   if( sc.isFailure() )
00958   { Error ( "fmatrix ('" + name + "'): item is not added",  sc ) ; }
00959   if ( !addItem ( name , "FMatrix" ) )
00960   { Error ( "fmatrix ('" + name + "'): item is not unique"     ) ; }
00961   return matrix ;
00962 }
00963 // ============================================================================
00964 // retrieve (book on demand) matrix-items for ntuple (fixed)
00965 // ============================================================================
00966 Tuples::TupleObj::FMatrix*
00967 Tuples::TupleObj::fMatrix
00968 ( const std::string&              name   ,
00969   const Tuples::TupleObj::MIndex& rows   ,
00970   const Tuples::TupleObj::MIndex& cols   )
00971 {
00972   // existing array ?
00973   FMatrices::iterator found = m_matricesf.find( name ) ;
00974   if( m_matricesf.end() != found ) { return found->second ; }
00975   // create new array
00976   FMatrix* matrix = new FMatrix () ;
00977   m_matricesf[ name] =  matrix   ;
00978   const StatusCode sc =
00979     tuple() -> addItem( name , rows , cols , *matrix ) ;
00980   if( sc.isFailure() )
00981   { Error ( "matrix ('" + name + "'): item is not added",  sc ) ; }
00982   if ( !addItem ( name , "FMatrix" ) )
00983   { Error ( "matrix ('" + name + "'): item is not unique"     ) ; }
00984   return matrix ;
00985 }
00986 // ============================================================================
00987 // The END
00988 // ============================================================================
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 12:29:52 for Gaudi Framework, version v23r3 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004