Atlas  0.7.0
Networking protocol for the Worldforge system.
RootEntityChildren.cpp
1 // This file may be redistributed and modified only under the terms of
2 // the GNU Lesser General Public License (See COPYING for details).
3 // Copyright 2000-2001 Stefanus Du Toit and Aloril.
4 // Copyright 2001-2005 Alistair Riddoch.
5 // Copyright 2011-2020 Erik Ogenvik.
6 // Automatically generated using gen_cpp.py. Don't edit directly.
7 
8 #include <Atlas/Objects/Entity.h>
9 
11 using Atlas::Message::MapType;
12 
13 namespace Atlas { namespace Objects { namespace Entity {
14 
15 Allocator<AdminEntityData> AdminEntityData::allocator;
16 
17 
18 
20 {
21  allocator.free(this);
22 }
23 
24 
25 
27 {
29 }
30 
32 {
33  return copyInstance<AdminEntityData>(*this);
34 }
35 
36 bool AdminEntityData::instanceOf(int classNo) const
37 {
38  if(ADMIN_ENTITY_NO == classNo) return true;
39  return RootEntityData::instanceOf(classNo);
40 }
41 
42 void AdminEntityData::fillDefaultObjectInstance(AdminEntityData& data, std::map<std::string, uint32_t>& attr_data)
43 {
44  data.attr_objtype = default_objtype;
45  data.attr_pos.clear();
46  data.attr_pos.push_back(0.0);
47  data.attr_pos.push_back(0.0);
48  data.attr_pos.push_back(0.0);
49  data.attr_velocity.clear();
50  data.attr_velocity.push_back(0.0);
51  data.attr_velocity.push_back(0.0);
52  data.attr_velocity.push_back(0.0);
53  data.attr_stamp_contains = 0.0;
54  data.attr_stamp = 0.0;
55  data.attr_parent = default_parent;
56 }
57 
58 const std::string USERNAME_ATTR = "username";
59 const std::string PASSWORD_ATTR = "password";
60 const std::string CHARACTERS_ATTR = "characters";
61 
62 int AccountData::getAttrClass(const std::string& name) const
63 {
64  if (allocator.attr_flags_Data.find(name) != allocator.attr_flags_Data.end()) {
65  return ACCOUNT_NO;
66  }
67  return AdminEntityData::getAttrClass(name);
68 }
69 
70 bool AccountData::getAttrFlag(const std::string& name, uint32_t& flag) const
71 {
72  auto I = allocator.attr_flags_Data.find(name);
73  if (I != allocator.attr_flags_Data.end()) {
74  flag = I->second;
75  return true;
76  }
77  return AdminEntityData::getAttrFlag(name, flag);
78 }
79 
80 int AccountData::copyAttr(const std::string& name, Element & attr) const
81 {
82  if (name == USERNAME_ATTR) { attr = getUsername(); return 0; }
83  if (name == PASSWORD_ATTR) { attr = getPassword(); return 0; }
84  if (name == CHARACTERS_ATTR) { attr = getCharactersAsList(); return 0; }
85  return AdminEntityData::copyAttr(name, attr);
86 }
87 
88 void AccountData::setAttr(std::string name, Element attr, const Atlas::Objects::Factories* factories)
89 {
90  if (name == USERNAME_ATTR) { setUsername(attr.moveString()); return; }
91  if (name == PASSWORD_ATTR) { setPassword(attr.moveString()); return; }
92  if (name == CHARACTERS_ATTR) { setCharactersAsList(attr.moveList()); return; }
93  AdminEntityData::setAttr(std::move(name), std::move(attr), factories);
94 }
95 
96 void AccountData::removeAttr(const std::string& name)
97 {
98  if (name == USERNAME_ATTR)
99  { m_attrFlags &= ~USERNAME_FLAG; return;}
100  if (name == PASSWORD_ATTR)
101  { m_attrFlags &= ~PASSWORD_FLAG; return;}
102  if (name == CHARACTERS_ATTR)
103  { m_attrFlags &= ~CHARACTERS_FLAG; return;}
105 }
106 
108 {
109  if(m_attrFlags & USERNAME_FLAG) {
110  b.mapStringItem(USERNAME_ATTR, attr_username);
111  }
112 }
113 
115 {
116  if(m_attrFlags & PASSWORD_FLAG) {
117  b.mapStringItem(PASSWORD_ATTR, attr_password);
118  }
119 }
120 
122 {
123  if(m_attrFlags & CHARACTERS_FLAG) {
124  b.mapListItem(CHARACTERS_ATTR);
125  for(const auto& item : attr_characters) {
126  b.listStringItem(item);
127  }
128  b.listEnd();
129  }
130 }
131 
133 {
134  sendUsername(b);
135  sendPassword(b);
136  sendCharacters(b);
138 }
139 
140 void AccountData::addToMessage(MapType & m) const
141 {
143  if(m_attrFlags & USERNAME_FLAG)
144  m[USERNAME_ATTR] = attr_username;
145  if(m_attrFlags & PASSWORD_FLAG)
146  m[PASSWORD_ATTR] = attr_password;
147  if(m_attrFlags & CHARACTERS_FLAG)
148  m[CHARACTERS_ATTR] = getCharactersAsList();
149 }
150 
151 Allocator<AccountData> AccountData::allocator;
152 
153 
154 
156 {
157  allocator.free(this);
158 }
159 
160 
161 
163 {
165 }
166 
168 {
169  return copyInstance<AccountData>(*this);
170 }
171 
172 bool AccountData::instanceOf(int classNo) const
173 {
174  if(ACCOUNT_NO == classNo) return true;
175  return AdminEntityData::instanceOf(classNo);
176 }
177 
178 void AccountData::fillDefaultObjectInstance(AccountData& data, std::map<std::string, uint32_t>& attr_data)
179 {
180  data.attr_objtype = default_objtype;
181  data.attr_pos.clear();
182  data.attr_pos.push_back(0.0);
183  data.attr_pos.push_back(0.0);
184  data.attr_pos.push_back(0.0);
185  data.attr_velocity.clear();
186  data.attr_velocity.push_back(0.0);
187  data.attr_velocity.push_back(0.0);
188  data.attr_velocity.push_back(0.0);
189  data.attr_stamp_contains = 0.0;
190  data.attr_stamp = 0.0;
191  data.attr_parent = default_parent;
192  attr_data[USERNAME_ATTR] = USERNAME_FLAG;
193  attr_data[PASSWORD_ATTR] = PASSWORD_FLAG;
194  attr_data[CHARACTERS_ATTR] = CHARACTERS_FLAG;
195 }
196 
197 Allocator<PlayerData> PlayerData::allocator;
198 
199 
200 
202 {
203  allocator.free(this);
204 }
205 
206 
207 
209 {
211 }
212 
214 {
215  return copyInstance<PlayerData>(*this);
216 }
217 
218 bool PlayerData::instanceOf(int classNo) const
219 {
220  if(PLAYER_NO == classNo) return true;
221  return AccountData::instanceOf(classNo);
222 }
223 
224 void PlayerData::fillDefaultObjectInstance(PlayerData& data, std::map<std::string, uint32_t>& attr_data)
225 {
226  data.attr_objtype = default_objtype;
227  data.attr_pos.clear();
228  data.attr_pos.push_back(0.0);
229  data.attr_pos.push_back(0.0);
230  data.attr_pos.push_back(0.0);
231  data.attr_velocity.clear();
232  data.attr_velocity.push_back(0.0);
233  data.attr_velocity.push_back(0.0);
234  data.attr_velocity.push_back(0.0);
235  data.attr_stamp_contains = 0.0;
236  data.attr_stamp = 0.0;
237  data.attr_parent = default_parent;
238 }
239 
240 Allocator<AdminData> AdminData::allocator;
241 
242 
243 
245 {
246  allocator.free(this);
247 }
248 
249 
250 
252 {
254 }
255 
257 {
258  return copyInstance<AdminData>(*this);
259 }
260 
261 bool AdminData::instanceOf(int classNo) const
262 {
263  if(ADMIN_NO == classNo) return true;
264  return AccountData::instanceOf(classNo);
265 }
266 
267 void AdminData::fillDefaultObjectInstance(AdminData& data, std::map<std::string, uint32_t>& attr_data)
268 {
269  data.attr_objtype = default_objtype;
270  data.attr_pos.clear();
271  data.attr_pos.push_back(0.0);
272  data.attr_pos.push_back(0.0);
273  data.attr_pos.push_back(0.0);
274  data.attr_velocity.clear();
275  data.attr_velocity.push_back(0.0);
276  data.attr_velocity.push_back(0.0);
277  data.attr_velocity.push_back(0.0);
278  data.attr_stamp_contains = 0.0;
279  data.attr_stamp = 0.0;
280  data.attr_parent = default_parent;
281 }
282 
283 Allocator<GameData> GameData::allocator;
284 
285 
286 
288 {
289  allocator.free(this);
290 }
291 
292 
293 
295 {
297 }
298 
300 {
301  return copyInstance<GameData>(*this);
302 }
303 
304 bool GameData::instanceOf(int classNo) const
305 {
306  if(GAME_NO == classNo) return true;
307  return AdminEntityData::instanceOf(classNo);
308 }
309 
310 void GameData::fillDefaultObjectInstance(GameData& data, std::map<std::string, uint32_t>& attr_data)
311 {
312  data.attr_objtype = default_objtype;
313  data.attr_pos.clear();
314  data.attr_pos.push_back(0.0);
315  data.attr_pos.push_back(0.0);
316  data.attr_pos.push_back(0.0);
317  data.attr_velocity.clear();
318  data.attr_velocity.push_back(0.0);
319  data.attr_velocity.push_back(0.0);
320  data.attr_velocity.push_back(0.0);
321  data.attr_stamp_contains = 0.0;
322  data.attr_stamp = 0.0;
323  data.attr_parent = default_parent;
324 }
325 
326 Allocator<GameEntityData> GameEntityData::allocator;
327 
328 
329 
331 {
332  allocator.free(this);
333 }
334 
335 
336 
338 {
340 }
341 
343 {
344  return copyInstance<GameEntityData>(*this);
345 }
346 
347 bool GameEntityData::instanceOf(int classNo) const
348 {
349  if(GAME_ENTITY_NO == classNo) return true;
350  return RootEntityData::instanceOf(classNo);
351 }
352 
353 void GameEntityData::fillDefaultObjectInstance(GameEntityData& data, std::map<std::string, uint32_t>& attr_data)
354 {
355  data.attr_objtype = default_objtype;
356  data.attr_pos.clear();
357  data.attr_pos.push_back(0.0);
358  data.attr_pos.push_back(0.0);
359  data.attr_pos.push_back(0.0);
360  data.attr_velocity.clear();
361  data.attr_velocity.push_back(0.0);
362  data.attr_velocity.push_back(0.0);
363  data.attr_velocity.push_back(0.0);
364  data.attr_stamp_contains = 0.0;
365  data.attr_stamp = 0.0;
366  data.attr_parent = default_parent;
367 }
368 
369 } } } // namespace Atlas::Objects::Entity
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
std::string attr_parent
The object this inherits attributes from.
Definition: Root.h:125
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void reset() override
Resets the object as it&#39;s returned to the pool.
Definition: RootEntity.cpp:157
bool instanceOf(int classNo) const override
Is this instance of some class?
void setAttr(std::string name, Atlas::Message::Element attr, const Atlas::Objects::Factories *factories=nullptr) override
Set the attribute "name" to the value given by"attr".
std::string attr_objtype
What kind of object this is.
Definition: Root.h:129
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
Definition: RootEntity.cpp:29
std::vector< double > attr_velocity
Velocity object is moving, usually world is 3D.
Definition: RootEntity.h:136
ListType && moveList()
Definition: Element.h:559
bool instanceOf(int classNo) const override
Is this instance of some class?
StringType && moveString()
Definition: Element.h:493
bool instanceOf(int classNo) const override
Is this instance of some class?
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
Definition: RootEntity.cpp:21
AccountData * copy() const override
Copy this object.
void reset() override
Resets the object as it&#39;s returned to the pool.
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
Definition: RootEntity.cpp:59
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
Definition: RootEntity.cpp:131
void reset() override
Resets the object as it&#39;s returned to the pool.
void free() override
Free an instance of this class, returning it to the memory pool.
AdminEntityData * copy() const override
Copy this object.
GameData * copy() const override
Copy this object.
AdminData * copy() const override
Copy this object.
virtual void mapListItem(std::string name)=0
bool instanceOf(int classNo) const override
Is this instance of some class?
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
void reset() override
Resets the object as it&#39;s returned to the pool.
void free() override
Free an instance of this class, returning it to the memory pool.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
virtual void mapStringItem(std::string name, std::string)=0
void setAttr(std::string name, Atlas::Message::Element attr, const Atlas::Objects::Factories *factories=nullptr) override
Set the attribute "name" to the value given by"attr".
Definition: RootEntity.cpp:49
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
Definition: RootEntity.cpp:39
void free() override
Free an instance of this class, returning it to the memory pool.
bool instanceOf(int classNo) const override
Is this instance of some class?
Definition: RootEntity.cpp:167
void free() override
Free an instance of this class, returning it to the memory pool.
void sendCharacters(Atlas::Bridge &) const
Send the "characters" attribute to an Atlas::Bridge.
All classes and objects used for administrative purposes.
Definition: Entity.h:32
PlayerData * copy() const override
Copy this object.
void sendPassword(Atlas::Bridge &) const
Send the "password" attribute to an Atlas::Bridge.
std::vector< double > attr_pos
Position coordinates, usually world is 3D.
Definition: RootEntity.h:134
void reset() override
Resets the object as it&#39;s returned to the pool.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
void free() override
Free an instance of this class, returning it to the memory pool.
bool instanceOf(int classNo) const override
Is this instance of some class?
virtual void listStringItem(std::string)=0
virtual void listEnd()=0
GameEntityData * copy() const override
Copy this object.
Privileged accounts.
Definition: Entity.h:385
All In Game classes and objects.
Definition: Entity.h:499
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
Definition: RootEntity.cpp:121
Base class for accounts.
Definition: Entity.h:89
Games this server hosts.
Definition: Entity.h:442
double attr_stamp
Last time this object was modified.
Definition: Root.h:127
void reset() override
Resets the object as it&#39;s returned to the pool.
void free() override
Free an instance of this class, returning it to the memory pool.
Definition: Bridge.h:20
void sendUsername(Atlas::Bridge &) const
Send the "username" attribute to an Atlas::Bridge.
void reset() override
Resets the object as it&#39;s returned to the pool.
double attr_stamp_contains
Last time any object that uses this as reference recursively has been modified.
Definition: RootEntity.h:140
bool instanceOf(int classNo) const override
Is this instance of some class?