The Gaudi Framework  v29r0 (ff2e7097)
Tuple.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_TUPLE_H
2 #define GAUDIALG_TUPLE_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <string>
9 
10 // ============================================================================
18 // ============================================================================
19 
20 // ============================================================================
28 // ============================================================================
29 
30 #include "GaudiAlg/TupleObj.h"
31 #include "GaudiKernel/SmartIF.h"
32 
33 namespace Tuples
34 {
35 
36  template <class ITEM>
37  class TupleItem;
38 
118  {
119 
122  // Tuple() = delete;
123  Tuple();
124 
125  public:
130  Tuple( TupleObj* );
131 
133  Tuple( const Tuple& ) = default;
134 
136  virtual ~Tuple() = default;
137 
142  Tuple& operator=( const Tuple& ) = default;
143 
147  TupleObj* operator->() const { return tuple(); }
148 
150  bool valid() const { return tuple(); }
151 
152  protected:
154  TupleObj* tuple() const { return m_tuple.get(); }
155 
156  private:
159  };
160 
273  template <class ITEM>
275  {
276  public:
277  TupleColumn() = delete;
278  TupleColumn( std::string name, ITEM value ) : m_name( std::move( name ) ), m_value( std::move( value ) ) {}
279 
281  const std::string& name() const { return m_name; }
283  const ITEM& value() const { return m_value; }
284 
285  private:
287  ITEM m_value;
288  };
289 
293  template <class ITEM>
294  inline TupleColumn<ITEM> make_column( std::string name, const ITEM& item )
295  {
296  return TupleColumn<ITEM>( std::move( name ), item );
297  }
298 
302  template <class ITEM>
304  {
305  return TupleColumn<const ITEM*>( std::move( name ), item );
306  }
307 
311  template <class ITEM>
313  {
314  return TupleColumn<ITEM*>( std::move( name ), item );
315  }
316 
317  template <class ITEM>
318  inline TupleColumn<ITEM> Column( std::string name, const ITEM& item )
319  {
320  return make_column( std::move( name ), item );
321  }
322 
323  template <class ITEM>
324  inline TupleColumn<const ITEM*> Column( std::string name, const ITEM* item )
325  {
326  return make_column( std::move( name ), item );
327  }
328 
329  template <class ITEM>
331  {
332  return make_column( std::move( name ), item );
333  }
334 
335 } // end of the namespace Tuples
336 
337 // ============================================================================
339 // ============================================================================
340 template <class ITEM>
341 inline Tuples::Tuple& operator<<( Tuples::Tuple& tuple, const Tuples::TupleColumn<ITEM>& item )
342 {
343  if ( !tuple.valid() ) {
344  return tuple;
345  } // no action for invalid tuple
346  tuple->column( item.name(), item.value() );
347  return tuple;
348 }
349 // ============================================================================
350 
351 // ============================================================================
352 // THe END
353 // ============================================================================
354 #endif // GAUDIALG_TUPLE_H
355 // ============================================================================
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:15
Header file for class TupleObj.
StatusCode column(const std::string &name, float value)
Set the value for selected tuple column.
Definition: TupleObj.cpp:315
STL namespace.
const ITEM & value() const
Return the column value.
Definition: Tuple.h:283
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: Tuple.h:117
const std::string & name() const
Return the column name.
Definition: Tuple.h:281
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:199
TupleColumn< ITEM > make_column(std::string name, const ITEM &item)
helper function to create &#39;on-the-fly&#39; the helper object Tuples::TupleColumn
Definition: Tuple.h:294
ITEM m_value
The column value.
Definition: Tuple.h:287
bool valid() const
check the validity of the tuple object
Definition: Tuple.h:150
T move(T...args)
Helper class which allows to extend the functionality of Tuple with possibility to use your own repre...
Definition: Tuple.h:274
SmartIF< TupleObj > m_tuple
The tuple object.
Definition: Tuple.h:158
TupleObj * tuple() const
Return the underlying tuple object.
Definition: Tuple.h:154
std::string m_name
The column name.
Definition: Tuple.h:286
TupleObj * operator->() const
get the pointer to the underlying object
Definition: Tuple.h:147
#define GAUDI_API
Definition: Kernel.h:110
TupleColumn(std::string name, ITEM value)
Definition: Tuple.h:278
TupleColumn< ITEM > Column(std::string name, const ITEM &item)
Definition: Tuple.h:318
General namespace for Tuple properties.
Definition: Maps.h:34