Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

HLAObjectInstance Class Reference
[The Federate ToolKit (FTK) Module]

#include <hlaobjectinstance.h>

Inheritance diagram for HLAObjectInstance:

ReturnValueInstance List of all members.

Detailed Description

This class represents an instance of an HLA object.


Public Member Functions

 HLAObjectInstance (const char *clname)
 HLAObjectInstance (ftk::HANDLE objHandle, ftk::HANDLE classHandle)
virtual ~HLAObjectInstance (void)
void removeFromFederation (void)
HLAObjectClassgetObjectClass (void)
ftk::HANDLE classHandleGet (void)
const char * classNameGet (void)
void handleSet (ftk::HANDLE id)
ftk::HANDLE handleGet (void)
void discovered (bool d)
bool discovered (void)
void zombie (bool z)
bool zombie ()
bool isAttributeInitialized (ftk::ATTRIBUTE_INDEX index)
bool isAttributeInitialized (ftk::HANDLE h)
virtual bool getAttributeData (ftk::HANDLE h, char *&data, unsigned int &size)=0
virtual bool setAttributeData (ftk::HANDLE h, const char *data, unsigned int size)=0
void queueAttributeRequest (ftk::HANDLE handle)
void queueAttributeUpdate (ftk::HANDLE handle)
void queueAttributeAcquisition (ftk::HANDLE handle)
void queueAttributeRelease (ftk::HANDLE handle)
int processPendingUpdates (void)
int processPendingRequests (void)
int processPendingReleases (void)
int processPendingAcquisitions (void)
int processPendings (unsigned char what)
bool attributeOwnershipAcquisition (set< ftk::ATTRIBUTE_INDEX > &attr, unsigned char priority)
bool unconditionalAttributeOwnershipDivestiture (set< ftk::ATTRIBUTE_INDEX > &attr)
bool attributeOwned (ftk::HANDLE h)
void attributeOwned (ftk::HANDLE h, bool o)
size_t getNumberOfClients ()
bool addClient (MessageClient *client)
bool removeClient (MessageClient *client)
bool addClient (InstanceClient *client)
bool removeClient (InstanceClient *client)
void notifyRemoval (void)
MessageClientgetFirstClient ()
MessageClientgetNextClient ()
bool isIdentified (void)
bool isReady (void)
bool isComplete (void)
bool isRepresented (void)
void setRepresented (void)
void setIdentifierAttribute (ftk::HANDLE h)
void addReadyRequiredAttribute (ftk::HANDLE h)
virtual void identified (void)
virtual void ready (void)
virtual void complete (void)
virtual void reflect (ftk::HANDLE h)
virtual void messageReceived (MethodMessage *msg)
void processReflection (ftk::HANDLE h)
void checkPendingAcquisitions (ftk::HANDLE h)
void nameSet (std::string name)
std::string nameGet () const
std::string entityNameGet (void)
std::string parentNameGet (void)
size_t hierachyLevelGet (void)
std::string nameLevelGet (size_t level)
virtual void print (ostream &w=cout)
void setAttributeTimestamp (ftk::HANDLE attributeHandle, double timeStamp)
double getAttributeTimestamp (ftk::HANDLE attributeHandle)

Protected Member Functions

void checkInitializedAttributes (ftk::HANDLE h)
void checkPendingUpdates (ftk::HANDLE h)
void markAttributeInitialized (ftk::HANDLE h)

Protected Attributes

HLAObjectClass_objectClassPtr
ftk::HANDLE _objectHandle
std::string _name
std::string _entityName
std::string _parentName
size_t _hierarchyLevel
set< ftk::HANDLEattributes2update
queue< ftk::HANDLEattributes2request
queue< ftk::HANDLEattributes2release
queue< ftk::HANDLEattributes2acquire
map< ftk::HANDLE, bool > owned_attributes
list< MessageClient * > _msgClients
list< MessageClient * >::iterator _currentClient
list< InstanceClient * > _objClients

Private Member Functions

void parseName (void)

