EntityType Class Reference

#include <EntityType.h>

Inherited by ArticulatedPhysicsEntityType, LinkedPhysicsEntityType, Physics2DEntityType, and SimplePhysicsEntityType.

Collaboration diagram for EntityType:

List of all members.


Public Member Functions

 EntityType (unsigned short id)
virtual ~EntityType ()
virtual void dump ()
void setName (std::string entName)
void setFixed (bool fixed)
virtual void setModel (ModelInterface *model)
unsigned short getId ()
std::string getName ()
unsigned getNumberOfInstances ()
bool isFixed ()
virtual EntitygetEntityByInstanceId (unsigned short instanceId)
virtual EntitygetEntityByEnvironmentBasedId (unsigned envBasedId)
virtual ModelInterfacegetModel ()
const std::vector< Entity * > & getInstanceList ()

Protected Member Functions

virtual EntitycreateInstance (unsigned short idOfEnv, unsigned short idInEnv)
virtual EntitycreateInstanceAtLoadTime (unsigned short idOfEnv, unsigned short idInEnv)
virtual EntitycreateInstanceUnchecked (unsigned short instId, unsigned short idOfEnv, unsigned short idInEnv)
virtual void removeInstance (Entity *entity)
virtual void clearInstances ()
virtual EventcreateEntityCreationEvent (Environment *env, unsigned environmentBasedId, TransformationData trans)
void setModelTemplate (ModelInterface *modelTemplate)
void setLocalEntityIdPool (IdPool *newlocalPool)
std::string getGlobalEntityIdPoolName ()
unsigned short getFreeInstanceId ()
unsigned short getFreeIdInEnvironment (Environment *env)

Protected Attributes

unsigned short id
 ID of the EntityType.
std::string name
 name of the EntityType
bool fixed
 boolean flag indicating that the model can't be moved
std::string nameGlobalEntityIdPool
 name of the globalEntityIdPool (set in setName method)
IdPool globalEntityIdPool
 globalEntityIdPool for EntityType
IdPoollocalEntityIdPool
 localEntityIdPool for creation of new Entities
IdPoolloadTimeEntityIdPool
 loadTimeEntityIdPool for creation of Entities on startup
std::vector< Entity * > instances
 list of Entity instances of this EntityType
ModelInterfacemodelTemplate
 model used as template for the Entity instances

Friends

class Entity
class Environment
class WorldDatabase
class SystemCore
class WorldDatabaseSyncEvent
class WorldDatabaseCreateEntityEvent

Constructor & Destructor Documentation

EntityType::EntityType ( unsigned short  id  ) 

Constructor initializes the members and sets the passed ID.

Parameters:
id ID of the EntityType

EntityType::~EntityType (  )  [virtual]

Destructor deletes all instances of the EntityType.


Member Function Documentation

void EntityType::clearInstances (  )  [protected, virtual]

Deletes all instances of the EntityType. The method deletes all created instances of this EntityType. It is mainly called by the destructor and the WorldDatabase::clearWorld method.

Event * EntityType::createEntityCreationEvent ( Environment env,
unsigned  environmentBasedId,
TransformationData  trans 
) [protected, virtual]

Creates the EntityCreationEvent for a new instance.

Reimplemented in LinkedPhysicsEntityType.

Entity * EntityType::createInstance ( unsigned short  idOfEnv,
unsigned short  idInEnv 
) [protected, virtual]

Creates a new instance of itself. The method creates a new Entity instance where the instanceId is requested from the localEntityIdPool.

Parameters:
idOfEnv ID of the destination Environment
idInEnv ID of the Entity in the Environment
Returns:
new Entity instance of current EntityType

Entity * EntityType::createInstanceAtLoadTime ( unsigned short  idOfEnv,
unsigned short  idInEnv 
) [protected, virtual]

Creates a new instance of itself at load time. The method creates a new Entity instance where the instanceId is requested from the loadTimeEntityIdPool.

Parameters:
idOfEnv ID of the destination Environment
idInEnv ID of the Entity in the Environment
Returns:
new Entity instance of the current EntityType

Reimplemented in Physics2DEntityType, ArticulatedPhysicsEntityType, LinkedPhysicsEntityType, and SimplePhysicsEntityType.

Entity * EntityType::createInstanceUnchecked ( unsigned short  instId,
unsigned short  idOfEnv,
unsigned short  idInEnv 
) [protected, virtual]

Creates a new instance of itself with the passed IDs. The method creates a new Entity instance with the passed IDs.

Parameters:
instId ID of the Entity instance
idOfEnv ID of the destination Environment
idInEnv ID of the Entity in the Environment
Returns:
new Entity instance of the current EntityType

