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

Layer class. More...

#include <Layer.h>

Public Types

typedef std::unordered_set< uint64EntityIdSet
 
- 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 }
 

Public Member Functions

 ~Layer ()
 Destructor. More...
 
LayerManagergetLayerManager () const
 Return the owner layer manager. More...
 
LayergetParentLayer () const
 Get the parent layer the layer is in. More...
 
void setParentLayer (Layer &layer)
 Set the parent layer the layer is in. More...
 
uint32 getId () const
 Return the unique layer identifier. More...
 
const std::string & getName () const
 Return the layer name. More...
 
uint32 getNameHash () const
 Return the layer name's hash value. More...
 
void setName (const std::string &name)
 Set the layer name. More...
 
bool getLoadInGame () const
 Return whether or not the layer is loaded at game startup. More...
 
bool getLoadInGameRecursive () const
 Return whether or not the layer is loaded at game startup. More...
 
void setLoadInGame (bool loadInGame)
 Set whether or not the layer is loaded at game startup. More...
 
void copyPropertiesFromLayer (const Layer &layer)
 Copy properties from another layer into this layer. More...
 
bool isHidden () const
 Return whether or not the layer is hidden. More...
 
void setHidden (bool hidden)
 Set whether or not the layer is hidden. More...
 
bool isGloballyHidden () const
 Return whether or not the layer is globally hidden. More...
 
LayercreateLayer ()
 Create a new layer. More...
 
LayercreateLayerWithId (uint32 id)
 Create a new layer instance with an enforced given unique layer identifier. More...
 
bool destroyLayerById (uint32 id)
 Destroy a layer instance by using its unique identifier. More...
 
void destroyAllLayers ()
 Destroy all layers within this layer. More...
 
const std::vector< Layer * > & getLayers () const
 Return the layer list. More...
 
void getLayersRecursive (std::vector< Layer * > &layers) const
 Return a list of layers and its child layers. More...
 
void reserveEntities (size_t numberOfEntities)
 Reserve entities. More...
 
bool registerEntityById (uint64 id)
 Register an entity inside this layer by using the ID of the entity. More...
 
bool registerEntitiesById (const EntityIdSet &ids)
 Register entities inside this layer by using the IDs of the entities. More...
 
void registerEntityByMetadataComponent (MetadataComponent &metadataComponent)
 Register an entity inside this layer by using the metadata component of the entity. More...
 
const EntityIdSetgetEntityIds () const
 Return the list of IDs of the entities registered inside this layer. More...
 
void unsafeSetEntityIds (const EntityIdSet &ids)
 For internal purposes only: Set entity ID set directly. More...
 
void getEntityIdsRecursive (EntityIdSet &entityIds) const
 Return a list of IDs of the entities registered inside this layer and its child layers. More...
 
MapgetInternalBufferMap ()
 Get or create the internal buffer map for unloaded entities. More...
 
const MapgetInternalBufferMap () const
 
bool isActive () const
 Return whether this layer is activated. More...
 
void activateLayer ()
 Activate the layer. More...
 
void deactivateLayer (bool copyIntoBufferMap=false)
 Deactivate the layer. More...
 
- 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...
 

Static Public Attributes

static const uint32 NAME
 "Name" unique class property ID inside the class More...
 
static const uint32 LOAD_IN_GAME
 "LoadInGame" unique class property ID inside the class More...
 

Friends

class LayerManager
 
class MetadataComponent
 

Additional Inherited Members

- Protected Member Functions inherited from qsf::Object
 Object ()
 Default constructor. More...
 

Detailed Description

Layer class.

Note
  • The metadata component automatically registers/unregisters the owner entity within the correct layer
  • Entities without a metadata component are not registered inside any layer, this should be an exception
  • Destroying a layer is a brutal act: All registered entities are now inside no layer; it's up to the user of the layers to e.g. move the entities to another layer or destroying the entities before destroying the layer
  • Derived from "qsf::Object" by intent in order to make it easier to do certain implementations inside the QSF editor
Todo:
  • TODO(fw): The buffer map mechanism could be optimized; this map has a layer manager with three layers, which is pretty useless

Definition at line 55 of file Layer.h.

Member Typedef Documentation

typedef std::unordered_set<uint64> qsf::Layer::EntityIdSet

Definition at line 72 of file Layer.h.

Constructor & Destructor Documentation

qsf::Layer::~Layer ( )

Destructor.

Note
  • Do never destroy a layer manually, use "qsf::Layer::destroyLayerById()" instead
  • All registered entities are now inside no layer
  • Not virtual by intent

Member Function Documentation

void qsf::Layer::activateLayer ( )

Activate the layer.

