MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
Loading...
Searching...
No Matches
TSLDynamicDataObject Class Reference

Detailed Description

This abstract base class represents a generic object from the 'real' world. These objects may also have different visual representations of themselves (through TSLDisplayObject class objects). Derived classes will represent concrete real world objects (such as e.g. Accidents, Roadworks, ...).

TSLDynamicDataObject (DDO) objects should be added to a TSLObjectDataLayer. Once added to it, the object data layer then assumes ownership of the DDO object & the client need not worry about deleting those DDO pointers.

When a TSLObjectDataLayer is added to a TSLDrawingSurface, a TSLDisplay Object is created for each DDO by calling instantiateDO on the DDO class. Derived-DDO classes should return an appropriate TSLDisplayObject* in their implementation of this method.

The TSLDynamicDataObject class provides two macros which allow derived-DDO classes to be streamed (through TSLofstream and TSLifstream objects). In order to register a derived-DDO class for streaming, clients must incorporate the following in their class declaration (e.g.):

 #define ACCIDENT_CLASS_ID 101

 class Accident : public TSLDynamicDataObject
 {
 public:
    TSL_DECLARE_DDO_CLASS(Accident, ACCIDENT_CLASS_ID)
    // ...
 };

The class must then be registered in accident.cpp:

 TSL_REGISTER_DDO_CLASS(Accident, ACCIDENT_CLASS_ID)

This would be typically done to enable an object data layer to save its contained DDOs to disk & restore them later.

Note: this requires that the derived class provides a default constructor.

The virtual methods write() and read() are provided to allow derived-DDO classes to stream object attributes specific to their derived classes.

Classes

class  Registration_
 

Public Member Functions

virtual int classID__ () const
 
 TSLDynamicDataObject ()
 
 TSLDynamicDataObject (TSLTMC x1, TSLTMC y1, TSLTMC x2, TSLTMC y2)
 
virtual ~TSLDynamicDataObject ()
 
bool attached () const
 
virtual void destroy ()
 
void grab ()
 
void clearEntity ()
 
void move (TSLTMC x, TSLTMC y, bool updateDOextent=false)
 
void move (TSLCoord pos, bool updateDOextent=false)
 
bool ownsEntity () const
 
virtual TSLDisplayObjectinstantiateDO (TSLDisplayType key, int dsID=0) const
 
virtual void read (TSLifstream &stream)
 
void release ()
 
void setEntity (TSLEntity *entity, bool owner=false)
 
void translate (TSLCoord pos, bool updateDOextent=false)
 
void translate (TSLTMC x, TSLTMC y, bool updateDOextent=false)
 
virtual void write (TSLofstream &stream) const
 
const TSLvector< TSLDisplayObject * > & getDisplayObjects () const
 
TSLEntitygetEntity () const
 
TSLEnvelope getExtent () const
 
void position (const TSLCoord &newPos)
 
void position (TSLTMC x, TSLTMC y)
 
TSLCoord position () const
 
void selectable (bool selectability)
 
bool selectable () const
 
void setExtent (const TSLEnvelope &extent)
 
void setExtent (TSLTMC x1, TSLTMC y1, TSLTMC x2, TSLTMC y2)
 
void visible (bool visibility)
 
bool visible () const
 

Protected Member Functions

void initialiseClone (const TSLDynamicDataObject &rhs)
 

Protected Attributes

TSLvector< TSLDisplayObject * > * m_displayObjects
 

Constructor & Destructor Documentation

◆ TSLDynamicDataObject() [1/2]

TSLDynamicDataObject::TSLDynamicDataObject ( )

Default constructor.

After construction, the TSLDynamicDataObject has zero extent, is visible and selectable.

◆ TSLDynamicDataObject() [2/2]

TSLDynamicDataObject::TSLDynamicDataObject ( TSLTMC x1,
TSLTMC y1,
TSLTMC x2,
TSLTMC y2 )

Constructor with position supplied.

Parameters
(x1,y1)Bottom left co-ordinate (in TMC units) of TSLDynamicDataObject (DDO) extent.
(x2,y2)Upper right co-ordinate (in TMC units) of DDO extent.

After construction, the DDO has the specified extent, is visible and selectable.

◆ ~TSLDynamicDataObject()

virtual TSLDynamicDataObject::~TSLDynamicDataObject ( )
virtual

Virtual destructor.

Removes itself from the object data layer and deletes all its associated TSLDisplayObjects.

