8 #ifndef ATLAS_OBJECTS_ENTITY_ENTITY_H 9 #define ATLAS_OBJECTS_ENTITY_ENTITY_H 11 #include <Atlas/Objects/RootEntity.h> 12 #include <Atlas/Objects/Anonymous.h> 15 namespace Atlas {
namespace Objects {
namespace Entity {
23 class AdminEntityData;
24 typedef SmartPtr<AdminEntityData> AdminEntity;
26 static const int ADMIN_ENTITY_NO = 3;
39 m_class_no = ADMIN_ENTITY_NO;
52 void iterate(
int& current_class, std::string& attr)
const override 57 friend class ::Atlas::Objects::Allocator;
62 void reset()
override;
67 static void fillDefaultObjectInstance(
AdminEntityData& data, std::map<std::string, int32_t>& attr_data);
80 static const int ACCOUNT_NO = 4;
93 m_class_no = ACCOUNT_NO;
109 void setAttr(
const std::string& name,
112 void removeAttr(
const std::string& name)
override;
118 void addToMessage(Atlas::Message::MapType &)
const override;
121 void setUsername(
const std::string& val);
123 void setPassword(
const std::string& val);
125 void setCharacters(
const std::list<std::string>& val);
127 void setCharactersAsList(
const Atlas::Message::ListType& val);
130 const std::string& getUsername()
const;
132 std::string& modifyUsername();
134 const std::string& getPassword()
const;
136 std::string& modifyPassword();
138 const std::list<std::string>& getCharacters()
const;
140 std::list<std::string>& modifyCharacters();
142 const Atlas::Message::ListType getCharactersAsList()
const;
145 bool isDefaultUsername()
const;
147 bool isDefaultPassword()
const;
149 bool isDefaultCharacters()
const;
153 int getAttrClass(
const std::string& name)
const override;
155 int32_t
getAttrFlag(
const std::string& name)
const override;
170 void iterate(
int& current_class, std::string& attr)
const override;
174 friend class ::Atlas::Objects::Allocator;
179 void reset()
override;
180 void free()
override;
184 static void fillDefaultObjectInstance(
AccountData& data, std::map<std::string, int32_t>& attr_data);
191 extern const std::string USERNAME_ATTR;
192 extern const std::string PASSWORD_ATTR;
193 extern const std::string CHARACTERS_ATTR;
199 const int32_t USERNAME_FLAG = 1 << 11;
204 m_attrFlags |= USERNAME_FLAG;
207 const int32_t PASSWORD_FLAG = 1 << 12;
212 m_attrFlags |= PASSWORD_FLAG;
215 const int32_t CHARACTERS_FLAG = 1 << 13;
219 attr_characters = val;
220 m_attrFlags |= CHARACTERS_FLAG;
225 m_attrFlags |= CHARACTERS_FLAG;
226 attr_characters.resize(0);
227 for (
const auto& entry : val) {
228 if(entry.isString()) {
229 attr_characters.push_back(entry.asString());
236 if(m_attrFlags & USERNAME_FLAG)
237 return attr_username;
244 if(!(m_attrFlags & USERNAME_FLAG))
246 return attr_username;
251 if(m_attrFlags & PASSWORD_FLAG)
252 return attr_password;
259 if(!(m_attrFlags & PASSWORD_FLAG))
261 return attr_password;
266 if(m_attrFlags & CHARACTERS_FLAG)
267 return attr_characters;
274 if(!(m_attrFlags & CHARACTERS_FLAG))
276 return attr_characters;
281 const std::list<std::string>& lst_in = getCharacters();
282 Atlas::Message::ListType lst_out;
283 for (
const auto& entry : lst_in) {
284 lst_out.push_back(std::string(entry));
291 return (m_attrFlags & USERNAME_FLAG) == 0;
296 return (m_attrFlags & PASSWORD_FLAG) == 0;
301 return (m_attrFlags & CHARACTERS_FLAG) == 0;
315 static const int PLAYER_NO = 5;
328 m_class_no = PLAYER_NO;
341 void iterate(
int& current_class, std::string& attr)
const override 346 friend class ::Atlas::Objects::Allocator;
351 void reset()
override;
352 void free()
override;
356 static void fillDefaultObjectInstance(
PlayerData& data, std::map<std::string, int32_t>& attr_data);
369 static const int ADMIN_NO = 6;
382 m_class_no = ADMIN_NO;
395 void iterate(
int& current_class, std::string& attr)
const override 400 friend class ::Atlas::Objects::Allocator;
405 void reset()
override;
406 void free()
override;
410 static void fillDefaultObjectInstance(
AdminData& data, std::map<std::string, int32_t>& attr_data);
423 static const int GAME_NO = 7;
436 m_class_no = GAME_NO;
449 void iterate(
int& current_class, std::string& attr)
const override 454 friend class ::Atlas::Objects::Allocator;
459 void reset()
override;
460 void free()
override;
464 static void fillDefaultObjectInstance(
GameData& data, std::map<std::string, int32_t>& attr_data);
477 static const int GAME_ENTITY_NO = 8;
490 m_class_no = GAME_ENTITY_NO;
503 void iterate(
int& current_class, std::string& attr)
const override 508 friend class ::Atlas::Objects::Allocator;
513 void reset()
override;
514 void free()
override;
518 static void fillDefaultObjectInstance(
GameEntityData& data, std::map<std::string, int32_t>& attr_data);
523 #endif // ATLAS_OBJECTS_ENTITY_ENTITY_H std::list< std::string > & modifyCharacters()
Retrieve the "characters" attribute as a non-const reference.
Definition: Entity.h:272
AdminEntityData(AdminEntityData *defaults=nullptr)
Construct a AdminEntityData class definition.
Definition: Entity.h:36
GameData(GameData *defaults=nullptr)
Construct a GameData class definition.
Definition: Entity.h:433
AccountData(AccountData *defaults=nullptr)
Construct a AccountData class definition.
Definition: Entity.h:90
void setCharactersAsList(const Atlas::Message::ListType &val)
Set the "characters" attribute AsList.
Definition: Entity.h:223
void setCharacters(const std::list< std::string > &val)
Set the "characters" attribute.
Definition: Entity.h:217
bool isDefaultPassword() const
Is "password" value default?
Definition: Entity.h:294
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
Retrieve the attribute "name".
void iterate(int ¤t_class, std::string &attr) const override
Iterate over the attributes of this instance.
Definition: Entity.h:395
Atlas stream bridge.
Definition: Bridge.h:35
void iterate(int ¤t_class, std::string &attr) const override
Iterate over the attributes of this instance.
AdminEntityData * copy() const override
Copy this object.
void setPassword(const std::string &val)
Set the "password" attribute.
Definition: Entity.h:209
void iterate(int ¤t_class, std::string &attr) const override
Iterate over the attributes of this instance.
Definition: Entity.h:341
std::string attr_username
Username for account usually.
Definition: Entity.h:157
const std::string & getPassword() const
Retrieve the "password" attribute.
Definition: Entity.h:249
std::list< std::string > attr_characters
List of characters account can control.
Definition: Entity.h:161
BaseObjectData * m_defaults
The default instance, acting as a prototype for all other instances.
Definition: BaseObject.h:440
Multi-type container.
Definition: Element.h:60
All In Game classes and objects.
Definition: Entity.h:483
void free() override
Free an instance of this class, returning it to the memory pool.
The Atlas namespace.
Definition: Bridge.h:20
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
int32_t getAttrFlag(const std::string &name) const override
Find the flag for the attribute "name".
All classes and objects used for adminitrativive purposes.
Definition: Entity.h:32
void reset() override
Resets the object as it's returned to the pool.
Games this server hosts.
Definition: Entity.h:429
~AdminEntityData() override=default
Default destructor.
Player accounts.
Definition: Entity.h:321
PlayerData(PlayerData *defaults=nullptr)
Construct a PlayerData class definition.
Definition: Entity.h:325
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
bool isDefaultUsername() const
Is "username" value default?
Definition: Entity.h:289
void setUsername(const std::string &val)
Set the "username" attribute.
Definition: Entity.h:201
void iterate(int ¤t_class, std::string &attr) const override
Iterate over the attributes of this instance.
Definition: Entity.h:449
void iterate(int ¤t_class, std::string &attr) const override
Iterate over the attributes of this instance.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
AdminData(AdminData *defaults=nullptr)
Construct a AdminData class definition.
Definition: Entity.h:379
const std::string & getUsername() const
Retrieve the "username" attribute.
Definition: Entity.h:234
Starting point for entity hierarchy.
Definition: RootEntity.h:31
void iterate(int ¤t_class, std::string &attr) const override
Iterate over the attributes of this instance.
Definition: Entity.h:503
Trait which handles allocation of instances of BaseObject.
Definition: BaseObject.h:63
const std::list< std::string > & getCharacters() const
Retrieve the "characters" attribute.
Definition: Entity.h:264
Privileged accounts.
Definition: Entity.h:375
std::string attr_password
Password for account usually.
Definition: Entity.h:159
std::string & modifyPassword()
Retrieve the "password" attribute as a non-const reference.
Definition: Entity.h:257
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
GameEntityData(GameEntityData *defaults=nullptr)
Construct a GameEntityData class definition.
Definition: Entity.h:487
Base class for accounts.
Definition: Entity.h:86
bool isDefaultCharacters() const
Is "characters" value default?
Definition: Entity.h:299
bool instanceOf(int classNo) const override
Is this instance of some class?
std::string & modifyUsername()
Retrieve the "username" attribute as a non-const reference.
Definition: Entity.h:242
void iterate(int ¤t_class, std::string &attr) const override
Iterate over the attributes of this instance.
Definition: Entity.h:52
void setAttr(const std::string &name, const Atlas::Message::Element &attr) override
Set the attribute "name" to the value given by"attr".
const Atlas::Message::ListType getCharactersAsList() const
Retrieve the "characters" attribute AsList.
Definition: Entity.h:279