Remarks
Activating a layer will instantiate the layer's entities into the map
void qsf::Layer::copyPropertiesFromLayer ( const Layer layer)

Copy properties from another layer into this layer.

Parameters
[in]layerLayer to copy the properties from
Note
  • This is only about serialized and hence none local properties
Layer* qsf::Layer::createLayer ( )

Create a new layer.

Returns
The created layer, null pointer on error, do not destroy the instance and do need keep a reference to it outside the C runtime stack (use the unique layer ID instead)
Layer* qsf::Layer::createLayerWithId ( uint32  id)

Create a new layer instance with an enforced given unique layer identifier.

Parameters
[in]idThe unique (inside the layer manager the layer is in) layer identifier
Returns
The created layer instance, null pointer on error (e.g. ID already used), do no destroy the returned instance and do need keep a reference to it outside the C runtime stack (use the unique layer ID instead)
Note
  • Use "createLayer()" instead of "createLayerWithId()" whenever possible, do not enforce unique layer identifier if you can avoid it
void qsf::Layer::deactivateLayer ( bool  copyIntoBufferMap = false)

Deactivate the layer.

Parameters
[in]copyIntoBufferMapIf "true", the layer's current entities are copied into the internal map buffer as a backup, overwriting the existing buffer map's contents
void qsf::Layer::destroyAllLayers ( )

Destroy all layers within this layer.

Note
  • All registered entities of the destroyed layers are now inside no layer
bool qsf::Layer::destroyLayerById ( uint32  id)

Destroy a layer instance by using its unique identifier.

Parameters
[in]idThe unique (inside the layer manager the layer is in) layer identifier
Returns
"true" if all went fine, else "false" (unknown layer identifier? invincible base layer which has the ID 0?)
Note
  • All registered entities of the destroyed layer are now inside no layer
const Layer::EntityIdSet & qsf::Layer::getEntityIds ( ) const
inline

Return the list of IDs of the entities registered inside this layer.

Returns
Reference to the internal list of IDs of the entities registered inside this layer, do not manipulate the list

Definition at line 80 of file Layer-inl.h.

void qsf::Layer::getEntityIdsRecursive ( EntityIdSet entityIds) const

Return a list of IDs of the entities registered inside this layer and its child layers.

Parameters
[out]entityIdsReference to the list which will receive the IDs of the entities registered inside this layer and its child layers, list is not cleared before adding new IDs
Note
  • Ease-of-use method
uint32 qsf::Layer::getId ( ) const
inline

Return the unique layer identifier.

Returns
The unique layer identifier, the base layer has ID 0
Note
  • Connected to the CAMP reflection system

Definition at line 32 of file Layer-inl.h.

Map& qsf::Layer::getInternalBufferMap ( )

Get or create the internal buffer map for unloaded entities.

Returns
The buffer map instance
const Map& qsf::Layer::getInternalBufferMap ( ) const
LayerManager & qsf::Layer::getLayerManager ( ) const
inline

Return the owner layer manager.

Returns
The owner layer manager, do not destroy the instance

Definition at line 20 of file Layer-inl.h.

const std::vector< Layer * > & qsf::Layer::getLayers ( ) const
inline

Return the layer list.

Returns
Reference to the internal layer list, do not manipulate the list or destroy the layers

Definition at line 70 of file Layer-inl.h.

void qsf::Layer::getLayersRecursive ( std::vector< Layer * > &  layers) const

Return a list of layers and its child layers.

Parameters
[out]layersReference to the layer list which will receive the layers and its child layers, do not destroy the layer instances
Note
  • Ease-of-use method
bool qsf::Layer::getLoadInGame ( ) const
inline

Return whether or not the layer is loaded at game startup.

Returns
"true" if the layer will be flagged to be loaded in the game, else "false"

Definition at line 52 of file Layer-inl.h.

bool qsf::Layer::getLoadInGameRecursive ( ) const

Return whether or not the layer is loaded at game startup.

Returns
"true" if the layer will be flagged to be loaded in the game, else "false"
const std::string & qsf::Layer::getName ( ) const
inline

Return the layer name.

Returns
The not unique layer name
Note
  • Connected to the CAMP reflection system

Definition at line 37 of file Layer-inl.h.

uint32 qsf::Layer::getNameHash ( ) const
inline

Return the layer name's hash value.

Returns
The not unique layer name hash

Definition at line 42 of file Layer-inl.h.

Layer * qsf::Layer::getParentLayer ( ) const
inline

Get the parent layer the layer is in.

Returns
The parent layer the layer is in, null pointer if there's no parent (meaning this layer is the root)

Definition at line 27 of file Layer-inl.h.

bool qsf::Layer::isActive ( ) const
inline

