Game Develop Core: gd::ClassWithObjects 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 | Protected Attributes | List of all members
gd::ClassWithObjects Class Reference
Platform Definition ( Classes defining the common concepts used by all platforms )

Used as a base class for classes that will own objects (see gd::Object). More...

`#include <ClassWithObjects.h>`

Inheritance diagram for gd::ClassWithObjects:
[legend]

## Public Member Functions

| ClassWithObjects ()
| Default constructor creating a container without any objects.
Objects management
Members functions related to objects management.
bool | HasObjectNamed (const std::string &name) const
| Return true if object called name exists.
Object & | GetObject (const std::string &name)
| Return a reference to the object called name.
const gd::Object & | GetObject (const std::string &name) const
| Return a reference to the object called name.
Object & | GetObject (unsigned int index)
| Return a reference to the object at position index in the objects list.
const gd::Object & | GetObject (unsigned int index) const
| Return a reference to the object at position index in the objects list.
unsigned int | GetObjectPosition (const std::string &name) const
| Return the position of the object called name in the objects list. More...
unsigned int | GetObjectsCount () const
| Return the number of object.
void | InsertNewObject (gd::Project &project, const std::string &objectType, const std::string &name, unsigned int position)
| Add a new empty object of type objectType called name at the specified position in the layout list. More...
void | InsertObject (const gd::Object &object, unsigned int position)
| Must add a new object constructed from the layout passed as parameter. More...
void | RemoveObject (const std::string &name)
| Delete an object. More...
void | SwapObjects (unsigned int firstObjectIndex, unsigned int secondObjectIndex)
| Swap the position of the specified objects.
std::vector< boost::shared_ptr < gd::Object > > & | GetObjects ()
const std::vector < boost::shared_ptr < gd::Object > > & | GetObjects () const
Saving and loading
Members functions related to saving and loading the project.
void | SaveObjectsToXml (TiXmlElement *element) const
| Save the objects to xml.
void | LoadObjectsFromXml (gd::Project &project, const TiXmlElement *element)
| Load the objects from xml.

## Protected Attributes

std::vector< boost::shared_ptr < gd::Object > > | initialObjects
| Objects contained.

## Detailed Description

Used as a base class for classes that will own objects (see gd::Object).

For example, gd::Project inherits from this class as it have global objects.
gd::Layout also inherits from this class as each layout has specific objects.

See Also
  gd::Project
  gd::Layout
  gd::Object

## Member Function Documentation

unsigned int gd::ClassWithObjects::GetObjectPosition | ( | const std::string & | name) |  | const

Return the position of the object called name in the objects list.

Warning
  This has nothing to do with an object position on a layout. Objects put on layouts are represented thanks to the gd::InitialInstance class.

std::vector< boost::shared_ptr<gd::Object> >& gd::ClassWithObjects::GetObjects | ( | ) |  |

inline

Provide a raw access to the vector containing the objects

const std::vector< boost::shared_ptr<gd::Object> >& gd::ClassWithObjects::GetObjects | ( | ) |  | const

inline

Provide a raw access to the vector containing the objects

void gd::ClassWithObjects::InsertNewObject | ( | gd::Project & | project,
|  | const std::string & | objectType,
|  | const std::string & | name,
|  | unsigned int | position
| ) |  |

Add a new empty object of type objectType called name at the specified position in the layout list.

Note
  The object is created using the project's current platform.

void gd::ClassWithObjects::InsertObject | ( | const gd::Object & | object,
|  | unsigned int | position
| ) |  |

Must add a new object constructed from the layout passed as parameter.

Note
  No pointer or reference must be kept on the object passed as parameter.

Parameters

  object | The object that must be copied and inserted into the project
  position | Insertion position. If the position is invalid, the object is inserted at the end of the objects list.

void gd::ClassWithObjects::RemoveObject | ( | const std::string & | name) |  |

Delete an object.

Parameters

  name | The name of the object to be deleted.

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

- ClassWithObjects.h
- ClassWithObjects.cpp