Reimplemented in Physics2DEntityType, ArticulatedPhysicsEntityType, LinkedPhysicsEntityType, and SimplePhysicsEntityType.

void EntityType::dump (  )  [virtual]

The method dumps the EntityType's Id and name on the std:out

Entity * EntityType::getEntityByEnvironmentBasedId ( unsigned  envBasedId  )  [virtual]

Returns the Entity of this EntityType which has the passed environmentBasedId. It therefore iterates over all instances and checks if one Entity has the passed environmentBasedId.

Parameters:
envBasedId environmentBasedId of the searched Entity
Returns:
Entity if found, NULL otherwise

Entity * EntityType::getEntityByInstanceId ( unsigned short  instanceId  )  [virtual]

Returns the Entity of this EntityType which has the passed instanceId. It therefore iterates over all instances and checks the Entities for the passed Id.

Parameters:
instanceId instanceId of the searched Entity (=lower 16 bit of Entity::typeInstanceId)
Returns:
Entity if found, NULL otherwise

unsigned short EntityType::getFreeIdInEnvironment ( Environment env  )  [protected]

Returns the next free ID available from the id pool of the passed Environment

Returns:
free id in environment

unsigned short EntityType::getFreeInstanceId (  )  [protected]

Returns the next Instance ID available from the local id pool.

Returns:
free instance ID

std::string EntityType::getGlobalEntityIdPoolName (  )  [protected]

Returns the name of the globalEntityIdPool. This is used when connecting to other users to allocate the localEntityIdPool.

Returns:
name of the globalEntityIdPool

unsigned short EntityType::getId (  ) 

Returns the ID of the EntityType.

Returns:
ID of the EntityType

const std::vector< Entity * > & EntityType::getInstanceList (  ) 

Returns a pointer to a list of instances. Do not change to content of the list! And of course don't delete it.

ModelInterface * EntityType::getModel (  )  [virtual]

Returns the visual representation of the EntityType. The returned ModelInterface is used as template for the Entity-instances created by the class.

Returns:
Model-template for this EntityType, NULL if not set

std::string EntityType::getName (  ) 

Returns the name of the EntityType.

Returns:
name of the EntityType

unsigned EntityType::getNumberOfInstances (  ) 

Returns the number of instances of the EntityType.

Returns:
number of EntityType instances

bool EntityType::isFixed (  ) 

Returns whether the EntityType is fixed.

Returns:
true if the EntityType is fixed

void EntityType::removeInstance ( Entity entity  )  [protected, virtual]

Removes an instance from the list. The method is called from the Entity destructor and removes the passed entity from the list of instances.

Parameters:
entity Entity which should be removed

void EntityType::setFixed ( bool  fixed  ) 

Defines if the EntityType should be fixed.

Parameters:
fixed true if the EntityType should not be movable

void EntityType::setLocalEntityIdPool ( IdPool newlocalPool  )  [protected]

Sets the localEntityIdPool. The method is called when connecting to other users. After the localEntityIdPool is approved from all other users the new pool is set with this method.

Parameters:
newlocalPool approved localEntityIdPool

void EntityType::setModel ( ModelInterface model  )  [virtual]

Sets the Visual representation of the EntityType. The method sets the passed Model to be used as template for new Entity-instances created by this class.

Parameters:
model Model-template used for new Entity-instances

void EntityType::setModelTemplate ( ModelInterface modelTemplate  )  [protected]

Sets the model used for the instances.

Parameters:
modelTemplate Model which is used for instances

void EntityType::setName ( std::string  entName  ) 

Sets the name of the EntityType and initalizes the globalEntityIdPool. The method sets the name of the EntityType and if it is called the first time it initializes the globalEntityIdPool.

Parameters:
entName new name of the EntityType


Friends And Related Function Documentation

friend class Entity [friend]

friend class Environment [friend]

friend class SystemCore [friend]

friend class WorldDatabase [friend]

friend class WorldDatabaseCreateEntityEvent [friend]

friend class WorldDatabaseSyncEvent [friend]


Member Data Documentation

bool EntityType::fixed [protected]

boolean flag indicating that the model can't be moved

globalEntityIdPool for EntityType

unsigned short EntityType::id [protected]

ID of the EntityType.

std::vector<Entity*> EntityType::instances [protected]

list of Entity instances of this EntityType

loadTimeEntityIdPool for creation of Entities on startup

localEntityIdPool for creation of new Entities

model used as template for the Entity instances

std::string EntityType::name [protected]

name of the EntityType

std::string EntityType::nameGlobalEntityIdPool [protected]

name of the globalEntityIdPool (set in setName method)


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

Generated on Wed Oct 20 16:11:56 2010 for inVRs by doxygen 1.5.8