Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Link< T > Class Template Reference
[Data classes]

Class-specialized, auto-loading smart-pointer to Objects. More...

#include <Link.h>

Inheritance diagram for Link< T >:

LinkBase Path ReferencePointer BaseType List of all members.

Public Types

typedef std::vector< Link<
T > > 
vector
 Convenience typedef.


Public Methods

 Link ()
 Create a null Link.

 Link (const Path &path, T *ptr)
 Create a Link with both a path and an object.

 Link (const char *path)
 Create a Link with a path but no object (null).

 Link (T *t)
 Create a Link with an object reference, but no path.

 Link (const Link< T > &p)
 Fast copy constructor.

 Link (const LinkBase &p)
 Safe copy constructor.

virtual std::string typeString () const
 Return a string representation of the type.

T * operator= (T *t)
 Assign a pointer.

T * operator-> ()
 Dereference.

const T * operator-> () const
 Const dereference.

T & operator * ()
 Dereference.

const T & operator * () const
 Const dereference.

const T * get () const
 Const dereference.

T * get ()
 Dereference.

bool __eq__ (const LinkBase &other)
bool __eq__ (const ReferencePointer &other)
bool __ne__ (const LinkBase &other)
bool __ne__ (const ReferencePointer &other)
virtual void serialize (Archive &)
 Serialize to or from a data archive.

virtual std::string asString () const
 String representation.

bool operator== (LinkBase const &p) const
 Comparison with other simdata pointers.

bool operator== (Path const &p) const
 Test for equality of two paths.

bool operator== (ReferencePointer const &p) const
 Comparison with other simdata pointers.

void setPath (ObjectID path)
 Assign to a specific Object ID.

void setPath (const char *path)
 Assign to an object path string (after converting to an Object ID).

void setNone ()
 Assign to Object ID 0 (no-path).

const ObjectID getPath () const
 Get the path's Object ID.

bool isNone () const
 Test for 'no-path' (Object ID == 0).

bool operator!= (Path const &p) const
 Test for equality of two paths.

virtual void parseXML (const char *cdata)
 Parse cdata from within the XML tags for this object.

virtual void convertXML ()
 Convert XML data to internal format prior to serialization.

bool unique () const
 Returns true if this is the only reference to an object.

void setNull ()
 Clear pointer.

bool isNull () const
 Test for null pointer.

bool operator! () const
 Test for null pointer.

bool valid () const
 Test for non-null pointer.

virtual Object__get__ ()

Protected Methods

virtual void _update (Object *ptr) throw (ObjectTypeMismatch)
 Internal pointer update.

void _load (DataArchive *archive, ObjectID path=0)
 Create a new object instance from source data.

void _assign_safe (Object *ptr)
 Rebind to a new object, testing for type compatibility.

void _assign_fast (Object *ptr)
 Rebind to a new object, without testing for type compatibility.

void _release ()
 Rebind to null.

Object_get () const
 Get the current object pointer.


Protected Attributes

ObjectID _path
Object_reference
 The actual object pointer.


Detailed Description

template<class T>
class Link< T >

Class-specialized, auto-loading smart-pointer to Objects.

Use this class for linking to other Objects in a data archive. The associated Objects will automatically be created by the archive loader as directed by the external XML data.

Once loaded, Link<> handles behaves very much like ordinary Ref<> handles. For storing and passing objects references, and for manually instantiating Objects from a data archive, you should use a Ref<> handle instead of Link<>.

Author:
Mark Rose <mrose@stm.lbl.gov>


Member Typedef Documentation

template<class T>
typedef std::vector< Link<T> > Link< T >::vector
 

Convenience typedef.


Constructor & Destructor Documentation

template<class T>
Link< T >::Link   [inline, explicit]
 

Create a null Link.

template<class T>
Link< T >::Link const Path   path,
T *    ptr
[inline, explicit]
 

Create a Link with both a path and an object.

template<class T>
Link< T >::Link const char *    path [inline, explicit]
 

Create a Link with a path but no object (null).

template<class T>
Link< T >::Link T *    t [inline, explicit]
 

Create a Link with an object reference, but no path.

template<class T>
Link< T >::Link const Link< T > &    p [inline]
 

Fast copy constructor.

template<class T>
Link< T >::Link const LinkBase   p [inline]
 

Safe copy constructor.


Member Function Documentation

bool ReferencePointer::__eq__ const ReferencePointer   other [inherited]
 

NAMESPACE_SIMDATA bool LinkBase::__eq__ const LinkBase   other [inherited]
 

virtual Object* ReferencePointer::__get__   [inline, virtual, inherited]
 