Private Attributes

bool _discovered
bool _identified
bool _ready
bool _complete
bool _represented
bool _zombie
ftk::HANDLE _identifierHandle
set< ftk::HANDLE_readyRequiredHandles
map< ftk::HANDLE, bool > initialized_attributes
set< ftk::HANDLE_pendingUpdates
set< ftk::HANDLE_pendingAcquisitions
map< ftk::HANDLE, double > _timeStamps


Constructor & Destructor Documentation

HLAObjectInstance::HLAObjectInstance const char *  clname  ) 
 

Constructor - creates an object instance of class clname.

This constructor is used by a federate which wants to create its own local objects in order to register them with the RFI (by using RFI::registerObjectInstance()).

See also:
RFI::registerObjectInstance()

HLAObjectInstance::HLAObjectInstance ftk::HANDLE  objHandle,
ftk::HANDLE  classHandle
 

Contructor - creates an object instance having an object handle and an HLAObjectClass.

This constructor is used by the Federate Ambassador when it discovers an object and wants to add it to the local object list (by using RFI::addObjectInstance()).

See also:
RFI::addObjectInstance()

HLAObjectInstance::~HLAObjectInstance void   )  [virtual]
 

Destructor.

Does some cleaning and removes the object instance from the federation.


Member Function Documentation

void HLAObjectInstance::removeFromFederation void   ) 
 

Removes this object from the Federation.

HLAObjectClass * HLAObjectInstance::getObjectClass void   ) 
 

Returns the class (HLAObjectClass) of the object instance.

ftk::HANDLE HLAObjectInstance::classHandleGet void   ) 
 

Returns the class handle for this object instance.

const char * HLAObjectInstance::classNameGet void   ) 
 

Returns the class name of this object instance.

void HLAObjectInstance::handleSet ftk::HANDLE  id  ) 
 

Sets the handle for this object instance.

This should be done only by a method which get this handle from the RTI.

ftk::HANDLE HLAObjectInstance::handleGet void   ) 
 

Returns the handle for this object instance.

void HLAObjectInstance::discovered bool  d  ) 
 

Sets boolean defining whether or not this object has been discovered.

Parameters:
d true signifies that this object has been discovered. false signifies that this object has been created by this federate.

bool HLAObjectInstance::discovered void   ) 
 

Tests whether or not this object has been discovered.

Returns:
true if this object has been discovered by the federate, false if this object was created by the federate itself.

void HLAObjectInstance::zombie bool  z  ) 
 

Mark the instance as zombie or not. An instance is considered as zombie when it still exist in the LRC, but not in the RTIexec database. This situation typically occurs after a reset. A zombie instance will not try to remove itself from the federation a destruction.

bool HLAObjectInstance::zombie  ) 
 

Return the zombie state of the instance (see above method).

bool HLAObjectInstance::isAttributeInitialized ftk::ATTRIBUTE_INDEX  index  ) 
 

bool HLAObjectInstance::isAttributeInitialized ftk::HANDLE  h  )  [inline]
 

virtual bool HLAObjectInstance::getAttributeData ftk::HANDLE  h,
char *&  data,
unsigned int &  size
[pure virtual]
 

Returns the data corresponding to the given handle.

This method is purely virtual and has to be implemented by derived classes which know about the queried data.

Parameters:
h attribute handle
data reference to a pointer to a char buffer
size the size of the buffer containing the desired data
Warning:
The caller of this function just provides a pointer to the buffer. The memory for the data should then be allocated. (In normal FTK usage this is done by the XDRmessage.getBuffer(data) call.) But it is up to the caller to delete the allocated memory.
See also:
HLAObjectInstance::processPendingUpdates() for a correct example.

Implemented in ReturnValueInstance.

virtual bool HLAObjectInstance::setAttributeData ftk::HANDLE  h,
const char *  data,
unsigned int  size
[pure virtual]
 

Sets the data corresponding to a given handle.

