![]() |
|
|
Generated: 18 Jul 2008 |
#include <SmartRef.h>
Collaboration diagram for SmartRef< TYPE >:

Description: The SmartRef class allows transparent handling of object links within the data store. Links are unloaded a priori and will only be loaded "on demand", i.e. when dereferenced.
SmartRefs should behave in the same way as normal pointers; The SmartRef object in fact is a smart pointer construct intercepting the dereference operators.
When loading, the executed code resides in the non templated base class. This ensures, that the templated code is minimized and code blow up is inhibited.
Using SmartRefs StreamBuffers are able to also save the references on data conversion requests.
Base Class: SmartRefBase
Dependencies:
History :
+---------+----------------------------------------------+--------+
| Date | Comment | Who |
+---------+----------------------------------------------+--------+
| 21/04/99| Initial version. | MF |
| 16/01/04| Move base class into aggregation. | MF |
+---------+----------------------------------------------+--------+
Author: M.Frank Version: 1.0
Definition at line 60 of file SmartRef.h.
Public Types | |
| enum | { VALID = StreamBuffer::VALID, INVALID = StreamBuffer::INVALID } |
| typedef TYPE | entry_type |
| Entry type definition. | |
Public Member Functions | |
| SmartRef () | |
| Standard Constructor. | |
| SmartRef (TYPE *pObject) | |
| Standard Constructor with initialisation. | |
| SmartRef (const TYPE *pObject) | |
| Standard Constructor with initialisation from const object. | |
| SmartRef (const SmartRef ©) | |
| Copy Constructor. | |
| SmartRef (long hint, long link, TYPE *obj=0) | |
| Constructor. | |
| SmartRef (const ContainedObject *pObj, long hint, long link, TYPE *obj=0) | |
| Constructor for references to contained objects passing environment. | |
| SmartRef (const DataObject *pObj, long hint, long link, TYPE *obj=0) | |
| Constructor for references to contained objects passing environment. | |
| SmartRef (const DataObject *pObj, long hint, TYPE *obj=0) | |
| Constructor for references to DataObjects passing environment. | |
| bool | shouldFollowLink (const DataObject *) const |
| Check if link should be followed: link must be valid and object not yet loaded. | |
| bool | shouldFollowLink (const ContainedObject *) const |
| Check if link should be followed: link must be valid and object not yet loaded. | |
| long | hintID () const |
| Access hint id:. | |
| long | linkID () const |
| Access link id:. | |
| void | set (DataObject *pObj, long hint_id, long link_id) |
| Setup smart reference when reading. Must be allowed from external sources. | |
| const std::type_info * | type () const |
| Access to embedded type. | |
| TYPE * | data () |
| Access to raw data pointer. | |
| const TYPE * | data () const |
| const TYPE * | target () const |
| Access to the object. | |
| TYPE * | target () |
| Access to the object. | |
| const std::string & | path () const |
| Return the path of the linked object inside the data store. | |
| bool | operator== (const SmartRef< TYPE > &c) const |
| Equality operator. | |
| bool | operator!= (const SmartRef< TYPE > &c) const |
| NON-Equality operator. | |
| const SmartRef< TYPE > & | _setEnvironment (const DataObject *pObj, const ContainedObject *pContd) const |
| Set the environment (CONST). | |
| SmartRef< TYPE > & | _setEnvironment (const DataObject *pObj, const ContainedObject *pContd) |
| Set the environment (CONST). | |
| SmartRef< TYPE > & | operator() (ContainedObject *pObj) |
| operator(): assigns parent object for serialisation | |
| const SmartRef< TYPE > & | operator() (const ContainedObject *pObj) const |
| operator() const: assigns parent object for serialisation | |
| SmartRef< TYPE > & | operator() (DataObject *pObj) |
| operator(): assigns parent object for serialisation | |
| const SmartRef< TYPE > & | operator() (const DataObject *pObj) const |
| operator() const: assigns parent object for serialisation | |
| SmartRef< TYPE > & | operator= (const SmartRef< TYPE > &c) |
| Assignment. | |
| SmartRef< TYPE > & | operator= (TYPE *pObject) |
| Assignment. | |
| TYPE & | operator * () |
| Dereference operator. | |
| const TYPE & | operator * () const |
| Dereference operator. | |
| TYPE * | operator-> () |
| Dereference operator. | |
| const TYPE * | operator-> () const |
| Dereference operator to const object. | |
| operator const TYPE * () const | |
| Implicit type conversion to const object. | |
| operator TYPE * () | |
| Implicit type conversion. | |
| StreamBuffer & | writeRef (StreamBuffer &s) const |
| Write the reference to the stream buffer (needed due to stupid G++ compiler). | |
| StreamBuffer & | readRef (StreamBuffer &s) |
| Read the reference from the stream buffer (needed due to stupid G++ compiler). | |
Protected Attributes | |
| SmartRefBase | m_base |
| const TYPE * | m_target |
| Pointer to target data object. | |
Friends | |
| class | SmartRefArray< TYPE > |
| The container must be a friend. | |
| class | SmartRefList< TYPE > |
| class | SmartRefMap< TYPE > |
| StreamBuffer & | operator<< (StreamBuffer &s, const SmartRef< TYPE > &ptr) |
| Output Streamer operator. | |
| StreamBuffer & | operator>> (StreamBuffer &s, SmartRef< TYPE > &ptr) |
| Input Streamer operator. | |
| typedef TYPE SmartRef< TYPE >::entry_type |
| anonymous enum |
Definition at line 67 of file SmartRef.h.
00067 { VALID = StreamBuffer::VALID, INVALID = StreamBuffer::INVALID };
Standard Constructor.
Definition at line 77 of file SmartRef.h.
00077 { 00078 m_base.m_hintID = INVALID; 00079 m_base.m_linkID = INVALID; 00080 m_target = 0; 00081 _setEnvironment(0, 0); 00082 }
Standard Constructor with initialisation.
Definition at line 84 of file SmartRef.h.
00084 { 00085 m_base.m_hintID = INVALID; 00086 m_base.m_linkID = INVALID; 00087 m_target = pObject; 00088 _setEnvironment(0, 0); 00089 }
Standard Constructor with initialisation from const object.
Definition at line 91 of file SmartRef.h.
00091 { 00092 m_base.m_hintID = INVALID; 00093 m_base.m_linkID = INVALID; 00094 m_target = const_cast<TYPE*>(pObject); 00095 _setEnvironment(0, 0); 00096 }
Constructor.
Definition at line 105 of file SmartRef.h.
00105 { 00106 m_base.m_hintID = hint; 00107 m_base.m_linkID = link; 00108 m_target = obj; 00109 _setEnvironment(0, 0); 00110 }
| SmartRef< TYPE >::SmartRef | ( | const ContainedObject * | pObj, | |
| long | hint, | |||
| long | link, | |||
| TYPE * | obj = 0 | |||
| ) | [inline] |
Constructor for references to contained objects passing environment.
Definition at line 112 of file SmartRef.h.
00112 { 00113 m_base.m_hintID = hint; 00114 m_base.m_linkID = link; 00115 m_target = obj; 00116 const DataObject* src = (0==pObj) ? 0 : pObj->parent(); 00117 _setEnvironment(src, pObj); 00118 }
| SmartRef< TYPE >::SmartRef | ( | const DataObject * | pObj, | |
| long | hint, | |||
| long | link, | |||
| TYPE * | obj = 0 | |||
| ) | [inline] |
Constructor for references to contained objects passing environment.
Definition at line 120 of file SmartRef.h.
00120 { 00121 m_base.m_hintID = hint; 00122 m_base.m_linkID = link; 00123 m_target = obj; 00124 _setEnvironment(pObj, 0); 00125 }
| SmartRef< TYPE >::SmartRef | ( | const DataObject * | pObj, | |
| long | hint, | |||
| TYPE * | obj = 0 | |||
| ) | [inline] |
Constructor for references to DataObjects passing environment.
Definition at line 127 of file SmartRef.h.
00127 { 00128 m_base.m_hintID = hint; 00129 m_base.m_linkID = INVALID; 00130 m_target = obj; 00131 _setEnvironment(pObj, 0); 00132 }
| bool SmartRef< TYPE >::shouldFollowLink | ( | const DataObject * | ) | const [inline] |
| bool SmartRef< TYPE >::shouldFollowLink | ( | const ContainedObject * | ) | const [inline] |
| long SmartRef< TYPE >::hintID | ( | ) | const [inline] |
Access hint id:.
Definition at line 145 of file SmartRef.h.
Referenced by RefTable1to1< FROM, TO >::insert(), and PoolDbIOHandler< T >::put().
| long SmartRef< TYPE >::linkID | ( | ) | const [inline] |
Access link id:.
Definition at line 149 of file SmartRef.h.
Referenced by PoolDbIOHandler< T >::put().
| void SmartRef< TYPE >::set | ( | DataObject * | pObj, | |
| long | hint_id, | |||
| long | link_id | |||
| ) | [inline] |
Setup smart reference when reading. Must be allowed from external sources.
Definition at line 153 of file SmartRef.h.
| const std::type_info* SmartRef< TYPE >::type | ( | ) | const [inline] |
| TYPE* SmartRef< TYPE >::data | ( | ) | [inline] |
Access to raw data pointer.
Definition at line 161 of file SmartRef.h.
Referenced by SmartRef< KeyType >::_setEnvironment(), RefTable1to1< FROM, TO >::insert(), and PoolDbIOHandler< T >::put().
00161 { 00162 return const_cast<TYPE*>(m_target); 00163 }
| const TYPE* SmartRef< TYPE >::data | ( | ) | const [inline] |
| const TYPE * SmartRef< TYPE >::target | ( | ) | const [inline] |
Access to the object.
Definition at line 284 of file SmartRef.h.
References SmartRefBase::accessData(), SmartRef< TYPE >::m_base, and SmartRef< TYPE >::m_target.
Referenced by RefTable1to1< FROM, TO >::isReferenced(), SmartRef< KeyType >::operator *(), SmartRef< TYPE >::operator const TYPE *(), SmartRef< TYPE >::operator TYPE *(), and SmartRef< KeyType >::operator->().
00284 { 00285 if ( 0 == m_target ) { 00286 m_target = dynamic_cast<const TYPE*>(m_base.accessData(m_target)); 00287 } 00288 return m_target; 00289 }
| TYPE * SmartRef< TYPE >::target | ( | ) | [inline] |
Access to the object.
Definition at line 275 of file SmartRef.h.
References SmartRefBase::accessData(), SmartRef< TYPE >::m_base, and SmartRef< TYPE >::m_target.
00275 { 00276 if ( 0 == m_target ) { 00277 m_target = dynamic_cast<const TYPE*>(m_base.accessData(m_target)); 00278 } 00279 return const_cast<TYPE*>(m_target); 00280 }
| const std::string& SmartRef< TYPE >::path | ( | ) | const [inline] |
Return the path of the linked object inside the data store.
Definition at line 172 of file SmartRef.h.
| bool SmartRef< TYPE >::operator== | ( | const SmartRef< TYPE > & | c | ) | const [inline] |
Equality operator.
Definition at line 174 of file SmartRef.h.
Referenced by SmartRef< KeyType >::operator!=().
00174 { 00175 if ( 0 != m_target && 0 != c.m_target ) { 00176 return m_target == c.m_target; 00177 } 00178 else if ( 0 == m_target && 0 == c.m_target ) { 00179 return m_base.isEqual(m_target,c.m_base); 00180 } 00181 else if ( 0 != m_target && 0 == c.m_target ) { 00182 return m_base.isEqualEx(m_target, c.m_base); 00183 } 00184 else if ( 0 == m_target && 0 != c.m_target ) { 00185 return c.m_base.isEqualEx(c.m_target, m_base); 00186 } 00187 return false; 00188 }
| bool SmartRef< TYPE >::operator!= | ( | const SmartRef< TYPE > & | c | ) | const [inline] |
NON-Equality operator.
Definition at line 190 of file SmartRef.h.
00190 { 00191 return !(this->operator==(c)); 00192 }
| const SmartRef<TYPE>& SmartRef< TYPE >::_setEnvironment | ( | const DataObject * | pObj, | |
| const ContainedObject * | pContd | |||
| ) | const [inline] |
Set the environment (CONST).
Definition at line 194 of file SmartRef.h.
Referenced by SmartRef< KeyType >::operator()(), SmartRef< KeyType >::operator=(), SmartRefVector< TYPE >::readRefs(), and SmartRef< KeyType >::SmartRef().
00194 { 00195 m_base.m_data = pObj; 00196 m_base.m_contd = pContd; 00197 m_base.setObjectType(data()); 00198 return *this; 00199 }
| SmartRef<TYPE>& SmartRef< TYPE >::_setEnvironment | ( | const DataObject * | pObj, | |
| const ContainedObject * | pContd | |||
| ) | [inline] |
Set the environment (CONST).
Definition at line 201 of file SmartRef.h.
00201 { 00202 m_base.m_data = pObj; 00203 m_base.m_contd = pContd; 00204 m_base.setObjectType(data()); 00205 return *this; 00206 }
| SmartRef<TYPE>& SmartRef< TYPE >::operator() | ( | ContainedObject * | pObj | ) | [inline] |
operator(): assigns parent object for serialisation
Definition at line 208 of file SmartRef.h.
00208 { 00209 const DataObject* src = (0==pObj) ? 0 : pObj->parent(); 00210 return _setEnvironment(src, pObj); 00211 }
| const SmartRef<TYPE>& SmartRef< TYPE >::operator() | ( | const ContainedObject * | pObj | ) | const [inline] |
operator() const: assigns parent object for serialisation
Definition at line 213 of file SmartRef.h.
00213 { 00214 const DataObject* src = (0==pObj) ? 0 : pObj->parent(); 00215 return _setEnvironment(src, pObj); 00216 }
| SmartRef<TYPE>& SmartRef< TYPE >::operator() | ( | DataObject * | pObj | ) | [inline] |
operator(): assigns parent object for serialisation
Definition at line 218 of file SmartRef.h.
00218 { 00219 return _setEnvironment(pObj,0); 00220 }
| const SmartRef<TYPE>& SmartRef< TYPE >::operator() | ( | const DataObject * | pObj | ) | const [inline] |
operator() const: assigns parent object for serialisation
Definition at line 222 of file SmartRef.h.
00222 { 00223 return _setEnvironment(pObj,0); 00224 }
| TYPE& SmartRef< TYPE >::operator * | ( | ) | [inline] |
Dereference operator.
Definition at line 239 of file SmartRef.h.
00239 { return *SmartRef<TYPE>::target(); }
| const TYPE& SmartRef< TYPE >::operator * | ( | ) | const [inline] |
Dereference operator.
Definition at line 241 of file SmartRef.h.
00241 { return *SmartRef<TYPE>::target(); }
| TYPE* SmartRef< TYPE >::operator-> | ( | ) | [inline] |
Dereference operator.
Definition at line 243 of file SmartRef.h.
00243 { return SmartRef<TYPE>::target(); }
| const TYPE* SmartRef< TYPE >::operator-> | ( | ) | const [inline] |
Dereference operator to const object.
Definition at line 245 of file SmartRef.h.
00245 { return SmartRef<TYPE>::target(); }
| SmartRef< TYPE >::operator const TYPE * | ( | ) | const [inline] |
Implicit type conversion to const object.
Definition at line 247 of file SmartRef.h.
References SmartRef< TYPE >::target().
00247 { return SmartRef<TYPE>::target(); }
| SmartRef< TYPE >::operator TYPE * | ( | ) | [inline] |
Implicit type conversion.
Definition at line 249 of file SmartRef.h.
References SmartRef< TYPE >::target().
00249 { return SmartRef<TYPE>::target(); }
| StreamBuffer & SmartRef< TYPE >::writeRef | ( | StreamBuffer & | s | ) | const [inline] |
Write the reference to the stream buffer (needed due to stupid G++ compiler).
Definition at line 293 of file SmartRef.h.
References SmartRef< TYPE >::m_base, SmartRef< TYPE >::m_target, Gaudi::Units::s, and SmartRefBase::writeObject().
00293 { 00294 m_base.writeObject(m_target, s); 00295 return s; 00296 }
| StreamBuffer & SmartRef< TYPE >::readRef | ( | StreamBuffer & | s | ) | [inline] |
Read the reference from the stream buffer (needed due to stupid G++ compiler).
Definition at line 300 of file SmartRef.h.
References SmartRef< TYPE >::m_base, SmartRef< TYPE >::m_target, SmartRefBase::readObject(), and Gaudi::Units::s.
00300 { 00301 m_target = dynamic_cast<TYPE*>( m_base.readObject(m_target, s) ); 00302 return s; 00303 }
friend class SmartRefArray< TYPE > [friend] |
friend class SmartRefList< TYPE > [friend] |
Definition at line 63 of file SmartRef.h.
friend class SmartRefMap< TYPE > [friend] |
Definition at line 64 of file SmartRef.h.
| StreamBuffer& operator<< | ( | StreamBuffer & | s, | |
| const SmartRef< TYPE > & | ptr | |||
| ) | [friend] |
| StreamBuffer& operator>> | ( | StreamBuffer & | s, | |
| SmartRef< TYPE > & | ptr | |||
| ) | [friend] |
SmartRefBase SmartRef< TYPE >::m_base [protected] |
Definition at line 71 of file SmartRef.h.
Referenced by SmartRef< KeyType >::_setEnvironment(), SmartRef< KeyType >::hintID(), SmartRef< KeyType >::linkID(), SmartRef< KeyType >::operator=(), SmartRef< KeyType >::operator==(), SmartRef< KeyType >::path(), SmartRef< TYPE >::readRef(), SmartRef< KeyType >::set(), SmartRef< KeyType >::shouldFollowLink(), SmartRef< KeyType >::SmartRef(), SmartRef< TYPE >::target(), and SmartRef< TYPE >::writeRef().
Pointer to target data object.
Definition at line 73 of file SmartRef.h.
Referenced by SmartRef< KeyType >::data(), SmartRef< KeyType >::operator=(), SmartRef< KeyType >::operator==(), SmartRef< TYPE >::readRef(), SmartRef< KeyType >::shouldFollowLink(), SmartRef< KeyType >::SmartRef(), SmartRef< TYPE >::target(), and SmartRef< TYPE >::writeRef().