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
11using Atlas::Message::MapType;
12
13namespace Atlas { namespace Objects { namespace Entity {
14
15Allocator<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
36bool AdminEntityData::instanceOf(int classNo) const
37{
38 if(ADMIN_ENTITY_NO == classNo) return true;
39 return RootEntityData::instanceOf(classNo);
40}
41
42void 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
58const std::string USERNAME_ATTR = "username";
59const std::string PASSWORD_ATTR = "password";
60const std::string CHARACTERS_ATTR = "characters";
61
62int 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 }
68}
69
70bool 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
80int 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
88void 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
96void 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);
138}
139
140void 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
151Allocator<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
172bool AccountData::instanceOf(int classNo) const
173{
174 if(ACCOUNT_NO == classNo) return true;
175 return AdminEntityData::instanceOf(classNo);
176}
177
178void 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
197Allocator<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
218bool PlayerData::instanceOf(int classNo) const
219{
220 if(PLAYER_NO == classNo) return true;
221 return AccountData::instanceOf(classNo);
222}
223
224void 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
240Allocator<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
261bool AdminData::instanceOf(int classNo) const
262{
263 if(ADMIN_NO == classNo) return true;
264 return AccountData::instanceOf(classNo);
265}
266
267void 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
283Allocator<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
304bool GameData::instanceOf(int classNo) const
305{
306 if(GAME_NO == classNo) return true;
307 return AdminEntityData::instanceOf(classNo);
308}
309
310void 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
326Allocator<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
347bool GameEntityData::instanceOf(int classNo) const
348{
349 if(GAME_ENTITY_NO == classNo) return true;
350 return RootEntityData::instanceOf(classNo);
351}
352
353void 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
StringType && moveString()
Definition: Element.h:467
ListType && moveList()
Definition: Element.h:533
Base class for accounts.
Definition: Entity.h:90
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
const std::string & getPassword() const
Retrieve the "password" attribute.
Definition: Entity.h:256
void sendUsername(Atlas::Bridge &) const
Send the "username" attribute to an Atlas::Bridge.
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.
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void setCharactersAsList(const Atlas::Message::ListType &val)
Set the "characters" attribute AsList.
Definition: Entity.h:230
void reset() override
Resets the object as it's returned to the pool.
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
Atlas::Message::ListType getCharactersAsList() const
Retrieve the "characters" attribute AsList.
Definition: Entity.h:286
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
std::string attr_password
Password for account usually.
Definition: Entity.h:168
std::string attr_username
Username for account usually.
Definition: Entity.h:166
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
std::vector< std::string > attr_characters
List of characters account can control.
Definition: Entity.h:170
void setUsername(std::string val)
Set the "username" attribute.
Definition: Entity.h:208
bool instanceOf(int classNo) const override
Is this instance of some class?
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
const std::string & getUsername() const
Retrieve the "username" attribute.
Definition: Entity.h:241
void setPassword(std::string val)
Set the "password" attribute.
Definition: Entity.h:216
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".
void sendPassword(Atlas::Bridge &) const
Send the "password" attribute to an Atlas::Bridge.
AccountData * copy() const override
Copy this object.
Privileged accounts.
Definition: Entity.h:386
void free() override
Free an instance of this class, returning it to the memory pool.
void reset() override
Resets the object as it's returned to the pool.
AdminData * copy() const override
Copy this object.
bool instanceOf(int classNo) const override
Is this instance of some class?
All classes and objects used for administrative purposes.
Definition: Entity.h:33
void reset() override
Resets the object as it'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.
bool instanceOf(int classNo) const override
Is this instance of some class?
Games this server hosts.
Definition: Entity.h:443
bool instanceOf(int classNo) const override
Is this instance of some class?
GameData * copy() const override
Copy this object.
void reset() override
Resets the object as it's returned to the pool.
void free() override
Free an instance of this class, returning it to the memory pool.
All In Game classes and objects.
Definition: Entity.h:500
void reset() override
Resets the object as it's returned to the pool.
GameEntityData * copy() const override
Copy this object.
bool instanceOf(int classNo) const override
Is this instance of some class?
void free() override
Free an instance of this class, returning it to the memory pool.
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?
void reset() override
Resets the object as it's returned to the pool.
PlayerData * copy() const override
Copy this object.
void reset() override
Resets the object as it's returned to the pool.
Definition: RootEntity.cpp:157
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
Definition: RootEntity.cpp:131
bool instanceOf(int classNo) const override
Is this instance of some class?
Definition: RootEntity.cpp:167
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
Definition: RootEntity.cpp:29
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
Definition: RootEntity.cpp:39
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
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
Definition: RootEntity.cpp:121
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
Definition: RootEntity.cpp:21
std::vector< double > attr_pos
Position coordinates, usually world is 3D.
Definition: RootEntity.h:134
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
Definition: RootEntity.cpp:59
double attr_stamp_contains
Last time any object that uses this as reference recursively has been modified.
Definition: RootEntity.h:140
std::vector< double > attr_velocity
Velocity object is moving, usually world is 3D.
Definition: RootEntity.h:136
std::string attr_objtype
What kind of object this is.
Definition: Root.h:129
std::string attr_parent
The object this inherits attributes from.
Definition: Root.h:125
double attr_stamp
Last time this object was modified.
Definition: Root.h:127
Definition: Bridge.h:20