MAK Legion 1.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Legion::SimulationDatabase Class Reference

The SimulationDatabase stores all data for the simulation. It also owns the event, control, and view managers. More...

+ Collaboration diagram for Legion::SimulationDatabase:

Public Member Functions

 SimulationDatabase (const Configuration &config)
 constructor More...
 
 SimulationDatabase (DatabaseHandle dbHandle)
 Access an existing database by it's handle - doesn't create a new database. More...
 
virtual ~SimulationDatabase ()
 destructor More...
 
virtual DatabaseHandle handle () const
 Returns the handle to the internal representation of this object. More...
 
virtual void beginFrame (double time)
 BeginFrame tells the database that a new frame of simulation has started and allows for synchronization and updating of internal data structures. More...
 
virtual void endFrame ()
 EndFrame tells the database that a frame of simulation has completed and allows for synchronization and updating of internal data structures. More...
 
virtual bool inFrame () const
 Users can check if the database is between an begin and end frame call. More...
 
virtual UInt64 currentFrame () const
 Gets the current frame number. More...
 
virtual double simTime () const
 gets the current simulation time More...
 
virtual ClientId clientId () const
 Get the current client ID of this database if the simulation is distributed over a network. More...
 
virtual bool addBeginFrameCallback (BeginFrameCb bfcb)
 Register and unregister callbacks for beginning of frame. More...
 
virtual bool removeBeginFrameCallback (BeginFrameCb bfcb)
 
virtual bool addEndFrameCallback (EndFrameCb efd)
 Register and unregister callbacks for end of frame. More...
 
virtual bool removeEndFrameCallback (EndFrameCb efd)
 
virtual AttributeSetId registerAttributeSet (const AttributeSetDescriptor &descriptor)
 Register a new type of attribute set with the database for storage. More...
 
virtual AttributeIndex registerAttribute (UInt32 setId, const AttributeDescriptor &descriptor)
 Register a new type of attribute with an existing attribute set for storage. More...
 
virtual AttributeSetId findAttributeSetId (const std::string &name)
 Find the attribute set id from the set name. More...
 
virtual AttributeIndex findAttributeIndex (UInt32 setId, const std::string &name)
 Find the application specific attribute index of an attribute from its name. More...
 
virtual AttributeIndex findAttributeIndex (UInt32 setId, UInt32 attrId)
 Find the application specific attribute index of an attribute from its ID. More...
 
template<typename OBJECT_TYPE >
OBJECT_TYPE createInstance ()
 Create an instance of registered legion object the OBJECT_TYPE class must have a static function type() that returns a AttributeSetId for the instance you want to create. More...
 
virtual InstanceHandle findInstance (GlobalIdentifier globalId)
 Find the internal instance handle of a simulation object from its globalID. More...
 
virtual void destroyInstance (const WriteStateInstance &instance)
 Destroy an instance that was created in this database. More...
 
virtual ClientId getClientId (InstanceHandle instance)
 Get the client ID of owner of the given instance handle. More...
 
virtual GlobalIdentifier findGlobalId (InstanceHandle handle)
 Find the global ID from the internal instance handle of a simulation object. More...
 
virtual Bool reserve (AttributeSetId type, UInt32 count)
 Reserve enough space for count instances of a given attribute set. More...
 
virtual UInt32 capacity (AttributeSetId type)
 Returns the capacity for a given attribute set. More...
 
virtual EventManagereventManager ()
 Get the Event Manager for the database. More...
 
virtual ControlManagercontrolManager ()
 Get the Control Manager for the database. More...
 
virtual ViewManagerviewManager ()
 Get the View Manager for the database. More...
 

Static Protected Member Functions

static void beginFrameCallback (void *usr, double simTime)
 
static void endFrameCallback (void *usr)
 

Protected Attributes

DatabaseHandle myHandle
 
EventManagermyEventManager
 
ControlManagermyControlManager
 
ViewManagermyViewManager
 
bool myIsReference
 
std::vector< BeginFrameCbmyBeginFrameCallbacks
 
std::vector< EndFrameCbmyEndFrameCallbacks
 

Detailed Description

The SimulationDatabase stores all data for the simulation. It also owns the event, control, and view managers.

Constructor & Destructor Documentation

Legion::SimulationDatabase::SimulationDatabase ( const Configuration config)

constructor

Legion::SimulationDatabase::SimulationDatabase ( DatabaseHandle  dbHandle)

Access an existing database by it's handle - doesn't create a new database.

virtual Legion::SimulationDatabase::~SimulationDatabase ( )

destructor

Member Function Documentation

virtual bool Legion::SimulationDatabase::addBeginFrameCallback ( BeginFrameCb  bfcb)
virtual

Register and unregister callbacks for beginning of frame.

virtual bool Legion::SimulationDatabase::addEndFrameCallback ( EndFrameCb  efd)
virtual

Register and unregister callbacks for end of frame.

virtual void Legion::SimulationDatabase::beginFrame ( double  time)
virtual

BeginFrame tells the database that a new frame of simulation has started and allows for synchronization and updating of internal data structures.

The user needs to provide the current simulation time to the database.

Referenced by Clutter::SimEngine::finish(), and main().

static void Legion::SimulationDatabase::beginFrameCallback ( void *  usr,
double  simTime 
)
staticprotected
virtual UInt32 Legion::SimulationDatabase::capacity ( AttributeSetId  type)
virtual

Returns the capacity for a given attribute set.

Includes empty space and instantiated instances.

