8 #include <Atlas/Objects/Entity.h> 11 using Atlas::Message::MapType;
13 namespace Atlas {
namespace Objects {
namespace Entity {
15 Allocator<AdminEntityData> AdminEntityData::allocator;
33 return copyInstance<AdminEntityData>(*this);
38 if(ADMIN_ENTITY_NO == classNo)
return true;
42 void AdminEntityData::fillDefaultObjectInstance(
AdminEntityData& data, std::map<std::string, uint32_t>& attr_data)
58 const std::string USERNAME_ATTR =
"username";
59 const std::string PASSWORD_ATTR =
"password";
60 const std::string CHARACTERS_ATTR =
"characters";
64 if (allocator.attr_flags_Data.find(name) != allocator.attr_flags_Data.end()) {
72 auto I = allocator.attr_flags_Data.find(name);
73 if (I != allocator.attr_flags_Data.end()) {
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; }
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; }
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;}
109 if(m_attrFlags & USERNAME_FLAG) {
116 if(m_attrFlags & PASSWORD_FLAG) {
123 if(m_attrFlags & CHARACTERS_FLAG) {
125 for(
const auto& item : attr_characters) {
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();
157 allocator.free(
this);
169 return copyInstance<AccountData>(*this);
174 if(ACCOUNT_NO == classNo)
return true;
178 void AccountData::fillDefaultObjectInstance(
AccountData& data, std::map<std::string, uint32_t>& attr_data)
192 attr_data[USERNAME_ATTR] = USERNAME_FLAG;
193 attr_data[PASSWORD_ATTR] = PASSWORD_FLAG;
194 attr_data[CHARACTERS_ATTR] = CHARACTERS_FLAG;
203 allocator.free(
this);
215 return copyInstance<PlayerData>(*this);
220 if(PLAYER_NO == classNo)
return true;
224 void PlayerData::fillDefaultObjectInstance(
PlayerData& data, std::map<std::string, uint32_t>& attr_data)
246 allocator.free(
this);
258 return copyInstance<AdminData>(*this);
263 if(ADMIN_NO == classNo)
return true;
267 void AdminData::fillDefaultObjectInstance(
AdminData& data, std::map<std::string, uint32_t>& attr_data)
289 allocator.free(
this);
301 return copyInstance<GameData>(*this);
306 if(GAME_NO == classNo)
return true;
310 void GameData::fillDefaultObjectInstance(
GameData& data, std::map<std::string, uint32_t>& attr_data)
332 allocator.free(
this);
344 return copyInstance<GameEntityData>(*this);
349 if(GAME_ENTITY_NO == classNo)
return true;
353 void GameEntityData::fillDefaultObjectInstance(
GameEntityData& data, std::map<std::string, uint32_t>& attr_data)
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
std::string attr_parent
The object this inherits attributes from.
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
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 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".
std::string attr_objtype
What kind of object this is.
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
std::vector< double > attr_velocity
Velocity object is moving, usually world is 3D.
bool instanceOf(int classNo) const override
Is this instance of some class?
StringType && moveString()
bool instanceOf(int classNo) const override
Is this instance of some class?
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
AccountData * copy() const override
Copy this object.
void reset() override
Resets the object as it's returned to the pool.
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
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.
GameData * copy() const override
Copy this object.
AdminData * copy() const override
Copy this object.
virtual void mapListItem(std::string name)=0
bool instanceOf(int classNo) const override
Is this instance of some class?
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
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.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
virtual void mapStringItem(std::string name, std::string)=0
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".
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
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 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.
All classes and objects used for administrative purposes.
PlayerData * copy() const override
Copy this object.
void sendPassword(Atlas::Bridge &) const
Send the "password" attribute to an Atlas::Bridge.
std::vector< double > attr_pos
Position coordinates, usually world is 3D.
void reset() override
Resets the object as it's returned to the pool.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
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?
virtual void listStringItem(std::string)=0
GameEntityData * copy() const override
Copy this object.
All In Game classes and objects.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
double attr_stamp
Last time this object was modified.
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.
void sendUsername(Atlas::Bridge &) const
Send the "username" attribute to an Atlas::Bridge.
void reset() override
Resets the object as it's returned to the pool.
double attr_stamp_contains
Last time any object that uses this as reference recursively has been modified.
bool instanceOf(int classNo) const override
Is this instance of some class?