Atlas
0.7.0
Networking protocol for the Worldforge system.
|
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;
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);
83 static 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);
198 extern const std::string USERNAME_ATTR;
199 extern const std::string PASSWORD_ATTR;
200 extern const std::string CHARACTERS_ATTR;
206 const uint32_t USERNAME_FLAG = 1u << 11u;
211 m_attrFlags |= USERNAME_FLAG;
214 const uint32_t PASSWORD_FLAG = 1u << 12u;
219 m_attrFlags |= PASSWORD_FLAG;
222 const 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;
322 static 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);
379 static 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);
436 static 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);
490 class GameEntityData;
493 static 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);
542 #endif // ATLAS_OBJECTS_ENTITY_ENTITY_H
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
Starting point for entity hierarchy.
void sendPassword(Atlas::Bridge &) const
Send the "password" attribute to an Atlas::Bridge.
~PlayerData() override=default
Default destructor.
void setCharactersAsList(const Atlas::Message::ListType &val)
Set the "characters" attribute AsList.
std::string & modifyUsername()
Retrieve the "username" attribute as a non-const reference.
void reset() override
Resets the object as it's returned to the pool.
const std::string & getPassword() const
Retrieve the "password" attribute.
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
~AccountData() override=default
Default destructor.
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 reset() override
Resets the object as it's returned to the pool.
GameEntityData(GameEntityData *defaults=nullptr)
Construct a GameEntityData class definition.
AdminData(AdminData *defaults=nullptr)
Construct a AdminData class definition.
PlayerData(PlayerData *defaults=nullptr)
Construct a PlayerData class definition.
std::vector< std::string > attr_characters
List of characters account can control.
GameEntityData * copy() const override
Copy this object.
std::string attr_password
Password for account usually.
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?
bool instanceOf(int classNo) const override
Is this instance of some class?
void setCharacters(std::vector< std::string > val)
Set the "characters" attribute.
AccountData * copy() const override
Copy this object.
GameData * copy() const override
Copy this object.
void reset() override
Resets the object as it's returned to the pool.
bool instanceOf(int classNo) const override
Is this instance of some class?
void setPassword(std::string val)
Set the "password" attribute.
void setUsername(std::string val)
Set the "username" attribute.
bool isDefaultCharacters() const
Is "characters" value default?
AdminEntityData * copy() const override
Copy this object.
AdminData * copy() const override
Copy this object.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
void free() override
Free an instance of this class, returning it to the memory pool.
~AdminData() override=default
Default destructor.
~GameData() override=default
Default destructor.
void reset() override
Resets the object as it's returned to the pool.
All In Game classes and objects.
bool isDefaultPassword() const
Is "password" value default?
Atlas::Message::ListType getCharactersAsList() const
Retrieve the "characters" attribute AsList.
All classes and objects used for administrative purposes.
bool isDefaultUsername() const
Is "username" value default?
void free() override
Free an instance of this class, returning it to the memory pool.
AdminEntityData(AdminEntityData *defaults=nullptr)
Construct a AdminEntityData class definition.
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.
BaseObjectData * m_defaults
void sendCharacters(Atlas::Bridge &) const
Send the "characters" attribute to an Atlas::Bridge.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
std::string attr_username
Username for account usually.
PlayerData * copy() const override
Copy this object.
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?
AccountData(AccountData *defaults=nullptr)
Construct a AccountData class definition.
const std::vector< std::string > & getCharacters() const
Retrieve the "characters" attribute.
void sendUsername(Atlas::Bridge &) const
Send the "username" attribute to an Atlas::Bridge.
~GameEntityData() override=default
Default destructor.
void free() override
Free an instance of this class, returning it to the memory pool.
std::string & modifyPassword()
Retrieve the "password" attribute as a non-const reference.
bool instanceOf(int classNo) const override
Is this instance of some class?
std::vector< std::string > & modifyCharacters()
Retrieve the "characters" attribute as a non-const reference.
GameData(GameData *defaults=nullptr)
Construct a GameData class definition.
void reset() override
Resets the object as it's returned to the pool.
const std::string & getUsername() const
Retrieve the "username" attribute.
~AdminEntityData() override=default
Default destructor.
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.