This method is purely virtual and has to be implemented by derived classes: making this call causes the concerned sub-class to set its correct data member (identified by h) with the given data.

Parameters:
h attribute handle
data pointer to the buffer containing the data to set
size size of the data to set

Implemented in ReturnValueInstance.

void HLAObjectInstance::queueAttributeRequest ftk::HANDLE  handle  ) 
 

Pushes the request for an update for the attribute with the given handle to a local queue. Clients of this objectinstance will be notified that all updates requests have been performed with the attributesInitialized callback.

void HLAObjectInstance::queueAttributeUpdate ftk::HANDLE  handle  ) 
 

Pushes the action to update the attribute with the given handle to a local queue.

void HLAObjectInstance::queueAttributeAcquisition ftk::HANDLE  handle  ) 
 

Pushes the request to acquire the ownership of the attribute with the given handle to a local queue. Clients of this objectinstance will be notified that all acquisitions requests have been performed with the onwershipsAcquired callback.

void HLAObjectInstance::queueAttributeRelease ftk::HANDLE  handle  ) 
 

Pushes the action to release the ownership of the attribute with the given handle to a local queue.

int HLAObjectInstance::processPendingUpdates void   ) 
 

Processes the pending update actions.

int HLAObjectInstance::processPendingRequests void   ) 
 

Processes the pending update request(s).

int HLAObjectInstance::processPendingReleases void   ) 
 

Processes the pending ownership release(s).

int HLAObjectInstance::processPendingAcquisitions void   ) 
 

Processes the pending ownership acquisitiions(s).

int HLAObjectInstance::processPendings unsigned char  what  ) 
 

Processes all the pending actions present in the local queues.

bool HLAObjectInstance::attributeOwnershipAcquisition set< ftk::ATTRIBUTE_INDEX > &  attr,
unsigned char  priority
 

Sends a request for ownership of a given set of attributes to the RTI.

The attribute ownership acquisition is perfomed on the basis of the priority argument. The federate can acquire the attribute only if the given priority is higher than the priority that the owning federate has given to this object class.

bool HLAObjectInstance::unconditionalAttributeOwnershipDivestiture set< ftk::ATTRIBUTE_INDEX > &  attr  ) 
 

Unconditionally releases a set of attributes.

bool HLAObjectInstance::attributeOwned ftk::HANDLE  h  ) 
 

Tests whether or not the attribute with the given handle is owned by the federate.

Returns:
true if the attribute is owned by the federate, false otherwise

void HLAObjectInstance::attributeOwned ftk::HANDLE  h,
bool  o
 

Sets the boolean defining whether or not the attribute with the given handle is owned by the federate.

size_t HLAObjectInstance::getNumberOfClients  ) 
 

Return the number of clients this object instance has.

bool HLAObjectInstance::addClient MessageClient client  ) 
 

Set a new client of this object instance. Return false if the client is already in the list, true otherwise (after insertion).

bool HLAObjectInstance::removeClient MessageClient client  ) 
 

Remove a client from the list of this object instance. Return false if the client was not in the list, false otherwise (after deletion).

bool HLAObjectInstance::addClient InstanceClient client  ) 
 

bool HLAObjectInstance::removeClient InstanceClient client  ) 
 

void HLAObjectInstance::notifyRemoval void   ) 
 

MessageClient * HLAObjectInstance::getFirstClient  ) 
 

Return a pointer on the first client of this object instance.

MessageClient * HLAObjectInstance::getNextClient  ) 
 

Return a pointer on the next client of this object instance.

bool HLAObjectInstance::isIdentified void   )  [inline]
 

Tests whether or not the object instance has been marked as identified.

"Identified" means that all the necessary attributes to completely identify this object instance have been initialized.

bool HLAObjectInstance::isReady void   )  [inline]
 

Returns if the object is ready to use or not. The significance of ready is application dependent.

bool HLAObjectInstance::isComplete void   )  [inline]
 

Tests whether or not this object instance has been fully initialized.

Returns:
true when all the attributes of this object have received at least one valid update, false otherwise.

