All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 "GaudiKernel/SmartIF.h"
31 #include "GaudiAlg/TupleObj.h"
32 
33 namespace Tuples
34 {
35 
36  template <class ITEM> class TupleItem ;
37 
117  {
118 
121  // Tuple() = delete;
122  Tuple();
123 
124  public :
129  Tuple ( TupleObj* ) ;
130 
132  Tuple ( const Tuple& ) = default;
133 
135  virtual ~Tuple() = default;
136 
141  Tuple& operator=( const Tuple& ) = default;
142 
146  TupleObj* operator-> () const { return tuple () ; }
147 
149  bool valid () const { return tuple () ; }
150 
151  protected:
152 
154  TupleObj* tuple() const { return m_tuple.get() ; }
155 
156  private:
157 
160 
161  };
162 
275  template<class ITEM>
277  {
278  public:
279  TupleColumn() = delete;
281  ITEM value )
282  : m_name ( std::move(name) ) , m_value ( std::move(value) ) {}
283 
285  const std::string& name () const { return m_name ; }
287  const ITEM& value () const { return m_value ; }
288  private:
290  ITEM m_value ;
291  };
292 
296  template<class ITEM>
297  inline TupleColumn<ITEM>
298  make_column ( std::string name , const ITEM& item )
299  { return TupleColumn<ITEM> ( std::move(name) , item ) ; }
300 
304  template<class ITEM>
306  make_column ( std::string name , const ITEM* item )
307  { return TupleColumn<const ITEM*>( std::move(name) , item ) ; }
308 
312  template<class ITEM>
313  inline TupleColumn<ITEM*>
314  make_column ( std::string name , ITEM* item )
315  { return TupleColumn<ITEM*> ( std::move(name) , item ) ; }
316 
317  template<class ITEM>
318  inline TupleColumn<ITEM>
319  Column ( std::string name , const ITEM& item )
320  { return make_column ( std::move(name) , item ) ; }
321 
322  template<class ITEM>
324  Column ( std::string name , const ITEM* item )
325  { return make_column ( std::move(name) , item ) ; }
326 
327  template<class ITEM>
328  inline TupleColumn<ITEM*>
329  Column ( std::string name , ITEM* item )
330  { return make_column ( std::move(name) , item ) ; }
331 
332 } // end of the namespace Tuples
333 
334 // ============================================================================
336 // ============================================================================
337 template <class ITEM>
338 inline Tuples::Tuple& operator<<
339  ( Tuples::Tuple& tuple ,
340  const Tuples::TupleColumn<ITEM>& item )
341 {
342  if ( !tuple.valid() ) { return tuple ; } // no action for invalid tuple
343  tuple->column( item.name() , item.value () ) ;
344  return tuple ;
345 }
346 // ============================================================================
347 
348 
349 
350 // ============================================================================
351 // THe END
352 // ============================================================================
353 #endif // GAUDIALG_TUPLE_H
354 // ============================================================================
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14
Header file for class TupleObj.
StatusCode column(const std::string &name, float value)
Set the value for selected tuple column.
Definition: TupleObj.cpp:285
STL namespace.
const ITEM & value() const
Return the column value.
Definition: Tuple.h:287
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: Tuple.h:116
const std::string & name() const
Return the column name.
Definition: Tuple.h:285
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:196
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:298
ITEM m_value
The column value.
Definition: Tuple.h:290
bool valid() const
check the validity of the tuple object
Definition: Tuple.h:149
T move(T...args)
Helper class which allows to extend the functionality of Tuple with possibility to use your own repre...
Definition: Tuple.h:276
SmartIF< TupleObj > m_tuple
The tuple object.
Definition: Tuple.h:159
TupleObj * tuple() const
Return the underlying tuple object.
Definition: Tuple.h:154
std::string m_name
The column name.
Definition: Tuple.h:289
#define GAUDI_API
Definition: Kernel.h:107
TupleColumn(std::string name, ITEM value)
Definition: Tuple.h:280
TupleColumn< ITEM > Column(std::string name, const ITEM &item)
Definition: Tuple.h:319
General namespace for Tuple properties.
Definition: Maps.h:34