22 #include "boost/integer_traits.hpp"
23 #include "boost/static_assert.hpp"
52 long counts (
const std::string&
object ) {
return m_map[object] ; }
56 for ( Map::const_iterator entry =
m_map.begin() ;
57 m_map.end() != entry ; ++entry )
59 if( 0 == entry->second ) { continue ; }
60 std::cout <<
"Tuples::TupleObj WARNING " <<
m_message
61 <<
"'" << entry->first <<
"' Counts = " << entry->second
67 typedef std::map<std::string,long>
Map;
77 static Counter s_InstanceCounter (
" Create/Destroy (mis)balance " ) ;
84 (
const std::string& name ,
116 Tuples::Local::s_InstanceCounter.
increment ( m_name ) ;
126 {
if( 0 != it->second ) {
delete it->second ; } }
132 {
if( 0 != it->second ) {
delete it->second ; } }
138 {
if( 0 != it->second ) {
delete it->second ; } }
144 {
if( 0 != it->second ) {
delete it->second ; } }
150 {
if( 0 != it->second ) {
delete it->second ; } }
156 {
if( 0 != it->second ) {
delete it->second ; } }
162 {
if( 0 != it->second ) {
delete it->second ; } }
168 {
if( 0 != it->second ) {
delete it->second ; } }
174 {
if( 0 != it->second ) {
delete it->second ; } }
180 {
if( 0 != it->second ) {
delete it->second ; } }
186 {
if( 0 != it->second ) {
delete it->second ; } }
192 {
if( 0 != it->second ) {
delete it->second ; } }
198 {
if( 0 != it->second ) {
delete it->second ; } }
204 {
if( 0 != it->second ) {
delete it->second ; } }
210 {
if( 0 != it->second ) {
delete it->second ; } }
216 {
if( 0 != it->second ) {
delete it->second ; } }
231 if( 0 < refCount() ) { --m_refCount; }
233 if( 0 != refCount() ) {
return; }
243 return tuple()->
write() ;
249 typedef std::vector<std::string> Tokens;
254 size_t tokenize(
const std::string&
value ,
256 const std::string& separators =
" " )
260 if( value .empty () ) {
return tokens.size () ; }
261 std::string::const_iterator it1 = value.begin() ;
262 std::string::const_iterator it2 = value.begin() ;
263 while( value.end() != it1 && value.end() != it2 )
265 it2 = std::find_first_of( it1 ,
267 separators.begin () ,
268 separators.end () ) ;
271 std::string aux( value , it1 - value.begin() , it2 - it1 ) ;
272 tokens.push_back( aux ) ;
278 return tokens.size();
288 tokenize( format , tokens ,
" ,;" );
292 va_start( valist , format ) ;
295 for( Tokens::const_iterator token = tokens.begin() ;
296 tokens.end() != token && status.
isSuccess() ; ++token )
298 const double val = va_arg( valist ,
double );
299 status = column( *token , val );
301 { Error (
"fill(): Can not add column '" + *token +
"' " ) ; }
313 (
const std::string& name ,
319 {
return Error (
"column('" + name +
333 return column (
"Address" , address ) ;
373 Char*
item = chars ( name , minv , maxv ) ;
380 const unsigned char value )
390 const unsigned char value ,
391 const unsigned char minv ,
392 const unsigned char maxv )
395 UChar*
item = uchars ( name , minv , maxv ) ;
417 Short*
item = shorts ( name , minv , maxv ) ;
424 const unsigned short value )
434 const unsigned short value ,
435 const unsigned short minv ,
436 const unsigned short maxv )
439 UShort*
item = ushorts ( name , minv , maxv ) ;
461 Int*
item = ints ( name , minv , maxv ) ;
468 const unsigned int value )
478 const unsigned int value ,
479 const unsigned int minv ,
480 const unsigned int maxv )
483 UInt*
item = uints ( name , minv , maxv ) ;
492 Warning(
"'long' has different sizes on 32/64 bit systems. Casting '" +
494 return column( name, (
long long)value );
502 Warning(
"'long' has different sizes on 32/64 bit systems. Casting '" +
511 const unsigned long value )
513 Warning(
"'unsigned long' has different sizes on 32/64 bit systems. Casting '" +
515 return column( name, (
unsigned long long)value );
519 const unsigned long value ,
520 const unsigned long minv ,
521 const unsigned long maxv )
523 Warning(
"'unsigned long' has different sizes on 32/64 bit systems. Casting '" +
526 (
unsigned long long)value,
527 (
unsigned long long)minv,
528 (
unsigned long long)maxv );
532 const long long value )
542 const long long value ,
543 const long long minv ,
544 const long long maxv )
554 const unsigned long long value )
564 const unsigned long long value ,
565 const unsigned long long minv ,
566 const unsigned long long maxv )
586 (
const std::string& name )
589 if ( m_floats.end() != found ) {
return found->second ; }
591 m_floats[ name ] =
item ;
594 { Error (
"floats ('" + name +
"'): item is not added", sc ) ; }
595 if ( !addItem ( name ,
"F" ) )
596 { Error (
"floats ('" + name +
"'): item is not unique" ) ; }
601 (
const std::string& name )
604 if ( m_doubles.end() != found ) {
return found->second ; }
606 m_doubles[ name ] =
item ;
609 { Error (
"doubles ('" + name +
"'): item is not added", sc ) ; }
610 if ( !addItem ( name ,
"D" ) )
611 { Error (
"doubles ('" + name +
"'): item is not unique" ) ; }
616 (
const std::string& name )
619 if( m_bools.end() != found ) {
return found->second ; }
621 m_bools[ name ] =
item ;
624 { Error (
"bools ('" + name +
"'): item is not added", sc ) ; }
625 if ( !addItem ( name ,
"I" ) )
626 { Error (
"bools ('" + name +
"'): item is not unique" ) ; }
631 (
const std::string& name )
634 if( m_chars.end() != found ) {
return found->second ; }
636 m_chars[ name ] =
item ;
639 { Error (
"chars ('" + name +
"'): item is not added", sc ) ; }
640 if ( !addItem ( name ,
"I" ) )
641 { Error (
"chars ('" + name +
"'): item is not unique" ) ; }
646 (
const std::string& name ,
651 if( m_chars.end() != found ) {
return found->second ; }
653 m_chars[ name ] =
item ;
656 { Error (
"chars ('" + name +
"'): item is not added", sc ) ; }
657 if ( !addItem ( name ,
"I" ) )
658 { Error (
"chars ('" + name +
"'): item is not unique" ) ; }
663 (
const std::string& name )
666 if( m_uchars.end() != found ) {
return found->second ; }
668 m_uchars[ name ] =
item ;
671 { Error (
"uchars ('" + name +
"'): item is not added", sc ) ; }
672 if ( !addItem ( name ,
"I" ) )
673 { Error (
"uchars ('" + name +
"'): item is not unique" ) ; }
678 (
const std::string& name ,
679 const unsigned char minv ,
680 const unsigned char maxv )
683 if( m_uchars.end() != found ) {
return found->second ; }
685 m_uchars[ name ] =
item ;
688 { Error (
"uchars ('" + name +
"'): item is not added", sc ) ; }
689 if ( !addItem ( name ,
"I" ) )
690 { Error (
"uchars ('" + name +
"'): item is not unique" ) ; }
695 (
const std::string& name )
698 if( m_shorts.end() != found ) {
return found->second ; }
700 m_shorts[ name ] =
item ;
703 { Error (
"shorts ('" + name +
"'): item is not added", sc ) ; }
704 if ( !addItem ( name ,
"I" ) )
705 { Error (
"shorts ('" + name +
"'): item is not unique" ) ; }
710 (
const std::string& name ,
715 if( m_shorts.end() != found ) {
return found->second ; }
717 m_shorts[ name ] =
item ;
720 { Error (
"shorts ('" + name +
"'): item is not added", sc ) ; }
721 if ( !addItem ( name ,
"I" ) )
722 { Error (
"shorts ('" + name +
"'): item is not unique" ) ; }
727 (
const std::string& name )
730 if( m_ushorts.end() != found ) {
return found->second ; }
732 m_ushorts[ name ] =
item ;
735 { Error (
"ushorts ('" + name +
"'): item is not added", sc ) ; }
736 if ( !addItem ( name ,
"I" ) )
737 { Error (
"ushorts ('" + name +
"'): item is not unique" ) ; }
742 (
const std::string& name ,
743 const unsigned short minv ,
744 const unsigned short maxv )
747 if( m_ushorts.end() != found ) {
return found->second ; }
749 m_ushorts[ name ] =
item ;
752 { Error (
"ushorts ('" + name +
"'): item is not added", sc ) ; }
753 if ( !addItem ( name ,
"I" ) )
754 { Error (
"ushorts ('" + name +
"'): item is not unique" ) ; }
759 (
const std::string& name )
762 if( m_ints.end() != found ) {
return found->second ; }
764 m_ints[ name ] =
item ;
767 { Error (
"ints ('" + name +
"'): item is not added", sc ) ; }
768 if ( !addItem ( name ,
"I" ) )
769 { Error (
"ints ('" + name +
"'): item is not unique" ) ; }
774 (
const std::string& name ,
779 if( m_ints.end() != found ) {
return found->second ; }
781 m_ints[ name ] =
item ;
784 { Error (
"ints ('" + name +
"'): item is not added", sc ) ; }
785 if ( !addItem ( name ,
"I" ) )
786 { Error (
"ints ('" + name +
"'): item is not unique" ) ; }
791 (
const std::string& name )
794 if( m_uints.end() != found ) {
return found->second ; }
796 m_uints[ name ] =
item ;
799 { Error (
"uints ('" + name +
"'): item is not added", sc ) ; }
800 if ( !addItem ( name ,
"I" ) )
801 { Error (
"uints ('" + name +
"'): item is not unique" ) ; }
806 (
const std::string& name ,
807 const unsigned int minv ,
808 const unsigned int maxv )
811 if( m_uints.end() != found ) {
return found->second ; }
813 m_uints[ name ] =
item ;
816 { Error (
"uints ('" + name +
"'): item is not added", sc ) ; }
817 if ( !addItem ( name ,
"I" ) )
818 { Error (
"uints ('" + name +
"'): item is not unique" ) ; }
823 (
const std::string& name )
826 if( m_longlongs.end() != found ) {
return found->second ; }
828 m_longlongs[ name ] =
item ;
831 { Error (
"ints ('" + name +
"'): item is not added", sc ) ; }
832 if ( !addItem ( name ,
"ULL" ) )
833 { Error (
"ints ('" + name +
"'): item is not unique" ) ; }
838 (
const std::string& name ,
839 const long long minv ,
840 const long long maxv )
843 if( m_longlongs.end() != found ) {
return found->second ; }
845 m_longlongs[ name ] =
item ;
848 { Error (
"longlongs ('" + name +
"'): item is not added", sc ) ; }
849 if ( !addItem ( name ,
"ULL" ) )
850 { Error (
"longlongs ('" + name +
"'): item is not unique" ) ; }
855 (
const std::string& name )
858 if( m_ulonglongs.end() != found ) {
return found->second ; }
860 m_ulonglongs[ name ] =
item ;
863 { Error (
"ulonglongs ('" + name +
"'): item is not added", sc ) ; }
864 if ( !addItem ( name ,
"ULL" ) )
865 { Error (
"ulonglongs ('" + name +
"'): item is not unique" ) ; }
870 (
const std::string& name ,
871 const unsigned long long minv ,
872 const unsigned long long maxv )
875 if( m_ulonglongs.end() != found ) {
return found->second ; }
877 m_ulonglongs[ name ] =
item ;
880 { Error (
"ulonglongs ('" + name +
"'): item is not added", sc ) ; }
881 if ( !addItem ( name ,
"ULL" ) )
882 { Error (
"ulonglongs ('" + name +
"'): item is not unique" ) ; }
887 (
const std::string& name )
890 if( m_addresses.end() != found ) {
return found->second ; }
892 m_addresses[ name ] =
item ;
895 { Error (
"addresses ('" + name +
"'): item is not added", sc ) ; }
896 if ( !addItem ( name ,
"IOpaqueAddress*" ) )
897 { Error (
"addresses ('" + name +
"'): item is not unique" ) ; }
904 (
const std::string& name ,
909 if( m_farrays.end() != found ) {
return found->second ; }
912 m_farrays[ name] =
array ;
913 const StatusCode sc = tuple() -> addIndexedItem( name , *length , *array) ;
915 { Error (
"farray ('" + name +
"'): item is not added", sc ) ; }
916 if ( !addItem ( name ,
"FArray" ) )
917 { Error (
"farray ('" + name +
"'): item is not unique" ) ; }
924 (
const std::string& name ,
929 if( m_arraysf.end() != found ) {
return found->second ; }
932 m_arraysf[ name] =
array ;
933 const StatusCode sc = tuple() -> addItem ( name , rows , *array) ;
935 { Error (
"array ('" + name +
"'): item is not added", sc ) ; }
936 if ( !addItem ( name ,
"FArray" ) )
937 { Error (
"array ('" + name +
"'): item is not unique" ) ; }
945 (
const std::string& name ,
951 if( m_fmatrices.end() != found ) {
return found->second ; }
954 m_fmatrices[ name] = matrix ;
956 tuple() -> addIndexedItem( name , *length , cols , *matrix ) ;
958 { Error (
"fmatrix ('" + name +
"'): item is not added", sc ) ; }
959 if ( !addItem ( name ,
"FMatrix" ) )
960 { Error (
"fmatrix ('" + name +
"'): item is not unique" ) ; }
968 (
const std::string& name ,
974 if( m_matricesf.end() != found ) {
return found->second ; }
977 m_matricesf[ name] = matrix ;
979 tuple() -> addItem( name , rows , cols , *matrix ) ;
981 { Error (
"matrix ('" + name +
"'): item is not added", sc ) ; }
982 if ( !addItem ( name ,
"FMatrix" ) )
983 { Error (
"matrix ('" + name +
"'): item is not unique" ) ; }
virtual StatusCode write()=0
Write record of the NTuple (Shortcut of writeRecord)
Address * addresses(const std::string &name)
get the column
UShorts m_ushorts
the actual storage of all 'unsigned int' columns
FMatrices m_fmatrices
the actual storage of all 'FArray' columns
void release()
release the reference to TupleObj if reference counter becomes zero, object will be automatically del...
long decrement(const std::string &object)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Float * floats(const std::string &name)
get the column
Header file for class TupleObj.
Doubles m_doubles
the actual storage of all 'Double' columns
Class acting as a smart pointer holding a N tuple _Item.
StatusCode fill(const char *format...)
Set the values for several columns simultaneously.
bool isSuccess() const
Test for a status code of SUCCESS.
Bool * bools(const std::string &name)
get the column
FMatrices m_matricesf
the actual storage of all 'FMatrix' columns (fixed)
Floats m_floats
the actual storage of all 'Float' columns
UShort * ushorts(const std::string &name)
get the column
FArrays m_farrays
the actual storage of all 'FArray' columns
long counts(const std::string &object)
UChar * uchars(const std::string &name)
get the column
bool isFailure() const
Test for a status code of FAILURE.
UInt * uints(const std::string &name)
get the column
FArrays m_arraysf
the actual storage of all 'FArray' columns (fixed)
Bools m_bools
the actual storage of all 'bool' columns
Counter(const std::string &msg=" Misbalance ")
ULongLong * ulonglongs(const std::string &name)
get the column
Chars m_chars
the actual storage of all 'Int' columns
ULongLongs m_ulonglongs
the actual storage of all 'ulonglong' columns
This class is used for returning status codes from appropriate routines.
StatusCode column(const std::string &name, const float value)
Set the value for selected tuple column.
UInts m_uints
the actual storage of all 'unsigned int' columns
StatusCode write()
write a record to NTuple
Specialization acting as a smart pointer holding a N tuple _Item.
Ints m_ints
the actual storage of all 'Int' columns
unsigned int CLID
Class ID definition.
LongLongs m_longlongs
the actual storage of all 'longlong' columns
Abstract base class which allows the user to interact with the actual N tuple implementation.
virtual ~TupleObj()
destructor is protected
Addresses m_addresses
the actual storage of all 'Address' columns
FArray * fArray(const std::string &name, Int *item)
get the column
Short * shorts(const std::string &name)
get the column
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
map_type::iterator iterator
TupleObj()
the default constructor is disabled
Char * chars(const std::string &name)
get the column
StatusCode addItem(const std::string &name, Item< TYPE > &itm)
Add a scalar data item a N tuple.
FMatrix * fMatrix(const std::string &name, Int *item, const MIndex &cols)
get the column
Shorts m_shorts
the actual storage of all 'Int' columns
Double * doubles(const std::string &name)
get the column
Int * ints(const std::string &name)
get the column
Opaque address interface definition.
Class acting as a smart pointer holding a N tuple _Item.
Type
the list of available types for ntuples
long increment(const std::string &object)
UChars m_uchars
the actual storage of all 'unsigned int' columns
std::map< std::string, long > Map
LongLong * longlongs(const std::string &name)
get the column