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>
15namespace Atlas {
namespace Objects {
namespace Entity {
24typedef SmartPtr<AdminEntityData> AdminEntity;
26static const int ADMIN_ENTITY_NO = 3;
39 m_class_no = ADMIN_ENTITY_NO;
46 static constexpr const char* super_parent =
"root_entity";
48 static constexpr const char* default_parent =
"admin_entity";
50 static constexpr const char* default_objtype =
"obj";
60 friend class ::Atlas::Objects::Allocator;
65 void reset()
override;
70 static void fillDefaultObjectInstance(
AdminEntityData& data, std::map<std::string, uint32_t>& attr_data);
83static const int ACCOUNT_NO = 4;
96 m_class_no = ACCOUNT_NO;
103 static constexpr const char* super_parent =
"admin_entity";
105 static constexpr const char* default_parent =
"account";
107 static constexpr const char* default_objtype =
"obj";
121 void removeAttr(
const std::string& name)
override;
127 void addToMessage(Atlas::Message::MapType &)
const override;
162 int getAttrClass(
const std::string& name)
const override;
164 bool getAttrFlag(
const std::string& name, uint32_t& flag)
const override;
181 friend class ::Atlas::Objects::Allocator;
186 void reset()
override;
187 void free()
override;
191 static void fillDefaultObjectInstance(
AccountData& data, std::map<std::string, uint32_t>& attr_data);
198extern const std::string USERNAME_ATTR;
199extern const std::string PASSWORD_ATTR;
200extern const std::string CHARACTERS_ATTR;
206const uint32_t USERNAME_FLAG = 1u << 11u;
211 m_attrFlags |= USERNAME_FLAG;
214const uint32_t PASSWORD_FLAG = 1u << 12u;
219 m_attrFlags |= PASSWORD_FLAG;
222const uint32_t CHARACTERS_FLAG = 1u << 13u;
227 m_attrFlags |= CHARACTERS_FLAG;
232 m_attrFlags |= CHARACTERS_FLAG;
234 for (
const auto& entry : val) {
235 if(entry.isString()) {
243 if(m_attrFlags & USERNAME_FLAG)
251 if(!(m_attrFlags & USERNAME_FLAG))
258 if(m_attrFlags & PASSWORD_FLAG)
266 if(!(m_attrFlags & PASSWORD_FLAG))
273 if(m_attrFlags & CHARACTERS_FLAG)
281 if(!(m_attrFlags & CHARACTERS_FLAG))
289 Atlas::Message::ListType lst_out;
290 for (
const auto& entry : lst_in) {
291 lst_out.push_back(std::string(entry));
298 return (m_attrFlags & USERNAME_FLAG) == 0;
303 return (m_attrFlags & PASSWORD_FLAG) == 0;
308 return (m_attrFlags & CHARACTERS_FLAG) == 0;
322static const int PLAYER_NO = 5;
335 m_class_no = PLAYER_NO;
342 static constexpr const char* super_parent =
"account";
344 static constexpr const char* default_parent =
"player";
346 static constexpr const char* default_objtype =
"obj";
356 friend class ::Atlas::Objects::Allocator;
361 void reset()
override;
362 void free()
override;
366 static void fillDefaultObjectInstance(
PlayerData& data, std::map<std::string, uint32_t>& attr_data);
379static const int ADMIN_NO = 6;
392 m_class_no = ADMIN_NO;
399 static constexpr const char* super_parent =
"account";
401 static constexpr const char* default_parent =
"admin";
403 static constexpr const char* default_objtype =
"obj";
413 friend class ::Atlas::Objects::Allocator;
418 void reset()
override;
419 void free()
override;
423 static void fillDefaultObjectInstance(
AdminData& data, std::map<std::string, uint32_t>& attr_data);
436static const int GAME_NO = 7;
449 m_class_no = GAME_NO;
456 static constexpr const char* super_parent =
"admin_entity";
458 static constexpr const char* default_parent =
"game";
460 static constexpr const char* default_objtype =
"obj";
470 friend class ::Atlas::Objects::Allocator;
475 void reset()
override;
476 void free()
override;
480 static void fillDefaultObjectInstance(
GameData& data, std::map<std::string, uint32_t>& attr_data);
493static const int GAME_ENTITY_NO = 8;
506 m_class_no = GAME_ENTITY_NO;
513 static constexpr const char* super_parent =
"root_entity";
515 static constexpr const char* default_parent =
"game_entity";
517 static constexpr const char* default_objtype =
"obj";
527 friend class ::Atlas::Objects::Allocator;
532 void reset()
override;
533 void free()
override;
537 static void fillDefaultObjectInstance(
GameEntityData& data, std::map<std::string, uint32_t>& attr_data);
BaseObjectData * m_defaults
AccountData(AccountData *defaults=nullptr)
Construct a AccountData class definition.
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
bool isDefaultCharacters() const
Is "characters" value default?
const std::string & getPassword() const
Retrieve the "password" attribute.
bool isDefaultUsername() const
Is "username" value default?
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.
std::string & modifyPassword()
Retrieve the "password" attribute as a non-const reference.
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.
void reset() override
Resets the object as it's returned to the pool.
bool isDefaultPassword() const
Is "password" value default?
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.
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.
std::string & modifyUsername()
Retrieve the "username" attribute as a non-const reference.
~AccountData() override=default
Default destructor.
std::string attr_username
Username for account usually.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
std::vector< std::string > attr_characters
List of characters account can control.
std::vector< std::string > & modifyCharacters()
Retrieve the "characters" attribute as a non-const reference.
void setUsername(std::string val)
Set the "username" attribute.
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.
void setCharacters(std::vector< std::string > val)
Set the "characters" attribute.
void setPassword(std::string val)
Set the "password" attribute.
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.
const std::vector< std::string > & getCharacters() const
Retrieve the "characters" attribute.
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() override=default
Default destructor.
AdminData * copy() const override
Copy this object.
bool instanceOf(int classNo) const override
Is this instance of some class?
AdminData(AdminData *defaults=nullptr)
Construct a AdminData class definition.
All classes and objects used for administrative purposes.
void reset() override
Resets the object as it's returned to the pool.
~AdminEntityData() override=default
Default destructor.
void free() override
Free an instance of this class, returning it to the memory pool.
AdminEntityData * copy() const override
Copy this object.
AdminEntityData(AdminEntityData *defaults=nullptr)
Construct a AdminEntityData class definition.
bool instanceOf(int classNo) const override
Is this instance of some class?
~GameData() override=default
Default destructor.
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.
GameData(GameData *defaults=nullptr)
Construct a GameData class definition.
All In Game classes and objects.
void reset() override
Resets the object as it's returned to the pool.
GameEntityData * copy() const override
Copy this object.
GameEntityData(GameEntityData *defaults=nullptr)
Construct a GameEntityData class definition.
~GameEntityData() override=default
Default destructor.
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.
PlayerData(PlayerData *defaults=nullptr)
Construct a PlayerData class definition.
~PlayerData() override=default
Default destructor.
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.
Starting point for entity hierarchy.