Member Function Documentation

◆ attached()

bool TSLDynamicDataObject::attached ( ) const

Query for whether TSLDynamicDataObject (DDO) is attached to an object data layer.

Note that this method is const.

Returns true if DDO is already attached, false otherwise.

◆ classID__()

virtual int TSLDynamicDataObject::classID__ ( ) const
inlinevirtual

◆ clearEntity()

void TSLDynamicDataObject::clearEntity ( )

Causes the dynamic data object to forget the entity added with setEntity. If the entity is owned by the dynamic data object (i.e. if the owner parameter was true when setEntity was called) then the entity will be deleted.

◆ destroy()

virtual void TSLDynamicDataObject::destroy ( )
virtual

This method is called to delete the instance of TSLDynamicDataObject.

You should provide an implementation of this method if you are not using the same Windows compiler that MapLink has been built with.

◆ getDisplayObjects()

const TSLvector< TSLDisplayObject * > & TSLDynamicDataObject::getDisplayObjects ( ) const
inline

Query method for the TSLDynamicDataObject's (DDO) associated TSLDisplay Objects (DO).

Note that this method is const.

Returns a constant reference to this DDO's vector of DO pointers.

Class TSLDynamicDataObject

◆ getEntity()

TSLEntity * TSLDynamicDataObject::getEntity ( ) const
inline

Query method for the entity associated with this TSLDynamicDataObject (DDO). This is for use by the application specific portion of the TSLDynamic DataObject or its associated TSLDisplayObjects.

Note that this method is const.

Returns the TSLEntity pointer associated with the DDO.

◆ getExtent()

TSLEnvelope TSLDynamicDataObject::getExtent ( ) const
inline

Query method for the extent of a TSLDynamicDataObject (DDO) in TMC Units.

Note that this method is const.

Returns the extent of the DDO as a TSLEnvelope.

◆ grab()

void TSLDynamicDataObject::grab ( )

Increment the reference count. The Object Data Layer uses this reference count to decide whether to delete the TSLDynamicDataObject. When the reference count is zero, the DDO is deleted.

The Object Data Layer increments the reference count when a DDO is added to it.

This mechanism is typically used for objects that need to be persistent and can be transferred between Object Data Layers.

◆ initialiseClone()

void TSLDynamicDataObject::initialiseClone ( const TSLDynamicDataObject & rhs)
protected

This method sets the member attributes of a cloned-copy.

◆ instantiateDO()

virtual TSLDisplayObject * TSLDynamicDataObject::instantiateDO ( TSLDisplayType key,
int dsID = 0 ) const
virtual

Called to create the TSLDisplayObject* (DO) to be used for this instance of the TSLDynamicDataObject (DDO).

Note that this method is const.

Parameters
keyOne of TSLDisplayType values. Determines the type of visualisation manager to use. Currently always tslTMS.
dsIDThe ID of the TSLDrawingSurface to which the DDO is being added.

The dsID allows clients to supply different classes of Display Object for different TSLDrawingSurfaces, or provide Drawing Surface specific positions for the Display Objects. This assumes that the client has tagged all drawing surfaces in his app with different (known) ids.

◆ move() [1/2]

void TSLDynamicDataObject::move ( TSLCoord pos,
bool updateDOextent = false )

Move the TSLDynamicDataObject (DDO) to the given (TSLCoord) position. This method also recalculates the DDO's extent.

Parameters
posThe position to move to (as a TSLCoord) in TMC units.
updateDOextentIf true, will update the extent of all TSLDisplayObjects associated with this DDO (default=false).

◆ move() [2/2]

void TSLDynamicDataObject::move ( TSLTMC x,
TSLTMC y,
bool updateDOextent = false )

Move the TSLDynamicDataObject (DDO) to the given (x,y) position. This method also recalculates the DDO's extent.

Parameters
(x,y)The new position in TMC units.
updateDOextentIf true, will update the extent of all TSLDisplayObjects associated with this DDO.

◆ ownsEntity()

bool TSLDynamicDataObject::ownsEntity ( ) const

Returns true if the dynamic data object owns its entity. This is the value given to the owner parameter of setEntity.

Note that this method is const.

◆ position() [1/3]

TSLCoord TSLDynamicDataObject::position ( ) const
inline

Query method for the position of the TSLDynamicDataObject (DDO).

Note that this method is const.

Returns the DDO position in TMC units.

◆ position() [2/3]

