00001
00002
00003 #ifndef ATHLINKS_DATALINK_H
00004 #define ATHLINKS_DATALINK_H
00005
00006
00007 extern "C" {
00008 # include <stdint.h>
00009 }
00010 #include <string>
00011
00012
00013 #include "AthLinks/DataLinkBase.h"
00014 #include "AthLinks/tools/selection_ns.h"
00015
00016
00017 namespace xAOD {
00018 class TVirtualEvent;
00019 }
00020 ENTER_ROOT_SELECTION_NS
00021 template< class STORABLE >
00022 class DataLink;
00023 EXIT_ROOT_SELECTION_NS
00024
00036 template< typename STORABLE >
00037 class DataLink : public DataLinkBase {
00038
00039 public:
00042
00044 typedef std::string ID_type;
00046 typedef uint32_t sgkey_t;
00047
00049 typedef STORABLE value_type;
00051 typedef STORABLE* __attribute__((deprecated)) pointer;
00053 typedef const STORABLE* const_pointer;
00055 typedef STORABLE& __attribute__((deprecated)) reference;
00057 typedef const STORABLE& const_reference;
00058
00060
00063
00065 DataLink();
00066
00068 DataLink( xAOD::TVirtualEvent* event );
00069
00071 DataLink( const_reference data, xAOD::TVirtualEvent* event = 0 );
00072
00074 DataLink( const_pointer data, xAOD::TVirtualEvent* event = 0 );
00075
00077 DataLink( const ID_type& id, xAOD::TVirtualEvent* event = 0 );
00078
00080 DataLink( sgkey_t key, xAOD::TVirtualEvent* event = 0 );
00081
00083 template< typename T >
00084 DataLink( const DataLink< T >& parent );
00085
00087
00090
00092 void toStorableObject( const_reference data );
00093
00095 void toDefaultObject();
00096
00098 void toIdentifiedObject( const ID_type& id );
00100 void toIdentifiedObject( sgkey_t key );
00101
00103
00106
00108 const_reference operator*() const;
00110 const_pointer operator->() const { return cptr(); }
00111
00113 operator const_pointer() const { return cptr(); }
00114
00116 const_pointer cptr() const;
00117
00119 bool isValid() const;
00120
00122 operator bool() const { return isValid(); }
00124 bool operator!() const { return !isValid(); }
00125
00127 const ID_type& dataID() const;
00129 sgkey_t key() const { return persKey(); }
00130
00132
00134 xAOD::TVirtualEvent* source() const { return m_event; }
00135
00137 bool toPersistent();
00138
00139 private:
00141 virtual bool toTransient();
00143 void findIdentifier();
00144
00146 mutable const_pointer m_object;
00148 xAOD::TVirtualEvent* m_event;
00149
00151 typedef typename ROOT_SELECTION_NS::DataLink< STORABLE >::self DictSel;
00152
00153 };
00154
00155
00156
00157
00158
00159 ENTER_ROOT_SELECTION_NS
00160 template< class STORABLE >
00161 class DataLink
00162 #if ROOT_VERSION_CODE >= ROOT_VERSION( 6, 0, 2 )
00163 : public SelectNoInstance
00164 #endif
00165 {
00166
00167 public:
00169 typedef DataLink< STORABLE > self;
00170
00171 #if ROOT_VERSION_CODE < ROOT_VERSION( 5, 99, 0 )
00172
00174 ROOT_SELECTION_NS::NO_SELF_AUTOSELECT dummy;
00175
00177 ROOT_SELECTION_NS::TRANSIENT m_object;
00179 ROOT_SELECTION_NS::TRANSIENT m_event;
00180
00181 #else
00182
00184 ROOT_SELECTION_NS::MemberAttributes< kTransient > m_object;
00186 ROOT_SELECTION_NS::MemberAttributes< kTransient > m_event;
00187
00188 #endif // ROOT_VERSION
00189
00190 };
00191 EXIT_ROOT_SELECTION_NS
00192
00194 template< typename STORABLE >
00195 bool operator==( const DataLink< STORABLE >& a,
00196 const DataLink< STORABLE >& b );
00197
00199 template< typename STORABLE >
00200 bool operator!=( const DataLink< STORABLE >& a,
00201 const DataLink< STORABLE >& b );
00202
00203
00204 #ifndef __GCCXML__
00205 # include "DataLink.icc"
00206 #endif // __GCCXML__
00207
00208 #endif // ATHLINKS_DATALINK_H