Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SmartDataStorePtr.h
Go to the documentation of this file.
1 // ====================================================================
2 // SmartDataStorePtr.h
3 // --------------------------------------------------------------------
4 //
5 // Package : GaudiKernel ( The LHCb Offline System)
6 //
7 // Description: Implementation of a smart pointer class to access
8 // easily (and efficiently) data stores.
9 //
10 // Author : M.Frank
11 // ====================================================================
12 #ifndef GAUDIKERNEL_SMARTDATASTOREPTR_H
13 #define GAUDIKERNEL_SMARTDATASTOREPTR_H 1
14 
15 // Framework include files
17 
44 template <class TYPE, class LOADER> class SmartDataStorePtr : public SmartDataObjectPtr {
45 public:
55  : SmartDataObjectPtr(LOADER::access(),pService,pRegistry,path), m_pObject(0)
56  {
57  }
62  : SmartDataObjectPtr( copy ), m_pObject(0)
63  {
64  }
65 
67  virtual ~SmartDataStorePtr() {
68  }
69 
72  m_pObject = dynamic_cast<TYPE*>(pObj);
73  return *this;
74  }
75 
78  m_pObject = dynamic_cast<TYPE*>(const_cast<DataObject*>(pObj));
79  return *this;
80  }
81 
84  this->m_pObject = dynamic_cast<TYPE*>(const_cast<SmartDataObjectPtr*>(&copy));
85  return *this;
86  }
87 
89  TYPE* ptr() {
90  return accessTypeSafeData();
91  }
92 
94  TYPE* operator->() {
95  return accessTypeSafeData();
96  }
97 
99  TYPE& operator*() {
100  TYPE* result = accessTypeSafeData();
101  return *result;
102  }
103 
105  operator TYPE*() {
106  return accessTypeSafeData();
107  }
108 
110  operator TYPE&() {
111  TYPE* result = accessTypeSafeData();
112  return *result;
113  }
114 
116  operator int() {
117  return 0 != accessTypeSafeData();
118  }
119 
121  bool operator !() {
122  return 0 == accessTypeSafeData();
123  }
124 
127  if ( 0 == m_pObject ) {
128  m_pObject = dynamic_cast<TYPE*>(accessData());
129  }
130  return m_pObject;
131  }
132 
133 protected:
135  mutable TYPE* m_pObject;
136 
137 };
138 
149 template <class A, class LDA, class B, class LDB>
151  if ( 0 != object_1.accessTypeSafeData() ) { // Test existence of the first object
152  if ( 0 != object_2.accessTypeSafeData() ) { // Test existence of the second object
153  return true; // Fine: Both objects exist
154  }
155  }
156  return false; // Tough luck: One is missing.
157 }
158 
169 template <class B, class LDB>
171  if ( test ) { // Test existence of the first object
172  if ( 0 != object.accessTypeSafeData() ) { // Test existence of the second object
173  return true; // Fine: Both objects exist
174  }
175  }
176  return false; // Tough luck: One is missing.
177 }
178 
189 template <class B, class LDB>
191  if ( test ) { // Test existence of the first object
192  if ( 0 != object.accessTypeSafeData() ) { // Test existence of the second object
193  return true; // Fine: Both objects exist
194  }
195  }
196  return false; // Tough luck: One is missing.
197 }
198 
213 template <class A, class LDA, class B, class LDB>
215  if ( 0 != object_1.accessTypeSafeData() ) { // Test existence of the first object
216  return true;
217  }
218  if ( 0 != object_2.accessTypeSafeData() ) { // Test existence of the second object
219  return true;
220  }
221  return false; // Tough luck: Both are missing.
222 }
223 
224 
235 template <class B, class LDB>
237  if ( test ) { // Test existence of the first object
238  return true;
239  }
240  if ( 0 != object.accessTypeSafeData() ) { // Test existence of the second object
241  return true; // Fine: Both objects exist
242  }
243  return false; // Tough luck: One is missing.
244 }
245 
256 template <class B, class LDB>
258  if ( test ) { // Test existence of the first object
259  return true;
260  }
261  if ( 0 != object.accessTypeSafeData() ) { // Test existence of the second object
262  return true; // Fine: Both objects exist
263  }
264  return false; // Tough luck: One is missing.
265 }
266 #endif // GAUDIKERNEL_SMARTDATASTOREPTR_H

Generated at Mon Feb 17 2014 14:37:44 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004