| The Gaudi Framework v32r1 (f65d50dc)

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 template <class ITEM>
36 class TupleItem;
37
116 class GAUDI_API Tuple {
117 public:
122 Tuple( std::shared_ptr<TupleObj> tuple ) : m_tuple( std::move( tuple ) ) {}
123
124 virtual ~Tuple() = default;
125
129 TupleObj* operator->() const { return m_tuple.get(); }
130
132 bool valid() const { return static_cast<bool>( m_tuple ); }
133
134 protected:
135 TupleObj* tuple() { return m_tuple.get(); }
136
137 private:
139 std::shared_ptr<TupleObj> m_tuple;
140 };
141
254 template <class ITEM>
255 class TupleColumn {
256 public:
257 TupleColumn( std::string name, ITEM value ) : m_name( std::move( name ) ), m_value( std::move( value ) ) {}
258
260 const std::string& name() const { return m_name; }
262 const ITEM& value() const { return m_value; }
263
264 private:
265 std::string m_name;
266 ITEM m_value;
267 };
268
272 template <class ITEM>
273 inline TupleColumn<ITEM> make_column( std::string name, const ITEM& item ) {
274 return {std::move( name ), item};
275 }
276
280 template <class ITEM>
281 inline TupleColumn<const ITEM*> make_column( std::string name, const ITEM* item ) {
282 return {std::move( name ), item};
283 }
284
288 template <class ITEM>
289 inline TupleColumn<ITEM*> make_column( std::string name, ITEM* item ) {
290 return {std::move( name ), item};
291 }
292
293 template <class ITEM>
294 inline TupleColumn<ITEM> Column( std::string name, const ITEM& item ) {
295 return make_column( std::move( name ), item );
296 }
297
298 template <class ITEM>
299 inline TupleColumn<const ITEM*> Column( std::string name, const ITEM* item ) {
300 return make_column( std::move( name ), item );
301 }
302
303 template <class ITEM>
304 inline TupleColumn<ITEM*> Column( std::string name, ITEM* item ) {
305 return make_column( std::move( name ), item );
306 }
307
308 } // namespace Tuples
309
310 // ============================================================================
312 // ============================================================================
313 template <class ITEM>
314 inline Tuples::Tuple& operator<<( Tuples::Tuple& tuple, const Tuples::TupleColumn<ITEM>& item ) {
315 if ( !tuple.valid() ) return tuple; // no action for invalid tuple
316 tuple->column( item.name(), item.value() );
317 return tuple;
318 }
319 // ============================================================================
320
321 // ============================================================================
322 // THe END
323 // ============================================================================
324 #endif // GAUDIALG_TUPLE_H
std::shared_ptr
STL class.
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
TupleObj.h
Header file for class TupleObj.
Tuples::TupleObj::column
StatusCode column(const std::string &name, float value)
Set the value for selected tuple column.
Definition: TupleObj.cpp:292
Tuples::Tuple::tuple
TupleObj * tuple()
Definition: Tuple.h:135
std
STL namespace.
Tuples::Tuple::m_tuple
std::shared_ptr< TupleObj > m_tuple
The (shared) tuple object.
Definition: Tuple.h:139
std::string
STL class.
Tuples::Tuple
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: Tuple.h:116
Tuples::Tuple::Tuple
Tuple(std::shared_ptr< TupleObj > tuple)
standard constructor
Definition: Tuple.h:122
Tuples::TupleObj
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:199
Tuples::make_column
TupleColumn< ITEM > make_column(std::string name, const ITEM &item)
helper function to create 'on-the-fly' the helper object Tuples::TupleColumn
Definition: Tuple.h:273
Tuples::TupleColumn::m_value
ITEM m_value
The column value.
Definition: Tuple.h:266
SmartIF.h
Tuples::TupleColumn::name
const std::string & name() const
Return the column name.
Definition: Tuple.h:260
operator<<
Tuples::Tuple & operator<<(Tuples::Tuple &tuple, const Tuples::TupleColumn< ITEM > &item)
helper operator to feed Tuple with the data, see Tuples::TupleColumn
Definition: Tuple.h:314
std::move
T move(T... args)
Tuples::TupleColumn
Helper class which allows to extend the functionality of Tuple with possibility to use your own repre...
Definition: Tuple.h:255
Tuples::Tuple::valid
bool valid() const
check the validity of the tuple object
Definition: Tuple.h:132
Tuples::TupleItem
Definition: Tuple.h:36
Tuples::TupleColumn::m_name
std::string m_name
The column name.
Definition: Tuple.h:265
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
Tuples::TupleColumn::TupleColumn
TupleColumn(std::string name, ITEM value)
Definition: Tuple.h:257
Tuples::Column
TupleColumn< ITEM > Column(std::string name, const ITEM &item)
Definition: Tuple.h:294
Tuples::TupleColumn::value
const ITEM & value() const
Return the column value.
Definition: Tuple.h:262
Tuples::Tuple::operator->
TupleObj * operator->() const
get the pointer to the underlying object
Definition: Tuple.h:129
Tuples
General namespace for Tuple properties.
Definition: Maps.h:33