BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/GeneratorObject/include/DataModel/DataLink.h
Go to the documentation of this file.
1#ifndef DATAMODEL_DATALINK_H
2#define DATAMODEL_DATALINK_H
3
4#ifndef DATAMODEL_TOOLS_DATAPROXYSTORAGE_H
5# include "DataModel/tools/DataProxyStorage.h"
6#endif
7
8#ifndef __EXCEPTION__
9# include <exception>
10#endif
11
12/** @class DataLink
13 * @brief a persistable pointer to a STORABLE (data object)
14 *
15 * @param STORABLE pointed-to data object type
16 * @param StoragePolicy STORABLE management policy (defaults to DataProxyStorage)
17 *
18 * @author ATLAS Collaboration
19 * $Id: DataLink.h,v 1.2 2003/04/16 01:32:52 calaf Exp $
20 **/
21
22class IProxyDict;
23
24template <typename STORABLE, class StoragePolicy = DataProxyStorage<STORABLE>>
25class DataLink : public StoragePolicy {
26public:
27 typedef typename StoragePolicy::ID_type ID_type;
28 // iterator-like tdefs
29 typedef typename StoragePolicy::value_type value_type;
30 typedef typename StoragePolicy::pointer pointer;
31 typedef typename StoragePolicy::const_pointer const_pointer;
32 typedef typename StoragePolicy::reference reference;
33 typedef typename StoragePolicy::const_reference const_reference;
34
35 // CONSTRUCTORS
36 /// links to the default object of type STORABLE
37 DataLink( IProxyDict* sg = StoragePolicy::defaultDataSource() ) : StoragePolicy( sg ) {}
38
39 /// link to a STORABLE using a transient ref to it
40 DataLink( const_reference data, IProxyDict* sg = StoragePolicy::defaultDataSource() )
41 : StoragePolicy( data, sg ) {}
42 /// link to a STORABLE using a transient ptr to it (must be non NULL)
43 ///@throws std::invalid_argument
44
45 DataLink( const_pointer pdata, IProxyDict* sg = StoragePolicy::defaultDataSource() )
46 : StoragePolicy( pdata, sg ) {}
47
48 /// link to a STORABLE using its ID
49 DataLink( const ID_type& dataID, IProxyDict* sg = StoragePolicy::defaultDataSource() )
50 : StoragePolicy( dataID, sg ) {}
51
52 // SETTERS, use to make a DataLink persistable
53
54 /// set link to data object pointed by data
55 void toStorableObject( const_reference data ) { StoragePolicy::setData( data ); }
56 /// set link to default data object (of type const_reference)
57 void toDefaultObject() { this->clear(); }
58 /// set link using data object key
59 void toIdentifiedObject( const ID_type& dataID ) { StoragePolicy::setData( dataID ); }
60
61 // ACCESSORS
62
63 const_reference operator*() const { return StoragePolicy::getDataRef(); }
64
65 const_pointer operator->() const { return StoragePolicy::getDataPtr(); }
66 operator const_pointer() const { return StoragePolicy::getDataPtr(); }
67 const_pointer cptr() const { return StoragePolicy::getDataPtr(); }
68
69 bool isValid() const;
70 bool operator!() const { return !isValid(); }
71
72 /// SG internal use only
73 //@{
74 using StoragePolicy::clear;
75 using StoragePolicy::reset;
76 //@}
77};
78
79/////////////////////////////////////////////////////////////////
80// inserters and extractors
81
82template <class OS, typename STORABLE, class StoragePolicy>
84
85template <class IS, typename STORABLE, class StoragePolicy>
87
88#include "DataModel/DataLink.icc"
89
90#ifndef DATAMODEL_TOOLS_PLAINPTRSTORAGE_H
91# include "DataModel/tools/PlainPtrStorage.h"
92#endif
93// helper struct to be used as type generator
94// e.g. PlainPtrDataLink<vector<int> >::type
95
96template <typename STORABLE> struct PlainPtrDataLink {
98};
99#endif /*DATALINK_H*/
TTree * data