bool HLAObjectInstance::isRepresented void   )  [inline]
 

Tests whether or not this object instance has been represented by this federate.

"Represented" could be used for any purpose by the federate. Normally it is used to determine if the federate has created a specific object to represent/manage its HLA equivalent.

void HLAObjectInstance::setRepresented void   )  [inline]
 

Set the object as represented.

void HLAObjectInstance::setIdentifierAttribute ftk::HANDLE  h  ) 
 

void HLAObjectInstance::addReadyRequiredAttribute ftk::HANDLE  h  ) 
 

virtual void HLAObjectInstance::identified void   )  [inline, virtual]
 

This method will be called when the instance has been identified. This is to derived classes of HLAObjectInstance to initiate this call (for example when it receive an relection for an identifier). The method should be implemented by derived classes.

virtual void HLAObjectInstance::ready void   )  [inline, virtual]
 

This method will be called when the instance is ready to use by a specific federate.

virtual void HLAObjectInstance::complete void   )  [inline, virtual]
 

This method will be called when all the attributes of this instance have been initialized. This method is called from the HLAObjectInstance level: developper of derived classes does not have to initiate this call, but can implement the method itself.

virtual void HLAObjectInstance::reflect ftk::HANDLE  h  )  [inline, virtual]
 

This method will be called when the federateambassador process an attribute reflection.

virtual void HLAObjectInstance::messageReceived MethodMessage msg  )  [inline, virtual]
 

This method could be implemented by derived classes to handle message attached to an instance.

void HLAObjectInstance::processReflection ftk::HANDLE  h  ) 
 

Check if the attribute reflection satisfies any request and make the object fully identified and propagate the attribute inside the object and its clients.

void HLAObjectInstance::checkPendingAcquisitions ftk::HANDLE  h  ) 
 

Check the status of pendinf acquisitions. Using the given handle, this method checks if after this ownership acquisition notification there is still pending acquisitions. If not, then the method will notify all clients that all the acquisitions requests have been satisfied (with onwershipsAcquired).

void HLAObjectInstance::nameSet std::string  name  ) 
 

Set the full name of the entity

std::string HLAObjectInstance::nameGet  )  const
 

Return the full name of the entity (with its hierachy). K9:HazCam:Physical -> K9:HazCam:Physical

string HLAObjectInstance::entityNameGet void   ) 
 

Return the short name of the entity. K9:HazCam:Physical -> Physical

string HLAObjectInstance::parentNameGet void   ) 
 

Return the parent full name of the entity. K9:HazCam:Physical -> K9:HazCam

size_t HLAObjectInstance::hierachyLevelGet void   ) 
 

Return the depth of the hierachy where this object is located. K9:HazCam:Physical -> 3

string HLAObjectInstance::nameLevelGet size_t  level  ) 
 

Return the name of the parent at the given level. (K9:HazCam:Physical,1) -> K9 (K9:HazCam:Physical,2) -> HazCam (K9:HazCam:Physical,3) -> Physical

void HLAObjectInstance::print ostream &  w = cout  )  [virtual]
 

void HLAObjectInstance::setAttributeTimestamp ftk::HANDLE  attributeHandle,
double  timeStamp
 

Set the time of the attribute update.

Parameters:
attributeHandle  RTI handle of the attribute
timeStamp  Time of the update.

double HLAObjectInstance::getAttributeTimestamp ftk::HANDLE  attributeHandle  ) 
 

Return the time of the most recent update or -1 if there is no time stamp.

Parameters:
attributeHandle  RTI handle of the desired attribute.

void HLAObjectInstance::checkInitializedAttributes ftk::HANDLE  h  )  [protected]
 

Marks the attribute with the given handle as initialized, then checks if all the attributes have been initialized, and if so, marks this object as initialized.

Todo:
: This method should go in the private section and allow only ftkfederateambassador to call it...

void HLAObjectInstance::checkPendingUpdates ftk::HANDLE  h  )  [protected]
 

