Game Develop Core: gd::InitialInstancesContainer Class Reference

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- Class List
- Class Index
- Class Hierarchy

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
Public Member Functions | List of all members
gd::InitialInstancesContainer Class Reference

Defines a container of gd::InitialInstances. More...

`#include <InitialInstancesContainer.h>`

## Public Member Functions

InitialInstancesContainer * | Clone () const
| Return a pointer to a copy of the container. A such method is needed as the IDE may want to store copies of some containers and so need a way to do polymorphic copies. More...
void | Create (const InitialInstancesContainer &source)
Instances management
Members functions related to managing the instances
unsigned int | GetInstancesCount () const
| Return the number of instances.
void | IterateOverInstances (InitialInstanceFunctor &func)
| Apply func to each instance of the container. More...
void | IterateOverInstancesWithZOrdering (InitialInstanceFunctor &func, const std::string &layer)
InitialInstance & | InsertInitialInstance (const InitialInstance &instance)
| Insert the specified instance into the list and return a a reference to the newly added instance.
InitialInstance & | InsertNewInitialInstance ()
| Insert a new blank instance at the end of the list and return a a reference to the newly added instance.
void | RemoveInstance (const gd::InitialInstance &instance)
| Remove the specified instance.
void | RemoveAllInstancesOnLayer (const std::string &layerName)
| Remove all instances from layer layerName.
void | MoveInstancesToLayer (const std::string &fromLayer, const std::string &toLayer)
| Move the instances on layer fromLayer to layer toLayer.
void | RemoveInitialInstancesOfObject (const std::string &objectName)
| Remove instances of object named objectName.
void | RenameInstancesOfObject (const std::string &oldName, const std::string &newName)
| Change instances with object's name oldName to newName.
bool | SomeInstancesAreOnLayer (const std::string &layerName)
| Return true if there is at least one instance on the layer named layerName.
Saving and loading
Members functions related to saving and loading the object.
void | SaveToXml (TiXmlElement *element) const
| Save the instances to a TiXmlElement.
void | LoadFromXml (const TiXmlElement *element)
| Load the instances from a TiXmlElement.

## Detailed Description

Defines a container of gd::InitialInstances.

The container is notably able to ensure that pointers to the elements of the container are not invalidated when a change occurs ( through InsertNewInitialInstance or RemoveInstance for example ).
Thus, the implementations uses a std::list for holding the instances. In this way, the container is not required to provide a direct access to element based on an index. Instead, the method IterateOverInstances is used to perform operations.

## Member Function Documentation

InitialInstancesContainer* gd::InitialInstancesContainer::Clone | ( | ) |  | const

inline

Return a pointer to a copy of the container. A such method is needed as the IDE may want to store copies of some containers and so need a way to do polymorphic copies.

Typical implementation example:

return new MyContainer(*this);

void gd::InitialInstancesContainer::Create | ( | const InitialInstancesContainer & | source) |  |

Must construct the class from the source A such method is needed as the IDE may want to store copies of some containers and so need a way to do polymorphic copies.

Typical implementation example:

try
{
const MyContainer & castedSource = dynamic_cast<const MyContainer&>(source);
operator=(castedSource);
}
catch(...) { std::cout << "WARNING: Tried to create a MyContainer object from an object which is not a MyContainer"; }

void gd::InitialInstancesContainer::IterateOverInstances | ( | gd::InitialInstanceFunctor & | func) |  |

Apply func to each instance of the container.

See Also
  InitialInstanceFunctor

void gd::InitialInstancesContainer::IterateOverInstancesWithZOrdering | ( | gd::InitialInstanceFunctor & | func,
|  | const std::string & | layer
| ) |  |

Get the instances on the specified layer, sort them regarding their Z order and then apply func on them.

Parameters

  func | The functor to be applied.
  layer | The layer

See Also
  InitialInstanceFunctor

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

- InitialInstancesContainer.h
- InitialInstancesContainer.cpp