| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
117 class GAUDI_API Tuple
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:
158 SmartIF<TupleObj> m_tuple;
159 };
160
273 template <class ITEM>
274 class TupleColumn
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:
286 std::string m_name;
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>
303 inline TupleColumn<const ITEM*> make_column( std::string name, const ITEM* item )
304 {
305 return TupleColumn<const ITEM*>( std::move( name ), item );
306 }
307
311 template <class ITEM>
312 inline TupleColumn<ITEM*> make_column( std::string name, ITEM* 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>
330 inline TupleColumn<ITEM*> Column( std::string name, ITEM* 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 // ============================================================================
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:15
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
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:315
std
STL namespace.
Tuples::TupleColumn::value
const ITEM & value() const
Return the column value.
Definition: Tuple.h:283
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
std::string
STL class.
Tuples::Tuple
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: Tuple.h:117
Tuples::TupleColumn::name
const std::string & name() const
Return the column name.
Definition: Tuple.h:281
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 &#39;on-the-fly&#39; the helper object Tuples::TupleColumn
Definition: Tuple.h:294
Tuples::TupleColumn::m_value
ITEM m_value
The column value.
Definition: Tuple.h:287
Tuples::Tuple::valid
bool valid() const
check the validity of the tuple object
Definition: Tuple.h:150
SmartIF.h
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:274
Tuples::Tuple::m_tuple
SmartIF< TupleObj > m_tuple
The tuple object.
Definition: Tuple.h:158
Tuples::TupleItem
Definition: Tuple.h:37
Tuples::Tuple::tuple
TupleObj * tuple() const
Return the underlying tuple object.
Definition: Tuple.h:154
Tuples::TupleColumn::m_name
std::string m_name
The column name.
Definition: Tuple.h:286
Tuples::Tuple::operator->
TupleObj * operator->() const
get the pointer to the underlying object
Definition: Tuple.h:147
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
Tuples::TupleColumn::TupleColumn
TupleColumn(std::string name, ITEM value)
Definition: Tuple.h:278
Tuples::Column
TupleColumn< ITEM > Column(std::string name, const ITEM &item)
Definition: Tuple.h:318
GaudiPython.GaudiAlgs.Tuple
Tuple
Definition: GaudiAlgs.py:1130
Tuples
General namespace for Tuple properties.
Definition: Maps.h:34