Atlas-C++
Entity.h
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 // Automatically generated using gen_cpp.py.
6 
7 #ifndef ATLAS_OBJECTS_ENTITY_ENTITY_H
8 #define ATLAS_OBJECTS_ENTITY_ENTITY_H
9 
10 #include <Atlas/Objects/RootEntity.h>
11 #include <Atlas/Objects/Anonymous.h>
12 
13 
14 namespace Atlas { namespace Objects { namespace Entity {
15 
22 class AdminEntityData;
23 typedef SmartPtr<AdminEntityData> AdminEntity;
24 
25 static const int ADMIN_ENTITY_NO = 3;
26 
29 
32 {
33 protected:
35  AdminEntityData(AdminEntityData *defaults = NULL) :
36  RootEntityData((RootEntityData*)defaults)
37  {
38  m_class_no = ADMIN_ENTITY_NO;
39  }
41  virtual ~AdminEntityData();
42 
43 public:
45  virtual AdminEntityData * copy() const;
46 
48  virtual bool instanceOf(int classNo) const;
49 
50 
51  virtual void iterate(int& current_class, std::string& attr) const
52  {if(current_class == ADMIN_ENTITY_NO) current_class = -1; RootEntityData::iterate(current_class, attr);}
53 
54  //freelist related things
55 public:
56  static AdminEntityData *alloc();
57  virtual void free();
58 
64 
70 private:
71  static AdminEntityData *defaults_AdminEntityData;
72  static AdminEntityData *begin_AdminEntityData;
73 };
74 
75 
82 class AccountData;
83 typedef SmartPtr<AccountData> Account;
84 
85 static const int ACCOUNT_NO = 4;
86 
89 
92 {
93 protected:
95  AccountData(AccountData *defaults = NULL) :
97  {
98  m_class_no = ACCOUNT_NO;
99  }
101  virtual ~AccountData();
102 
103 public:
105  virtual AccountData * copy() const;
106 
108  virtual bool instanceOf(int classNo) const;
109 
112  virtual int copyAttr(const std::string& name, Atlas::Message::Element & attr) const;
114  virtual void setAttr(const std::string& name,
115  const Atlas::Message::Element& attr);
117  virtual void removeAttr(const std::string& name);
118 
120  virtual void sendContents(Atlas::Bridge & b) const;
121 
123  virtual void addToMessage(Atlas::Message::MapType &) const;
124 
126  inline void setUsername(const std::string& val);
128  inline void setPassword(const std::string& val);
130  inline void setCharacters(const std::list<std::string>& val);
132  inline void setCharactersAsList(const Atlas::Message::ListType& val);
133 
135  inline const std::string& getUsername() const;
137  inline std::string& modifyUsername();
139  inline const std::string& getPassword() const;
141  inline std::string& modifyPassword();
143  inline const std::list<std::string>& getCharacters() const;
145  inline std::list<std::string>& modifyCharacters();
147  inline const Atlas::Message::ListType getCharactersAsList() const;
148 
150  inline bool isDefaultUsername() const;
152  inline bool isDefaultPassword() const;
154  inline bool isDefaultCharacters() const;
155 
156 protected:
158  virtual int getAttrClass(const std::string& name)const;
160  virtual int getAttrFlag(const std::string& name)const;
162  std::string attr_username;
164  std::string attr_password;
166  std::list<std::string> attr_characters;
167 
169  void sendUsername(Atlas::Bridge&) const;
171  void sendPassword(Atlas::Bridge&) const;
173  void sendCharacters(Atlas::Bridge&) const;
174 
175  virtual void iterate(int& current_class, std::string& attr) const;
176 
177  //freelist related things
178 public:
179  static AccountData *alloc();
180  virtual void free();
181 
186  virtual AccountData *getDefaultObject();
187 
193 private:
194  static AccountData *defaults_AccountData;
195  static AccountData *begin_AccountData;
196 
197  static std::map<std::string, int> * attr_flags_AccountData;
198 };
199 
200 //
201 // Attribute name strings follow.
202 //
203 
204 extern const std::string USERNAME_ATTR;
205 extern const std::string PASSWORD_ATTR;
206 extern const std::string CHARACTERS_ATTR;
207 
208 //
209 // Inlined member functions follow.
210 //
211 
212 const int USERNAME_FLAG = 1 << 11;
213 
214 void AccountData::setUsername(const std::string& val)
215 {
216  attr_username = val;
217  m_attrFlags |= USERNAME_FLAG;
218 }
219 
220 const int PASSWORD_FLAG = 1 << 12;
221 
222 void AccountData::setPassword(const std::string& val)
223 {
224  attr_password = val;
225  m_attrFlags |= PASSWORD_FLAG;
226 }
227 
228 const int CHARACTERS_FLAG = 1 << 13;
229 
230 void AccountData::setCharacters(const std::list<std::string>& val)
231 {
232  attr_characters = val;
233  m_attrFlags |= CHARACTERS_FLAG;
234 }
235 
236 void AccountData::setCharactersAsList(const Atlas::Message::ListType& val)
237 {
238  m_attrFlags |= CHARACTERS_FLAG;
239  attr_characters.resize(0);
240  for(Atlas::Message::ListType::const_iterator I = val.begin();
241  I != val.end();
242  I++)
243  {
244  if((*I).isString()) {
245  attr_characters.push_back((*I).asString());
246  }
247  }
248 }
249 
250 const std::string& AccountData::getUsername() const
251 {
252  if(m_attrFlags & USERNAME_FLAG)
253  return attr_username;
254  else
255  return ((AccountData*)m_defaults)->attr_username;
256 }
257 
259 {
260  if(!(m_attrFlags & USERNAME_FLAG))
261  setUsername(((AccountData*)m_defaults)->attr_username);
262  return attr_username;
263 }
264 
265 const std::string& AccountData::getPassword() const
266 {
267  if(m_attrFlags & PASSWORD_FLAG)
268  return attr_password;
269  else
270  return ((AccountData*)m_defaults)->attr_password;
271 }
272 
274 {
275  if(!(m_attrFlags & PASSWORD_FLAG))
276  setPassword(((AccountData*)m_defaults)->attr_password);
277  return attr_password;
278 }
279 
280 const std::list<std::string>& AccountData::getCharacters() const
281 {
282  if(m_attrFlags & CHARACTERS_FLAG)
283  return attr_characters;
284  else
285  return ((AccountData*)m_defaults)->attr_characters;
286 }
287 
288 std::list<std::string>& AccountData::modifyCharacters()
289 {
290  if(!(m_attrFlags & CHARACTERS_FLAG))
291  setCharacters(((AccountData*)m_defaults)->attr_characters);
292  return attr_characters;
293 }
294 
295 const Atlas::Message::ListType AccountData::getCharactersAsList() const
296 {
297  const std::list<std::string>& lst_in = getCharacters();
298  Atlas::Message::ListType lst_out;
299  for(std::list<std::string>::const_iterator I = lst_in.begin();
300  I != lst_in.end();
301  I++)
302  {
303  lst_out.push_back(std::string(*I));
304  }
305  return lst_out;
306 }
307 
309 {
310  return (m_attrFlags & USERNAME_FLAG) == 0;
311 }
312 
314 {
315  return (m_attrFlags & PASSWORD_FLAG) == 0;
316 }
317 
319 {
320  return (m_attrFlags & CHARACTERS_FLAG) == 0;
321 }
322 
323 
324 
331 class PlayerData;
333 
334 static const int PLAYER_NO = 5;
335 
338 
340 class PlayerData : public AccountData
341 {
342 protected:
344  PlayerData(PlayerData *defaults = NULL) :
345  AccountData((AccountData*)defaults)
346  {
347  m_class_no = PLAYER_NO;
348  }
350  virtual ~PlayerData();
351 
352 public:
354  virtual PlayerData * copy() const;
355 
357  virtual bool instanceOf(int classNo) const;
358 
359 
360  virtual void iterate(int& current_class, std::string& attr) const
361  {if(current_class == PLAYER_NO) current_class = -1; AccountData::iterate(current_class, attr);}
362 
363  //freelist related things
364 public:
365  static PlayerData *alloc();
366  virtual void free();
367 
372  virtual PlayerData *getDefaultObject();
373 
379 private:
380  static PlayerData *defaults_PlayerData;
381  static PlayerData *begin_PlayerData;
382 };
383 
384 
391 class AdminData;
392 typedef SmartPtr<AdminData> Admin;
393 
394 static const int ADMIN_NO = 6;
395 
398 
400 class AdminData : public AccountData
401 {
402 protected:
404  AdminData(AdminData *defaults = NULL) :
405  AccountData((AccountData*)defaults)
406  {
407  m_class_no = ADMIN_NO;
408  }
410  virtual ~AdminData();
411 
412 public:
414  virtual AdminData * copy() const;
415 
417  virtual bool instanceOf(int classNo) const;
418 
419 
420  virtual void iterate(int& current_class, std::string& attr) const
421  {if(current_class == ADMIN_NO) current_class = -1; AccountData::iterate(current_class, attr);}
422 
423  //freelist related things
424 public:
425  static AdminData *alloc();
426  virtual void free();
427 
432  virtual AdminData *getDefaultObject();
433 
439 private:
440  static AdminData *defaults_AdminData;
441  static AdminData *begin_AdminData;
442 };
443 
444 
451 class GameData;
452 typedef SmartPtr<GameData> Game;
453 
454 static const int GAME_NO = 7;
455 
458 
460 class GameData : public AdminEntityData
461 {
462 protected:
464  GameData(GameData *defaults = NULL) :
465  AdminEntityData((AdminEntityData*)defaults)
466  {
467  m_class_no = GAME_NO;
468  }
470  virtual ~GameData();
471 
472 public:
474  virtual GameData * copy() const;
475 
477  virtual bool instanceOf(int classNo) const;
478 
479 
480  virtual void iterate(int& current_class, std::string& attr) const
481  {if(current_class == GAME_NO) current_class = -1; AdminEntityData::iterate(current_class, attr);}
482 
483  //freelist related things
484 public:
485  static GameData *alloc();
486  virtual void free();
487 
492  virtual GameData *getDefaultObject();
493 
499 private:
500  static GameData *defaults_GameData;
501  static GameData *begin_GameData;
502 };
503 
504 
511 class GameEntityData;
512 typedef SmartPtr<GameEntityData> GameEntity;
513 
514 static const int GAME_ENTITY_NO = 8;
515 
518 
521 {
522 protected:
524  GameEntityData(GameEntityData *defaults = NULL) :
525  RootEntityData((RootEntityData*)defaults)
526  {
527  m_class_no = GAME_ENTITY_NO;
528  }
530  virtual ~GameEntityData();
531 
532 public:
534  virtual GameEntityData * copy() const;
535 
537  virtual bool instanceOf(int classNo) const;
538 
539 
540  virtual void iterate(int& current_class, std::string& attr) const
541  {if(current_class == GAME_ENTITY_NO) current_class = -1; RootEntityData::iterate(current_class, attr);}
542 
543  //freelist related things
544 public:
545  static GameEntityData *alloc();
546  virtual void free();
547 
552  virtual GameEntityData *getDefaultObject();
553 
559 private:
560  static GameEntityData *defaults_GameEntityData;
561  static GameEntityData *begin_GameEntityData;
562 };
563 
564 } } } // namespace Atlas::Objects::Entity
565 
566 #endif // ATLAS_OBJECTS_ENTITY_ENTITY_H
std::list< std::string > & modifyCharacters()
Retrieve the "characters" attribute as a non-const reference.
Definition: Entity.h:288
virtual void free()
Free an instance of this class, returning it to the memory pool.
static AdminEntityData * getDefaultObjectInstance()
Get the reference object that contains the default values for attributes of instances of this class...
void setCharactersAsList(const Atlas::Message::ListType &val)
Set the "characters" attribute AsList.
Definition: Entity.h:236
void setCharacters(const std::list< std::string > &val)
Set the "characters" attribute.
Definition: Entity.h:230
virtual PlayerData * getDefaultObject()
Get the reference object that contains the default values for attributes of instances of the same cla...
virtual int getAttrClass(const std::string &name) const
Find the class which contains the attribute "name".
virtual void free()
Free an instance of this class, returning it to the memory pool.
virtual bool instanceOf(int classNo) const
Is this instance of some class?
static GameData * getDefaultObjectInstance()
Get the reference object that contains the default values for attributes of instances of this class...
virtual bool instanceOf(int classNo) const
Is this instance of some class?
Atlas stream bridge.
Definition: Bridge.h:35
void sendPassword(Atlas::Bridge &) const
Send the "password" attribute to an Atlas::Bridge.
virtual GameData * copy() const
Copy this object.
virtual void addToMessage(Atlas::Message::MapType &) const
Write this object to an existing Element.
void setPassword(const std::string &val)
Set the "password" attribute.
Definition: Entity.h:222
virtual AccountData * getDefaultObject()
Get the reference object that contains the default values for attributes of instances of the same cla...
virtual void free()
Free an instance of this class, returning it to the memory pool.
virtual AdminData * copy() const
Copy this object.
std::string attr_username
Username for account usually.
Definition: Entity.h:162
static PlayerData * getDefaultObjectInstance()
Get the reference object that contains the default values for attributes of instances of this class...
const std::list< std::string > & getCharacters() const
Retrieve the "characters" attribute.
Definition: Entity.h:280
virtual AccountData * copy() const
Copy this object.
virtual void free()
Free an instance of this class, returning it to the memory pool.
AdminData(AdminData *defaults=NULL)
Construct a AdminData class definition.
Definition: Entity.h:404
virtual GameEntityData * getDefaultObject()
Get the reference object that contains the default values for attributes of instances of the same cla...
std::list< std::string > attr_characters
List of characters account can control.
Definition: Entity.h:166
Multi-type container.
Definition: Element.h:59
virtual ~AdminEntityData()
Default destructor.
virtual ~AdminData()
Default destructor.
virtual void iterate(int &current_class, std::string &attr) const
Iterate over the attributes of this instance.
Definition: Entity.h:420
virtual bool instanceOf(int classNo) const
Is this instance of some class?
All In Game classes and objects.
Definition: Entity.h:520
PlayerData(PlayerData *defaults=NULL)
Construct a PlayerData class definition.
Definition: Entity.h:344
virtual void iterate(int &current_class, std::string &attr) const
Iterate over the attributes of this instance.
Definition: Entity.h:51
virtual PlayerData * copy() const
Copy this object.
virtual bool instanceOf(int classNo) const
Is this instance of some class?
virtual void iterate(int &current_class, std::string &attr) const
Iterate over the attributes of this instance.
Definition: Entity.h:480
The Atlas namespace.
Definition: Bridge.h:20
virtual void iterate(int &current_class, std::string &attr) const
Iterate over the attributes of this instance.
virtual ~PlayerData()
Default destructor.
virtual AdminData * getDefaultObject()
Get the reference object that contains the default values for attributes of instances of the same cla...
virtual AdminEntityData * getDefaultObject()
Get the reference object that contains the default values for attributes of instances of the same cla...
bool isDefaultCharacters() const
Is "characters" value default?
Definition: Entity.h:318
All classes and objects used for adminitrativive purposes.
Definition: Entity.h:31
virtual ~AccountData()
Default destructor.
static GameEntityData * getDefaultObjectInstance()
Get the reference object that contains the default values for attributes of instances of this class...
virtual GameData * getDefaultObject()
Get the reference object that contains the default values for attributes of instances of the same cla...
Games this server hosts.
Definition: Entity.h:460
virtual bool instanceOf(int classNo) const
Is this instance of some class?
virtual void free()
Free an instance of this class, returning it to the memory pool.
GameEntityData(GameEntityData *defaults=NULL)
Construct a GameEntityData class definition.
Definition: Entity.h:524
Player accounts.
Definition: Entity.h:340
virtual int copyAttr(const std::string &name, Atlas::Message::Element &attr) const
Retrieve the attribute "name".
virtual GameEntityData * copy() const
Copy this object.
virtual void setAttr(const std::string &name, const Atlas::Message::Element &attr)
Set the attribute "name" to the value given by"attr".
bool isDefaultPassword() const
Is "password" value default?
Definition: Entity.h:313
virtual void removeAttr(const std::string &name)
Remove the attribute "name". This will not work for static attributes.
void setUsername(const std::string &val)
Set the "username" attribute.
Definition: Entity.h:214
const std::string & getPassword() const
Retrieve the "password" attribute.
Definition: Entity.h:265
void sendCharacters(Atlas::Bridge &) const
Send the "characters" attribute to an Atlas::Bridge.
static AdminData * getDefaultObjectInstance()
Get the reference object that contains the default values for attributes of instances of this class...
virtual void free()
Free an instance of this class, returning it to the memory pool.
virtual ~GameEntityData()
Default destructor.
virtual void iterate(int &current_class, std::string &attr) const
Iterate over the attributes of this instance.
Definition: Entity.h:360
virtual void sendContents(Atlas::Bridge &b) const
Send the contents of this object to a Bridge.
void sendUsername(Atlas::Bridge &) const
Send the "username" attribute to an Atlas::Bridge.
static AccountData * getDefaultObjectInstance()
Get the reference object that contains the default values for attributes of instances of this class...
Starting point for entity hierarchy.
Definition: RootEntity.h:30
bool isDefaultUsername() const
Is "username" value default?
Definition: Entity.h:308
Definition: Decoder.h:15
virtual ~GameData()
Default destructor.
virtual int getAttrFlag(const std::string &name) const
Find the flag for the attribute "name".
Privileged accounts.
Definition: Entity.h:400
std::string attr_password
Password for account usually.
Definition: Entity.h:164
const Atlas::Message::ListType getCharactersAsList() const
Retrieve the "characters" attribute AsList.
Definition: Entity.h:295
AccountData(AccountData *defaults=NULL)
Construct a AccountData class definition.
Definition: Entity.h:95
std::string & modifyPassword()
Retrieve the "password" attribute as a non-const reference.
Definition: Entity.h:273
virtual void iterate(int &current_class, std::string &attr) const
Iterate over the attributes of this instance.
Definition: Entity.h:540
const std::string & getUsername() const
Retrieve the "username" attribute.
Definition: Entity.h:250
virtual bool instanceOf(int classNo) const
Is this instance of some class?
Base class for accounts.
Definition: Entity.h:91
GameData(GameData *defaults=NULL)
Construct a GameData class definition.
Definition: Entity.h:464
AdminEntityData(AdminEntityData *defaults=NULL)
Construct a AdminEntityData class definition.
Definition: Entity.h:35
std::string & modifyUsername()
Retrieve the "username" attribute as a non-const reference.
Definition: Entity.h:258
virtual void iterate(int &current_class, std::string &attr) const
Iterate over the attributes of this instance.
virtual AdminEntityData * copy() const
Copy this object.

Copyright 2000-2004 the respective authors.

This document can be licensed under the terms of the GNU Free Documentation License or the GNU General Public License and may be freely distributed under the terms given by one of these licenses.