#include <SmartRef.h>
Inheritance diagram for SmartRef< TYPE >:
Public Types | |
typedef TYPE | entry_type |
Entry type definition. | |
VALID = StreamBuffer::VALID | |
INVALID = StreamBuffer::INVALID | |
enum | { VALID = StreamBuffer::VALID, INVALID = StreamBuffer::INVALID } |
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. |
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 62 of file SmartRef.h.
typedef TYPE SmartRef< TYPE >::entry_type |
anonymous enum |
Definition at line 69 of file SmartRef.h.
00069 { VALID = StreamBuffer::VALID, INVALID = StreamBuffer::INVALID };
Standard Constructor.
Definition at line 79 of file SmartRef.h.
00079 { 00080 m_base.m_hintID = INVALID; 00081 m_base.m_linkID = INVALID; 00082 m_target = 0; 00083 _setEnvironment(0, 0); 00084 }
Standard Constructor with initialisation.
Definition at line 86 of file SmartRef.h.
00086 { 00087 m_base.m_hintID = INVALID; 00088 m_base.m_linkID = INVALID; 00089 m_target = pObject; 00090 _setEnvironment(0, 0); 00091 }
Standard Constructor with initialisation from const object.
Definition at line 93 of file SmartRef.h.
00093 { 00094 m_base.m_hintID = INVALID; 00095 m_base.m_linkID = INVALID; 00096 m_target = const_cast<TYPE*>(pObject); 00097 _setEnvironment(0, 0); 00098 }
Constructor.
Definition at line 107 of file SmartRef.h.
00107 { 00108 m_base.m_hintID = hint; 00109 m_base.m_linkID = link; 00110 m_target = obj; 00111 _setEnvironment(0, 0); 00112 }
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 114 of file SmartRef.h.
00114 { 00115 m_base.m_hintID = hint; 00116 m_base.m_linkID = link; 00117 m_target = obj; 00118 const DataObject* src = (0==pObj) ? 0 : pObj->parent(); 00119 _setEnvironment(src, pObj); 00120 }
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 122 of file SmartRef.h.
00122 { 00123 m_base.m_hintID = hint; 00124 m_base.m_linkID = link; 00125 m_target = obj; 00126 _setEnvironment(pObj, 0); 00127 }
SmartRef< TYPE >::SmartRef | ( | const DataObject * | pObj, | |
long | hint, | |||
TYPE * | obj = 0 | |||
) | [inline] |
Constructor for references to DataObjects passing environment.
Definition at line 129 of file SmartRef.h.
00129 { 00130 m_base.m_hintID = hint; 00131 m_base.m_linkID = INVALID; 00132 m_target = obj; 00133 _setEnvironment(pObj, 0); 00134 }
bool SmartRef< TYPE >::shouldFollowLink | ( | const DataObject * | ) | const [inline] |
bool SmartRef< TYPE >::shouldFollowLink | ( | const ContainedObject * | ) | const [inline] |
long SmartRef< TYPE >::hintID | ( | ) | const [inline] |
long SmartRef< TYPE >::linkID | ( | ) | const [inline] |
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 155 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 163 of file SmartRef.h.
00163 { 00164 return const_cast<TYPE*>(m_target); 00165 }
const TYPE* SmartRef< TYPE >::data | ( | ) | const [inline] |
const TYPE * SmartRef< TYPE >::target | ( | ) | const [inline] |
Access to the object.
Definition at line 286 of file SmartRef.h.
00286 { 00287 if ( 0 == m_target ) { 00288 m_target = dynamic_cast<const TYPE*>(m_base.accessData(m_target)); 00289 } 00290 return m_target; 00291 }
TYPE * SmartRef< TYPE >::target | ( | ) | [inline] |
Access to the object.
Definition at line 277 of file SmartRef.h.
00277 { 00278 if ( 0 == m_target ) { 00279 m_target = dynamic_cast<const TYPE*>(m_base.accessData(m_target)); 00280 } 00281 return const_cast<TYPE*>(m_target); 00282 }
const std::string& SmartRef< TYPE >::path | ( | ) | const [inline] |
Return the path of the linked object inside the data store.
Definition at line 174 of file SmartRef.h.
bool SmartRef< TYPE >::operator== | ( | const SmartRef< TYPE > & | c | ) | const [inline] |
Equality operator.
Definition at line 176 of file SmartRef.h.
00176 { 00177 if ( 0 != m_target && 0 != c.m_target ) { 00178 return m_target == c.m_target; 00179 } 00180 else if ( 0 == m_target && 0 == c.m_target ) { 00181 return m_base.isEqual(m_target,c.m_base); 00182 } 00183 else if ( 0 != m_target && 0 == c.m_target ) { 00184 return m_base.isEqualEx(m_target, c.m_base); 00185 } 00186 else if ( 0 == m_target && 0 != c.m_target ) { 00187 return c.m_base.isEqualEx(c.m_target, m_base); 00188 } 00189 return false; 00190 }
bool SmartRef< TYPE >::operator!= | ( | const SmartRef< TYPE > & | c | ) | const [inline] |
NON-Equality operator.
Definition at line 192 of file SmartRef.h.
00192 { 00193 return !(this->operator==(c)); 00194 }
const SmartRef<TYPE>& SmartRef< TYPE >::_setEnvironment | ( | const DataObject * | pObj, | |
const ContainedObject * | pContd | |||
) | const [inline] |
Set the environment (CONST).
Definition at line 196 of file SmartRef.h.
00196 { 00197 m_base.m_data = pObj; 00198 m_base.m_contd = pContd; 00199 m_base.setObjectType(data()); 00200 return *this; 00201 }
SmartRef<TYPE>& SmartRef< TYPE >::_setEnvironment | ( | const DataObject * | pObj, | |
const ContainedObject * | pContd | |||
) | [inline] |
Set the environment (CONST).
Definition at line 203 of file SmartRef.h.
00203 { 00204 m_base.m_data = pObj; 00205 m_base.m_contd = pContd; 00206 m_base.setObjectType(data()); 00207 return *this; 00208 }
SmartRef<TYPE>& SmartRef< TYPE >::operator() | ( | ContainedObject * | pObj | ) | [inline] |
operator(): assigns parent object for serialisation
Definition at line 210 of file SmartRef.h.
00210 { 00211 const DataObject* src = (0==pObj) ? 0 : pObj->parent(); 00212 return _setEnvironment(src, pObj); 00213 }
const SmartRef<TYPE>& SmartRef< TYPE >::operator() | ( | const ContainedObject * | pObj | ) | const [inline] |
operator() const: assigns parent object for serialisation
Definition at line 215 of file SmartRef.h.
00215 { 00216 const DataObject* src = (0==pObj) ? 0 : pObj->parent(); 00217 return _setEnvironment(src, pObj); 00218 }
SmartRef<TYPE>& SmartRef< TYPE >::operator() | ( | DataObject * | pObj | ) | [inline] |
operator(): assigns parent object for serialisation
Definition at line 220 of file SmartRef.h.
00220 { 00221 return _setEnvironment(pObj,0); 00222 }
const SmartRef<TYPE>& SmartRef< TYPE >::operator() | ( | const DataObject * | pObj | ) | const [inline] |
operator() const: assigns parent object for serialisation
Definition at line 224 of file SmartRef.h.
00224 { 00225 return _setEnvironment(pObj,0); 00226 }
TYPE& SmartRef< TYPE >::operator * | ( | ) | [inline] |
Dereference operator.
Definition at line 241 of file SmartRef.h.
00241 { return *SmartRef<TYPE>::target(); }
const TYPE& SmartRef< TYPE >::operator * | ( | ) | const [inline] |
Dereference operator.
Definition at line 243 of file SmartRef.h.
00243 { return *SmartRef<TYPE>::target(); }
TYPE* SmartRef< TYPE >::operator-> | ( | ) | [inline] |
Dereference operator.
Definition at line 245 of file SmartRef.h.
00245 { return SmartRef<TYPE>::target(); }
const TYPE* SmartRef< TYPE >::operator-> | ( | ) | const [inline] |
Dereference operator to const object.
Definition at line 247 of file SmartRef.h.
00247 { return SmartRef<TYPE>::target(); }
SmartRef< TYPE >::operator const TYPE * | ( | ) | const [inline] |
Implicit type conversion to const object.
Definition at line 249 of file SmartRef.h.
00249 { return SmartRef<TYPE>::target(); }
SmartRef< TYPE >::operator TYPE * | ( | ) | [inline] |
Implicit type conversion.
Definition at line 251 of file SmartRef.h.
00251 { 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 295 of file SmartRef.h.
00295 { 00296 m_base.writeObject(m_target, s); 00297 return s; 00298 }
StreamBuffer & SmartRef< TYPE >::readRef | ( | StreamBuffer & | s | ) | [inline] |
Read the reference from the stream buffer (needed due to stupid G++ compiler).
Definition at line 302 of file SmartRef.h.
00302 { 00303 m_target = dynamic_cast<TYPE*>( m_base.readObject(m_target, s) ); 00304 return s; 00305 }
friend class SmartRefArray< TYPE > [friend] |
friend class SmartRefList< TYPE > [friend] |
Definition at line 65 of file SmartRef.h.
friend class SmartRefMap< TYPE > [friend] |
Definition at line 66 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 73 of file SmartRef.h.