void TSLDynamicDataObject::position ( const TSLCoord & newPos)
inline

Set the TSLDynamicDataObject position (given a TSLCoord). This does not affect the extent and is typically used only during initialisation.

Parameters
newPosConst reference to the new position in TMC units.

◆ position() [3/3]

void TSLDynamicDataObject::position ( TSLTMC x,
TSLTMC y )
inline

Set the TSLDynamicDataObject position (given x & y). This does not affect the extent and is typically used only during initialisation.

Parameters
(x,y)The new position in TMC units.

◆ read()

virtual void TSLDynamicDataObject::read ( TSLifstream & stream)
virtual

This virtual method streams in derived-class specifics. It should be overridden by derived classes.

The stream passed is a binary stream. Therefore use only the read method of the stream.

Parameters
streamA reference to a TSLifstream object.

◆ release()

void TSLDynamicDataObject::release ( )

Release the object by decrementing the reference count. The Object Data Layer decrements the reference count when a DDO is removed from it or the Object Data Layer is deleted.

he Object Data Layer uses this reference count to decide whether to delete the TSLDynamicDataObject. When the reference count is zero, the DDO is deleted.

This mechanism is typically used for objects that need to be persistent and can be transferred between Object Data Layers.

◆ selectable() [1/2]

bool TSLDynamicDataObject::selectable ( ) const
inline

Query method for selectability of the TSLDynamicDataObject (DDO).

Note that this method is const.

Returns true if DDO is selectable, false otherwise.

◆ selectable() [2/2]

void TSLDynamicDataObject::selectable ( bool selectability)
inline

Set the selectability of the TSLDynamicDataObject (DDO).

Parameters
selectabilityIf true, then the DDO is selectable.

◆ setEntity()

void TSLDynamicDataObject::setEntity ( TSLEntity * entity,
bool owner = false )

Sets this object's entity.

Parameters
entityPointer to the entity.
ownerIf true, then the object is responsible for deleting its entity. Default is false.

◆ setExtent() [1/2]

void TSLDynamicDataObject::setExtent ( const TSLEnvelope & extent)
inline

Set the extent of the TSLDynamicDataObject (DDO).

Parameters
extentThe TSLEnvelope (in TMC units) describing the DDO extent.

◆ setExtent() [2/2]

void TSLDynamicDataObject::setExtent ( TSLTMC x1,
TSLTMC y1,
TSLTMC x2,
TSLTMC y2 )
inline

Set the extent of the TSLDynamicDataObject (DDO).

Parameters
(x1,y1)Bottom left co-ordinate (in TMC units) of DDO extent.
(x2,y2)Upper right co-ordinate (in TMC units) of DDO extent.

◆ translate() [1/2]

void TSLDynamicDataObject::translate ( TSLCoord pos,
bool updateDOextent = false )

Move the TSLDynamicDataObject (DDO) by the given (TSLCoord) offset. This method also recalculates the DDO's extent.

Parameters
posThe delta to move by in TMC units.
updateDOextentIf true, will update the extent of all TSLDisplayObjects associated with this DDO.

◆ translate() [2/2]

void TSLDynamicDataObject::translate ( TSLTMC x,
TSLTMC y,
bool updateDOextent = false )

Move the TSLDynamicDataObject (DDO) by the given (x,y) offset. This method also recalculates the DDO's extent.

Parameters
(x,y)The delta values to move by in TMC units.
updateDOextentIf true, will update the extent of all TSLDisplayObjects associated with this DDO.

◆ visible() [1/2]

bool TSLDynamicDataObject::visible ( ) const
inline

Query method for visibility of the TSLDynamicDataObject (DDO).

Note that this operation is const.

Returns true if DDO is visible, false otherwise.

◆ visible() [2/2]

void TSLDynamicDataObject::visible ( bool visibility)
inline

Set the visibility of the TSLDynamicDataObject (DDO).

Parameters
visibilityIf true, then DDO is visible.

◆ write()

virtual void TSLDynamicDataObject::write ( TSLofstream & stream) const
virtual

This virtual method streams out derived-class specifics. It should be overridden by derived classes.

Note that this method is const.

The stream passed is a binary stream. Therefore use only the write method of the stream.

Parameters
streamA reference to the binary stream object.

Member Data Documentation

◆ m_displayObjects

TSLvector<TSLDisplayObject *>* TSLDynamicDataObject::m_displayObjects
protected

Data Members for Associations