virtual ClientId Legion::SimulationDatabase::clientId ( ) const
virtual

Get the current client ID of this database if the simulation is distributed over a network.

virtual ControlManager& Legion::SimulationDatabase::controlManager ( )
virtual

Get the Control Manager for the database.

template<typename OBJECT_TYPE >
OBJECT_TYPE Legion::SimulationDatabase::createInstance ( )

Create an instance of registered legion object the OBJECT_TYPE class must have a static function type() that returns a AttributeSetId for the instance you want to create.

OBJECT_TYPE needs to derive from WriteStateInstance.

References legion_db_createInstance(), and Return_success.

Referenced by DtVehicleSim::DtVehicleSim(), DtVehicleSim::enableEmissions(), Clutter::SimEngine::init(), DtVehicleSim::init(), and main().

virtual UInt64 Legion::SimulationDatabase::currentFrame ( ) const
virtual

Gets the current frame number.

virtual void Legion::SimulationDatabase::destroyInstance ( const WriteStateInstance instance)
virtual

Destroy an instance that was created in this database.

Referenced by DtVehicleSim::disableEmissions(), main(), and DtVehicleSim::~DtVehicleSim().

virtual void Legion::SimulationDatabase::endFrame ( )
virtual

EndFrame tells the database that a frame of simulation has completed and allows for synchronization and updating of internal data structures.

Referenced by Clutter::SimEngine::finish(), and main().

static void Legion::SimulationDatabase::endFrameCallback ( void *  usr)
staticprotected
virtual EventManager& Legion::SimulationDatabase::eventManager ( )
virtual
virtual AttributeIndex Legion::SimulationDatabase::findAttributeIndex ( UInt32  setId,
const std::string &  name 
)
virtual

Find the application specific attribute index of an attribute from its name.

Referenced by registerCustomAttributeSet().

virtual AttributeIndex Legion::SimulationDatabase::findAttributeIndex ( UInt32  setId,
UInt32  attrId 
)
virtual

Find the application specific attribute index of an attribute from its ID.

virtual AttributeSetId Legion::SimulationDatabase::findAttributeSetId ( const std::string &  name)
virtual

Find the attribute set id from the set name.

Referenced by Clutter::SimEngine::extendEntityAttributes(), and RegisterCustomEntityAttributes().

virtual GlobalIdentifier Legion::SimulationDatabase::findGlobalId ( InstanceHandle  handle)
virtual

Find the global ID from the internal instance handle of a simulation object.

If the Attribute Set of the ID is not registered or the instance is not known, this function will return 0.

virtual InstanceHandle Legion::SimulationDatabase::findInstance ( GlobalIdentifier  globalId)
virtual

Find the internal instance handle of a simulation object from its globalID.

If the Attribute Set of the instance is not registered or the instance is not known, this function will return 0.

Referenced by processOwnershipAcquired().

virtual ClientId Legion::SimulationDatabase::getClientId ( InstanceHandle  instance)
virtual

Get the client ID of owner of the given instance handle.

virtual DatabaseHandle Legion::SimulationDatabase::handle ( ) const
inlinevirtual

Returns the handle to the internal representation of this object.

virtual bool Legion::SimulationDatabase::inFrame ( ) const
virtual

Users can check if the database is between an begin and end frame call.

Several operations can only happen between begin/end frame calls such as creating or destroying instances, and creating and sending events, and controls

virtual AttributeIndex Legion::SimulationDatabase::registerAttribute ( UInt32  setId,
const AttributeDescriptor descriptor 
)
virtual

Register a new type of attribute with an existing attribute set for storage.

Referenced by Clutter::SimEngine::extendEntityAttributes(), and RegisterCustomEntityAttributes().

virtual AttributeSetId Legion::SimulationDatabase::registerAttributeSet ( const AttributeSetDescriptor descriptor)
virtual

Register a new type of attribute set with the database for storage.

Referenced by registerCustomAttributeSet().

virtual bool Legion::SimulationDatabase::removeBeginFrameCallback ( BeginFrameCb  bfcb)
virtual
virtual bool Legion::SimulationDatabase::removeEndFrameCallback ( EndFrameCb  efd)
virtual
virtual Bool Legion::SimulationDatabase::reserve ( AttributeSetId  type,
UInt32  count 
)
virtual

Reserve enough space for count instances of a given attribute set.

Referenced by Clutter::SimEngine::init(), and Clutter::SimEngine::SimEngine().

virtual double Legion::SimulationDatabase::simTime ( ) const
virtual
virtual ViewManager& Legion::SimulationDatabase::viewManager ( )
virtual

Get the View Manager for the database.

Referenced by DtVehicleSim::DtVehicleSim(), f18ShutDownHandler(), main(), and DtVehicleSim::~DtVehicleSim().

Member Data Documentation

std::vector<BeginFrameCb> Legion::SimulationDatabase::myBeginFrameCallbacks
protected
ControlManager* Legion::SimulationDatabase::myControlManager
protected
std::vector<EndFrameCb> Legion::SimulationDatabase::myEndFrameCallbacks
protected
EventManager* Legion::SimulationDatabase::myEventManager
protected
DatabaseHandle Legion::SimulationDatabase::myHandle
protected
bool Legion::SimulationDatabase::myIsReference
protected
ViewManager* Legion::SimulationDatabase::myViewManager
protected

The documentation for this class was generated from the following files:

Document ID: Generated on Wed May 26 15:17:05 EDT 2021 from SVN revision 229676
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)