Game Develop Core: ClassWithObjects.h Source File

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

- Main Page
- Modules
- Classes

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
ClassWithObjects.h
Go to the documentation of this file.
1
5 #ifndef GDCORE_CLASSWITHOBJECTS_H
6 #define GDCORE_CLASSWITHOBJECTS_H
7 #include <string>
8 #include <vector>
9 #include <boost/shared_ptr.hpp>
10 namespace gd { class Object; }
11 namespace gd { class Project; }
12 class TiXmlElement;
13 #undef GetObject //Disable an annoying macro
14
15 namespace gd
16 {
17
30 class GD_CORE_API ClassWithObjects
31 {
32 public:
36 ClassWithObjects();
37 virtual ~ClassWithObjects() {};
38
42
47 bool HasObjectNamed(const std::string & name) const;
48
52 Object & GetObject(const std::string & name);
53
57 const gd::Object & GetObject(const std::string & name) const;
58
62 Object & GetObject(unsigned int index);
63
67 const gd::Object & GetObject (unsigned int index) const;
68
75 unsigned int GetObjectPosition(const std::string & name) const;
76
80 unsigned int GetObjectsCount() const;
81
82 #if defined(GD_IDE_ONLY)
83
88 void InsertNewObject(gd::Project & project, const std::string & objectType, const std::string & name, unsigned int position);
89 #endif
90
97 void InsertObject(const gd::Object & object, unsigned int position);
98
103 void RemoveObject(const std::string & name);
104
108 void SwapObjects(unsigned int firstObjectIndex, unsigned int secondObjectIndex);
109
113 std::vector < boost::shared_ptr<gd::Object> > & GetObjects() { return initialObjects; }
114
118 const std::vector < boost::shared_ptr<gd::Object> > & GetObjects() const { return initialObjects; }
120
124
128 void SaveObjectsToXml(TiXmlElement * element) const;
129
133 void LoadObjectsFromXml(gd::Project & project, const TiXmlElement * element);
135
136 protected:
137 std::vector < boost::shared_ptr<gd::Object> > initialObjects;
138 };
139
140 }
141
142 #endif // GDCORE_CLASSWITHOBJECTS_H