Emergency 2017 Dokumentation  v3.0.1
qsf::Entity Class Reference

Entity class. More...

#include <Entity.h>

Public Member Functions

virtual ~Entity ()
 Destructor. More...
 
MapgetMap () const
 Return the map this entity is in. More...
 
bool isSerializable () const
 Return whether or not the entity is serializable. More...
 
void setSerializable (bool serializable)
 Set whether or not the entity is serializable. More...
 
void setActive (bool active) const
 Set whether or not the entity is considered to be active. More...
 
void setDebug (bool debug) const
 Set whether or not the entity is considered to be in debug mode. More...
 
void setHidden (bool hidden) const
 Set whether or not the entity is considered to be hidden. More...
 
void setGloballyHidden (bool globallyHidden) const
 Set whether or not the entity is considered to be globally hidden. More...
 
void startup ()
 Loop through all components of the entity and startup them. More...
 
void shutdown ()
 Loop through all components of the entity and shutdown them. More...
 
bool hasSimulationTransformListeners () const
 Check if there are any simulation transform listeners. More...
 
void registerComponentForSimulationTransformChanges (Component &component)
 Register a component as simulation transform listener. More...
 
void unregisterComponentForSimulationTransformChanges (Component &component)
 Unregister a component as simulation transform listener. More...
 
bool hasAnimationTransformListeners () const
 Check if there are any animation transform listeners. More...
 
void registerComponentForAnimationTransformChanges (Component &component)
 Register a component as animation transform listener. More...
 
void unregisterComponentForAnimationTransformChanges (Component &component)
 Unregister a component as animation transform listener. More...
 
void onComponentTransformChange (TransformComponent &transformComponent, const Transform &transform, uint8 flags)
 React to component transform changes. More...
 
- Public Member Functions inherited from qsf::Prototype
virtual ~Prototype ()
 Destructor. More...
 
uint64 getId () const
 Return the unique prototype identifier. More...
 
BasePrototypeManagergetPrototypeManager () const
 Return the prototype manager this prototype is in. More...
 
ComponentManagergetComponentManager () const
 Return the component manager that's responsible for this component instance. More...
 
void reserveComponents (size_t numberOfComponents)
 Reserve components. More...
 
template<typename T >
T * createComponent (bool startup=true)
 Create an instance of a component of a certain type. More...
 
ComponentcreateComponentById (const StringHash &id, bool startup=true)
 Create an instance of a component by using its unique identifier. More...
 
ComponentcreateComponentByCampClass (const camp::Class &campClass, bool startup=true)
 Create an instance of a component by using a given CAMP reflection class. More...
 
template<typename T >
T * createComponentWithValues (const std::string &values, bool startup=true)
 Create an instance of a component of a certain type and set component property values at once. More...
 
ComponentcreateComponentByIdWithValues (const StringHash &id, const std::string &values, bool startup=true)
 Create an instance of a component by using its unique identifier and set component property values at once. More...
 
ComponentcreateComponentByCampClassWithValues (const camp::Class &campClass, const std::string &values, bool startup=true)
 Create an instance of a component by using a given CAMP reflection class and set component property values at once. More...
 
bool destroyComponent (Component &component)
 Destroy a component instance. More...
 
template<typename T >
bool destroyComponent ()
 Destroy a component instance of a certain type. More...
 
bool destroyComponentById (const StringHash &id)
 Destroy a component instance by using its unique identifier. More...
 
bool destroyComponentByCampClass (const camp::Class &campClass)
 Destroy a component instance by using a given CAMP reflection class. More...
 
void destroyAllComponents ()
 Destroy all components within this prototype. More...
 
template<typename T >
T * getComponent () const
 Return a component instance of a certain type. More...
 
template<typename T >
T & getComponentSafe () const
 Return a component instance of a certain type. More...
 
ComponentgetComponentById (const StringHash &id) const
 Return a component instance pointer by using its unique identifier. More...
 
ComponentgetComponentByCampClass (const camp::Class &campClass) const
 Return a component instance by using a given CAMP reflection class. More...
 