bool ReferencePointer::__ne__ const ReferencePointer   other [inherited]
 

bool LinkBase::__ne__ const LinkBase   other [inherited]
 

void ReferencePointer::_assign_fast Object   ptr [inline, protected, inherited]
 

Rebind to a new object, without testing for type compatibility.

Use this method only when you know that the pointer you are assignng from has the correct type.

void ReferencePointer::_assign_safe Object   ptr [inline, protected, inherited]
 

Rebind to a new object, testing for type compatibility.

This method calls _update(), which is overridden in the Pointer<> class to attempt a dynamic cast to the template type and throws an exception if the cast fails.

Object* ReferencePointer::_get   const [inline, protected, inherited]
 

Get the current object pointer.

void LinkBase::_load DataArchive   archive,
ObjectID    path = 0
[protected, inherited]
 

Create a new object instance from source data.

Parameters:
archive  The data archive from which to load the new object's data.
path  The object path to load.

void ReferencePointer::_release   [inline, protected, inherited]
 

Rebind to null.

template<class T>
virtual void Link< T >::_update Object   ptr throw (ObjectTypeMismatch) [inline, protected, virtual]
 

Internal pointer update.

Changes the object pointer without reference counting, checking that the new object type matches the template type.

Reimplemented from ReferencePointer.

std::string LinkBase::asString   [virtual, inherited]
 

String representation.

Reimplemented from Path.

void BaseType::convertXML   [virtual, inherited]
 

Convert XML data to internal format prior to serialization.

This method is currently only called by the XML parser for Object classes. If another BaseType class requires this method, a call must be added to the appropriate XML handler in the parser.

template<class T>
T* Link< T >::get   [inline]
 

Dereference.

template<class T>
const T* Link< T >::get   const [inline]
 

Const dereference.

const ObjectID Path::getPath   const [inline, inherited]
 

Get the path's Object ID.

bool Path::isNone   const [inline, inherited]
 

Test for 'no-path' (Object ID == 0).

bool ReferencePointer::isNull   const [inline, inherited]
 

Test for null pointer.

template<class T>
const T& Link< T >::operator *   const [inline]
 

Const dereference.

template<class T>
T& Link< T >::operator *   [inline]
 

Dereference.

bool ReferencePointer::operator!   const [inline, inherited]
 

Test for null pointer.

bool Path::operator!= Path const &    p const [inline, inherited]
 

Test for equality of two paths.

template<class T>
const T* Link< T >::operator->   const [inline]
 

Const dereference.

template<class T>
T* Link< T >::operator->   [inline]
 

Dereference.

template<class T>
T* Link< T >::operator= T *    t [inline]
 

Assign a pointer.

bool ReferencePointer::operator== ReferencePointer const &    p const [inline, inherited]
 

Comparison with other simdata pointers.

bool Path::operator== Path const &    p const [inline, inherited]
 

Test for equality of two paths.

bool LinkBase::operator== LinkBase const &    p const [inline, inherited]
 

Comparison with other simdata pointers.

void BaseType::parseXML const char *    cdata [virtual, inherited]
 

Parse cdata from within the XML tags for this object.

Reimplemented in SimDate, EnumLink, GeoPos, LLA, UTM, Matrix3, Quat, Real, and Vector3.

void LinkBase::serialize Archive   [virtual, inherited]
 

Serialize to or from a data archive.

Saves the path, and also saves the referenced object if the path is 'None'. Packing a None and Null LinkBase is an error.

Reads the saved path and binds to the correct object. If the path is None, the object is unpacked from the subsequent data. Otherwise the object is created by asking the current DataArchive to instantiate an instance of the path.

Reimplemented from Path.

void Path::setNone   [inline, inherited]
 

Assign to Object ID 0 (no-path).

void ReferencePointer::setNull   [inline, inherited]
 

Clear pointer.

NAMESPACE_SIMDATA void Path::setPath const char *    path [inherited]
 

Assign to an object path string (after converting to an Object ID).

void Path::setPath ObjectID    path [inline, inherited]
 

Assign to a specific Object ID.

template<class T>
virtual std::string Link< T >::typeString   const [inline, virtual]
 

Return a string representation of the type.

Reimplemented from LinkBase.

bool ReferencePointer::unique   const [inline, inherited]
 

Returns true if this is the only reference to an object.

bool ReferencePointer::valid   const [inline, inherited]
 

Test for non-null pointer.


Member Data Documentation

ObjectID Path::_path [protected, inherited]
 

Object* ReferencePointer::_reference [protected, inherited]
 

The actual object pointer.


The documentation for this class was generated from the following file:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:41 2003, using Doxygen 1.2.18.

[SF.net]