Check the status of the pending updates. Using the given handle, this method checks if after this update there is still pending updates. If not, then the method will notify all clients that all the update requests have been satisfied (with attributesInitialized).

void HLAObjectInstance::markAttributeInitialized ftk::HANDLE  h  )  [protected]
 

void HLAObjectInstance::parseName void   )  [private]
 

This method extract information from the name: entityName, parentName and hierachyLevel.


Member Data Documentation

HLAObjectClass* HLAObjectInstance::_objectClassPtr [protected]
 

Pointer to the class of this object

ftk::HANDLE HLAObjectInstance::_objectHandle [protected]
 

The handle of this object instance (defined by the RTI).

std::string HLAObjectInstance::_name [protected]
 

full name of this object instance. this name should be unique among the federation. this name contains the hierachy of objects.

std::string HLAObjectInstance::_entityName [protected]
 

name of the object instance without the full hierachy.

std::string HLAObjectInstance::_parentName [protected]
 

Full name of the parent of this object instance.

size_t HLAObjectInstance::_hierarchyLevel [protected]
 

Depth of the hierachy

set<ftk::HANDLE> HLAObjectInstance::attributes2update [protected]
 

A queue of the attributes to update. This queue is needed because the RTI is not reentrant. Then if the federateAmbassador receive a request to update an attribute, then the application can not call right away a method to the rtiAmbassador to provide the requested update: the federateAmbassador put this update request in a queue which will then be processed outside the federateAmbassador and then avoid the reentrant call to the RTI.

Todo:
Continue comment editing from this point [MDW]

queue<ftk::HANDLE> HLAObjectInstance::attributes2request [protected]
 

A queue of the attribute for which this object require updates.

queue<ftk::HANDLE> HLAObjectInstance::attributes2release [protected]
 

A queue of the attributes to release. This queue is needed for the same reason than attributes2update. In this case, we maintain a queue of all the attributes for which this federate should release the ownership.

queue<ftk::HANDLE> HLAObjectInstance::attributes2acquire [protected]
 

A queue of the attributes to acquire.

map<ftk::HANDLE, bool> HLAObjectInstance::owned_attributes [protected]
 

This map maintained a list of the status of each attributes regarding their ownership. A true value associated with a attribute handle means that this attribute is owned by this federate, a false value mean that it is not owned by this federate.

list<MessageClient*> HLAObjectInstance::_msgClients [protected]
 

List of clients of this message instance.

list<MessageClient*>::iterator HLAObjectInstance::_currentClient [protected]
 

Last returned client.

list<InstanceClient*> HLAObjectInstance::_objClients [protected]
 

bool HLAObjectInstance::_discovered [private]
 

Define if this object been discovered (@ c true) or created by this federate (false)

bool HLAObjectInstance::_identified [private]
 

Flag to store if this object instance is identified or not.

bool HLAObjectInstance::_ready [private]
 

Flag to store if this object instance is ready to be used or not.

bool HLAObjectInstance::_complete [private]
 

Flag to store if this object has been fully initialized or not

bool HLAObjectInstance::_represented [private]
 

Flag to store if this object instance has been represented or not.

bool HLAObjectInstance::_zombie [private]
 

ftk::HANDLE HLAObjectInstance::_identifierHandle [private]
 

Handle of the attribute marking the instance as identified.

set<ftk::HANDLE> HLAObjectInstance::_readyRequiredHandles [private]
 

Set of handles marking the instance as ready.

map<ftk::HANDLE, bool> HLAObjectInstance::initialized_attributes [private]
 

Map to store if the attributes of this object instance have been initialized or not.

set<ftk::HANDLE> HLAObjectInstance::_pendingUpdates [private]
 

set<ftk::HANDLE> HLAObjectInstance::_pendingAcquisitions [private]
 

map<ftk::HANDLE,double> HLAObjectInstance::_timeStamps [private]
 


The documentation for this class was generated from the following files:
Generated on Thu Apr 7 18:20:54 2005 for MST API by  doxygen 1.4.1