template<typename T >
T * getOrCreateComponent (bool startup=true)
 Return a component instance of a certain type, creates an component instance in case it does not exist. More...
 
ComponentgetOrCreateComponentById (const StringHash &id, bool startup=true)
 Return a component instance by using its unique identifier, creates an component instance in case it does not exist. More...
 
ComponentgetOrCreateComponentByCampClass (const camp::Class &campClass, bool startup=true)
 Return a component instance by using a given CAMP reflection class, creates an component instance in case it does not exist. More...
 
template<typename T >
T & getOrCreateComponentSafe (bool startup=true)
 Return a component instance of a certain type, creates a component instance in case it does not exist. More...
 
ComponentcloneComponent (const Component &sourceComponent, bool startup=true, bool copyOverrideState=false)
 Clone a component from a another one. More...
 
ComponentgetConflictingRegisteredComponent (uint32 componentId) const
 Check whether a component or a conflicting component is registered already, including base classes (except "qsf::Component") More...
 
const std::vector< Component * > & getComponents () const
 Return the component list. More...
 
void setComponentPropertiesToDefaultValues ()
 Set all CAMP reflection system properties of all components to their default values. More...
 
PrototypegetBasePrototype () const
 Return the base prototype this prototype inherits default values for its properties from. More...
 
bool isEntity () const
 Return whether or not this is an entity. More...
 
bool getIgnorePropertyChanges () const
 
void setIgnorePropertyChanges (bool ignorePropertyChanges)
 
void serializeStructure (BinarySerializer &serializer)
 Serialize or deserialize the prototype's list of components (but not their content) using a binary serializer. More...
 
void serializeContent (BinarySerializer &serializer)
 Serialize or deserialize the prototype's components using a binary serializer. More...
 
void cloneComponentsFrom (const Prototype &originalPrototype, bool copyOverrideState)
 Clone all components of another prototype. More...
 
uint8 getComponentChangesCount () const
 
- Public Member Functions inherited from qsf::Object
virtual ~Object ()
 Destructor. More...
 
const camp::Class & getCampClass () const
 Return the CAMP class. More...
 
int getPropertyIndexById (const StringHash &propertyId) const
 Return the CAMP property index by using the unique class property ID. More...
 
uint32 getPropertyIdByIndex (int index) const
 Return the unique class property ID with the given index. More...
 
std::string getPropertyNameById (const StringHash &propertyId) const
 Return the CAMP property name by using the unique class property ID. More...
 
const camp::Property * getCampPropertyById (const StringHash &propertyId) const
 Return the CAMP property by using the unique class property ID. More...
 
void setPropertyValuesByString (const std::string &values)
 Set CAMP reflection property values by using a given string. More...
 
void setPropertiesToDefaultValues ()
 Set all CAMP reflection system properties to their default values. More...
 