Return whether this layer is activated.

Returns
"true" if this layer was activated, "false" otherwise
Remarks
By default, a layer is always active

Definition at line 90 of file Layer-inl.h.

bool qsf::Layer::isGloballyHidden ( ) const

Return whether or not the layer is globally hidden.

Returns
"true" if the layer is globally hidden, else "false"
Remarks
Even in case a layer is not hidden, it might be globally hidden because the parent layer is hidden.
Note
  • Not connected to the CAMP reflection system by intent
bool qsf::Layer::isHidden ( ) const
inline

Return whether or not the layer is hidden.

Returns
"true" if the layer is hidden, else "false"
Remarks
"Hidden" is a passive special layer feature. While the content of hidden layers is identical to the content of not hidden layers, the content of hidden layers will not be visible inside the render viewport. This special property will not be serialized and e.g. inside the QSF editor will have no influence on the layer hidden state of other QSF editor users.
Note
  • Not connected to the CAMP reflection system by intent

Definition at line 65 of file Layer-inl.h.

bool qsf::Layer::registerEntitiesById ( const EntityIdSet ids)

Register entities inside this layer by using the IDs of the entities.

Parameters
[in]idsIDs of the entities to register inside this layer
Returns
"true" if all went fine, else "false" (at least a single invalid entity ID?)
See also
  • "qsf::Layer::registerEntityById()"
Note
  • Ease-of-use method
bool qsf::Layer::registerEntityById ( uint64  id)

Register an entity inside this layer by using the ID of the entity.

Parameters
[in]idID of the entity to register inside this layer
Returns
"true" if all went fine, else "false" (invalid entity ID?)
Remarks
There's no public "qsf::Layer::unregisterEntityById()" method by intent, entities with metadata components must always be inside a layer. Register an entity inside the base layer which has the ID 0 in order to unregister it from another layer. It's no error when the given entity is already registered inside this layer, hence the method will return "true". The entity is automatically unregistered from the previous layer before it's registered inside the new layer.
Note
  • In case the given entity ID is valid, this method automatically creates a metadata component in case there's no instance, yet
void qsf::Layer::registerEntityByMetadataComponent ( MetadataComponent metadataComponent)

Register an entity inside this layer by using the metadata component of the entity.

Parameters
[in]metadataComponentMetadata component of the entity to register inside this layer
Note
  • Use "qsf::Layer::registerEntityById()" instead of "qsf::Layer::registerEntityByMetadataComponent()" whenever possible
See also
  • "qsf::Layer::registerEntityById()" for details
void qsf::Layer::reserveEntities ( size_t  numberOfEntities)
inline

Reserve entities.

Parameters
[in]numberOfEntitiesNumber of entities to reserve
Note
  • You might want to reserve entities before starting an insertion of entity masses (performance)

Definition at line 75 of file Layer-inl.h.

void qsf::Layer::setHidden ( bool  hidden)

Set whether or not the layer is hidden.

Parameters
[in]hidden"true" if the layer is hidden, else "false"
See also
  • "qsf::Layer::isHidden()"
void qsf::Layer::setLoadInGame ( bool  loadInGame)
inline

Set whether or not the layer is loaded at game startup.

Parameters
[in]loadInGame"true" if the layer is flagged to be loaded in the game, else "false"

Definition at line 57 of file Layer-inl.h.

void qsf::Layer::setName ( const std::string &  name)
inline

Set the layer name.

Parameters
[in]nameThe not unique layer name
Note
  • Connected to the CAMP reflection system

Definition at line 47 of file Layer-inl.h.

void qsf::Layer::setParentLayer ( Layer layer)

Set the parent layer the layer is in.

Parameters
[in]layerNew parent layer
Note
  • Please note that changing the parent of the root layer is not allowed, such requests will be ignored
void qsf::Layer::unsafeSetEntityIds ( const EntityIdSet ids)
inline

For internal purposes only: Set entity ID set directly.

Parameters
[in]idsIDs of the entities to register inside this layer
Note
  • Lookout! This method is for internal purposes only, do not use it if you don't know what this is about.
  • Can be used e.g. for internal temporary layers (handy e.g. inside the editor)

Definition at line 85 of file Layer-inl.h.

Friends And Related Function Documentation

friend class LayerManager
friend

Definition at line 62 of file Layer.h.

friend class MetadataComponent
friend

Definition at line 63 of file Layer.h.

Member Data Documentation

const uint32 qsf::Layer::LOAD_IN_GAME
static

"LoadInGame" unique class property ID inside the class

Definition at line 71 of file Layer.h.

const uint32 qsf::Layer::NAME
static

"Name" unique class property ID inside the class

Definition at line 70 of file Layer.h.


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