Atlas-C++
|
Atlas base object class. More...
#include <BaseObject.h>
Classes | |
class | const_iterator |
class | iterator |
The iterator first iterates over the contents of m_obj->m_attributes, holding an iterator to the attributes map in m_I. More... | |
Public Member Functions | |
BaseObjectData (BaseObjectData *defaults) | |
Construct a new BaseObjectData from a subclass. More... | |
int | getClassNo () const |
Get class number: | |
int | getAttrFlags () const |
virtual BaseObjectData * | copy () const =0 |
virtual bool | instanceOf (int classNo) const |
Is this instance of some class? | |
bool | hasAttr (const std::string &name) const |
Check whether the attribute "name" exists. | |
bool | hasAttrFlag (int flag) const |
Check whether the attribute "name" exists. | |
const Atlas::Message::Element | getAttr (const std::string &name) const |
Retrieve the attribute "name". More... | |
virtual int | copyAttr (const std::string &name, Atlas::Message::Element &attr) const |
Retrieve the attribute "name". More... | |
virtual void | setAttr (const std::string &name, const Atlas::Message::Element &attr) |
Set the attribute "name" to the value given by "attr". | |
virtual void | removeAttr (const std::string &name) |
Remove the attribute "name". | |
virtual void | removeAttrFlag (int flag) |
Remove the attribute "name". | |
const Atlas::Message::MapType | asMessage () const |
Convert this object to a Object. More... | |
virtual void | addToMessage (Atlas::Message::MapType &) const |
Write this object to an existing Element. | |
virtual void | sendContents (Atlas::Bridge &b) const |
Send the contents of this object to a Bridge. | |
void | incRef () |
void | decRef () |
virtual void | free ()=0 |
Free an instance of this class, returning it to the memory pool. More... | |
iterator | begin () |
iterator | end () |
iterator | find (const std::string &) |
const_iterator | begin () const |
const_iterator | end () const |
const_iterator | find (const std::string &) const |
Static Public Member Functions | |
static BaseObjectData * | alloc () |
Allocate a new instance of this class, using an existing instance if available. More... | |
Protected Member Functions | |
virtual int | getAttrClass (const std::string &name) const |
Find the class which contains the attribute "name". | |
virtual int | getAttrFlag (const std::string &name) const |
Find the flag for the attribute "name". | |
virtual void | iterate (int ¤t_class, std::string &attr) const |
Iterate over the attributes of this instance. | |
Protected Attributes | |
int | m_class_no |
int | m_refCount |
BaseObjectData * | m_defaults |
BaseObjectData * | m_next |
std::map< std::string, Atlas::Message::Element > | m_attributes |
int | m_attrFlags |
Friends | |
class | iterator |
class | const_iterator |
Atlas base object class.
This is class is the base from which all classes used to represent high level objects are derived. In this release of Atlas-C++, all classes that inherit from BaseObjectData are designed to be used with SmartPtr and should have the suffix Data on the end of their name. All the subclasses of BaseObjectData included with Atlas-C++ are automatically generated from the Atlas spec at release time. For each subclass a typedef is created of a specialisation of SmartPtr aliasing it to the name of the class without the Data suffix. Thus RootOperationData has an associate type RootOperation which is a typedef for SmartPtr<RootOperationData>. Each class also has an associated integer identifier used to identify classes of its type. The SmartPtr class is designed to store unused instances of the data objects in a memory pool, and reuse instances as they are required. In order to re-use instances without re-constructing all their members, a system of flags is used to mark which members are in use. When an instance is re-used these flags are cleared, indicating that none of the members are in use.
Atlas::Objects::BaseObjectData::BaseObjectData | ( | BaseObjectData * | defaults | ) |
Construct a new BaseObjectData from a subclass.
Initialises flags to zero, and stores a pointer to the reference object that provides default values for all attributes. Subclasses must pass in a pointer to their class specific reference object.
|
inlinestatic |
Allocate a new instance of this class, using an existing instance if available.
This is the key function for implementing the memory pool for the Atlas::Objects API.
const Atlas::Message::MapType Atlas::Objects::BaseObjectData::asMessage | ( | ) | const |
Convert this object to a Object.
This is now legacy, and implemented using addToMessage.
|
virtual |
Retrieve the attribute "name".
Return non-zero if it does not exist.
Reimplemented in Atlas::Objects::Entity::AccountData, Atlas::Objects::Operation::RootOperationData, Atlas::Objects::RootData, and Atlas::Objects::Entity::RootEntityData.
|
pure virtual |
Free an instance of this class, returning it to the memory pool.
This function in combination with alloc() handle the memory pool.
Implemented in Atlas::Objects::Operation::ErrorData, Atlas::Objects::Operation::FeelData, Atlas::Objects::Operation::SmellData, Atlas::Objects::Operation::SoundData, Atlas::Objects::Operation::DisappearanceData, Atlas::Objects::Operation::AppearanceData, Atlas::Objects::Operation::SightData, Atlas::Objects::Operation::PerceptionData, Atlas::Objects::Operation::InfoData, Atlas::Objects::Operation::UseData, Atlas::Objects::Operation::ImaginaryData, Atlas::Objects::Operation::LogoutData, Atlas::Objects::Operation::LoginData, Atlas::Objects::Operation::TouchData, Atlas::Objects::Operation::SniffData, Atlas::Objects::Operation::ListenData, Atlas::Objects::Operation::LookData, Atlas::Objects::Operation::PerceiveData, Atlas::Objects::Operation::GetData, Atlas::Objects::Operation::WieldData, Atlas::Objects::Operation::MoveData, Atlas::Objects::Operation::AffectData, Atlas::Objects::Entity::GameEntityData, Atlas::Objects::Operation::SetData, Atlas::Objects::Entity::GameData, Atlas::Objects::Operation::DeleteData, Atlas::Objects::Entity::AdminData, Atlas::Objects::Entity::PlayerData, Atlas::Objects::Operation::TalkData, Atlas::Objects::Operation::CommunicateData, Atlas::Objects::Operation::DivideData, Atlas::Objects::Operation::CombineData, Atlas::Objects::Entity::AccountData, Atlas::Objects::Operation::RootOperationData, Atlas::Objects::Entity::RootEntityData, Atlas::Objects::RootData, Atlas::Objects::Operation::CreateData, Atlas::Objects::Operation::GenericData, Atlas::Objects::Operation::ActionData, Atlas::Objects::Entity::AnonymousData, and Atlas::Objects::Entity::AdminEntityData.
const Atlas::Message::Element Atlas::Objects::BaseObjectData::getAttr | ( | const std::string & | name | ) | const |
Retrieve the attribute "name".
Throws NoSuchAttrException if it does not exist.
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.