void serializeToBoostPTree (boost::property_tree::ptree &pTree, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
void serializeToBoostPTree (boost::property_tree::ptree &pTree, const camp::Class &campClass, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
bool deserializeFromBoostPTree (const boost::property_tree::ptree &pTree, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL)
 
bool deserializeFromBoostPTree (const boost::property_tree::ptree &pTree, const camp::Class &campClass, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL)
 
void serializeToBinarySerializer (BinarySerializer &serializer, SerializationMode mode=MODE_MINIMAL, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
void deserializeFromBinarySerializer (BinarySerializer &serializer, SerializationMode mode=MODE_MINIMAL, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL, bool setOverrideState=true)
 
virtual camp::Value getPropertyDefaultValue (const StringHash &propertyId) const
 
virtual PropertyOverrideState getPropertyOverrideState (const StringHash &propertyId) const
 
virtual bool setPropertyOverrideState (const StringHash &propertyId, PropertyOverrideState overrideState)
 
virtual void onPreDeserialize ()
 Called right before the object is deserialized using any of the above methods. Default implementation is empty. More...
 
virtual void onPostDeserialize ()
 Called right after the object was deserialized using any of the above methods. Default implementation is empty. More...
 
virtual ScriptgetAssociatedScript () const
 Return the script instance associated with this object instance. More...
 

Friends

class Map
 

Additional Inherited Members

- Public Types inherited from qsf::Object
enum  PropertyOverrideState { PROPERTY_INVALID, PROPERTY_DEFAULT, PROPERTY_OVERRIDE, PROPERTY_REMOVED }
 
enum  SerializationMethod { SERIALIZE_FLAT, SERIALIZE_COMPLETE, SERIALIZE_DIFFERENTIAL, SERIALIZE_IGNORE_UNKNOWN }
 
enum  SerializationMode { MODE_MINIMAL, MODE_COMPATIBLE }
 
- Protected Types inherited from qsf::Prototype
enum  Flags { ENTITY = 1<<0, SERIALIZABLE = 1<<1, IGNORE_PROPERTY_CHANGES = 1<<2 }
 Prototype flags. More...
 
typedef BitFlagSet< uint8, FlagsFlagSet
 
typedef std::vector< Component * > ComponentList
 
typedef std::unordered_map< uint32, Component * > ComponentMap
 
- Protected Member Functions inherited from qsf::Prototype
 Prototype (uint64 id, BasePrototypeManager &manager)
 Constructor. More...
 
void registerComponent (Component &component)
 Register the given component. More...
 
void onComponentPropertyChange (Component &component, uint32 propertyId)
 Called in case a component property value was changed. More...
 
void onComponentTransformChange (TransformComponent &transformComponent, const Transform &transform, uint8 flags)
 React to component transform changes. More...
 
- Protected Member Functions inherited from qsf::Object
 Object ()
 Default constructor. More...
 
- Protected Member Functions inherited from qsf::WeakPtrTarget
 WeakPtrTarget ()
 Default constructor. More...
 
 WeakPtrTarget (const WeakPtrTarget &other)
 Copy constructor. More...
 
 WeakPtrTarget (WeakPtrTarget &&)=delete
 Delete the move constructor, as WeakPtrTarget would need a proper move constructor-implementation that ensures that its pointer gets updated in the WeakPtrBase as well. More...
 
 ~WeakPtrTarget ()
 Destructor. More...
 
void invalidateAllWeakPtr ()
 Invalidate all weak pointers to this object. More...
 
void operator= (const WeakPtrTarget &other)
 Copy operator. More...
 
- Protected Attributes inherited from qsf::Prototype
uint64 mId
 The unique prototype identifier inside the associated manager. More...
 
BasePrototypeManagermManager
 The manager this prototype is registered in. More...
 
ComponentList mComponentList
 Component list. More...
 
ComponentMap mComponentMap
 Component map with unique component identifier as key and pointer to the component as value. More...
 
ComponentList mListenerComponents
 List of components that can be listeners to component property changes (see "onComponentPropertyChange") More...
 
FlagSet mFlags
 Internal flags, see "qsf::Prototype::Flags". More...
 
uint8 mComponentChangesCount
 An "counter" which is used to "track" if any changes to the component list (add/remove) where done. More...
 

Detailed Description

Entity class.

Note
  • An entity is a concrete prototype instance
  • Everything within a map is an entity
  • "Objects" are formed by linking entities together

Definition at line 46 of file Entity.h.

Constructor & Destructor Documentation

qsf::Entity::~Entity ( )
inlinevirtual

Destructor.

Note
  • Do never destroy an entity manually, use "qsf::Map::destroyEntityById()" instead

Definition at line 14 of file Entity-inl.h.

Member Function Documentation

Map& qsf::Entity::getMap ( ) const

Return the map this entity is in.

Returns
The map this entity is in, do no destroy the returned instance
bool qsf::Entity::hasAnimationTransformListeners ( ) const
inline

Check if there are any animation transform listeners.

Returns
"true" if there's at least one listener for animation transformation changes

Definition at line 36 of file Entity-inl.h.

bool qsf::Entity::hasSimulationTransformListeners ( ) const
inline

Check if there are any simulation transform listeners.

Returns
"true" if there's at least one listener for simulation transformation changes

Definition at line 31 of file Entity-inl.h.

bool qsf::Entity::isSerializable ( ) const
inline

Return whether or not the entity is serializable.

Returns
"true" if the entity is serializable, else "false"
Note
  • Not connected to the CAMP reflection system by intent, this must be internal only

Definition at line 21 of file Entity-inl.h.

void qsf::Entity::onComponentTransformChange ( TransformComponent transformComponent,
const Transform transform,
uint8  flags 
)

React to component transform changes.

Parameters
[in]transformComponentThe transform component holding the changes transformation
[in]transformThe changed transform
[in]flagsFlags describing the change, see "qsf::Component::TransformChangeFlag"
void qsf::Entity::registerComponentForAnimationTransformChanges ( Component component)

Register a component as animation transform listener.

Parameters
[in]componentThe component to register
Remarks
Registered listeners receive a call to "qsf::Component::onComponentTransformChange()" whenever the entity's animation transformation changes. However, registering is only important in simulating mode (see "qsf::Component::onSetSimulating()"), for otherwise all property change listeners will receive "onComponentTransformChange" callbacks as well.
void qsf::Entity::registerComponentForSimulationTransformChanges ( Component component)

Register a component as simulation transform listener.

Parameters
[in]componentThe component to register
Remarks
Registered listeners receive a call to "qsf::Component::onComponentTransformChange()" whenever the entity's simulation transformation changes. However, registering is only important in simulating mode (see "qsf::Component::onSetSimulating()"), for otherwise all property change listeners will receive "onComponentTransformChange" callbacks as well.
void qsf::Entity::setActive ( bool  active) const

Set whether or not the entity is considered to be active.

Parameters
[in]active"true" if the entity is considered to be active, else "false"
Note
  • Calls "qsf::Component::setActive()" of each component
  • A "qsf::Entity::isActive()" is not possible because each component can have another active state
void qsf::Entity::setDebug ( bool  debug) const

Set whether or not the entity is considered to be in debug mode.

Parameters
[in]debug"true" if the entity is considered to be in debug mode, else "false"
Note
  • Calls "qsf::Component::setDebug()" of each component
  • A "qsf::Entity::isDebug()" is not possible because each component can have another debug mode state
void qsf::Entity::setGloballyHidden ( bool  globallyHidden) const

Set whether or not the entity is considered to be globally hidden.

Parameters
[in]globallyHidden"true" if the entity is considered to be globally hidden, else "false"
Note
  • Calls "qsf::Component::setGloballyHidden()" of each component
  • A "qsf::Entity::isGloballyHidden()" is not possible because each component can have another hidden state
void qsf::Entity::setHidden ( bool  hidden) const

Set whether or not the entity is considered to be hidden.

Parameters
[in]hidden"true" if the entity is considered to be hidden, else "false"
Note
  • Calls "qsf::Component::setHidden()" of each component
  • A "qsf::Entity::isHidden()" is not possible because each component can have another hidden state
void qsf::Entity::setSerializable ( bool  serializable)
inline

Set whether or not the entity is serializable.

Parameters
[in]serializable"true" if the entity is serializable, else "false"
See also
  • "qsf::Entity::isSerializable()"

Definition at line 26 of file Entity-inl.h.

void qsf::Entity::shutdown ( )

Loop through all components of the entity and shutdown them.

Note
  • Do only use this method when you know what you're doing
void qsf::Entity::startup ( )

Loop through all components of the entity and startup them.

Note
  • Do only use this method when you know what you're doing
  • Component startup failures are silently ignored
void qsf::Entity::unregisterComponentForAnimationTransformChanges ( Component component)

Unregister a component as animation transform listener.

Parameters
[in]componentThe component to unregister
void qsf::Entity::unregisterComponentForSimulationTransformChanges ( Component component)

Unregister a component as simulation transform listener.

Parameters
[in]componentThe component to unregister

Friends And Related Function Documentation

friend class Map
friend

Definition at line 53 of file Entity.h.


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