7 #ifndef ATLAS_OBJECTS_BASEOBJECT_H
8 #define ATLAS_OBJECTS_BASEOBJECT_H
10 #include <Atlas/Message/MEncoder.h>
11 #include <Atlas/Message/Element.h>
12 #include <Atlas/Bridge.h>
13 #include <Atlas/Exception.h>
46 static const int BASE_OBJECT_NO = 0;
84 int getAttrFlags()
const
95 bool hasAttr(
const std::string& name)
const;
101 const throw (NoSuchAttrException);
104 virtual int copyAttr(
const std::string& name,
107 virtual void setAttr(
const std::string& name,
110 virtual void removeAttr(
const std::string& name);
116 const Atlas::Message::MapType
asMessage()
const;
119 virtual void addToMessage(Atlas::Message::MapType &)
const;
125 inline void incRef();
126 inline void decRef();
138 virtual void free() = 0;
140 class const_iterator;
165 iterator() : m_obj(0), m_val(
"", *
this) {}
167 m_current_class(I.m_current_class),
168 m_I(I.m_I), m_val(I.m_val.first, *
this) {}
179 bool operator==(
const iterator& I)
const;
181 bool operator!=(
const iterator& I)
const {
return !operator==(I);}
201 typedef std::pair<std::string,PsuedoElement> value_type;
203 const value_type& operator*()
const {
return m_val;}
204 const value_type* operator->()
const {
return &m_val;}
209 Message::MapType::iterator m_I;
212 friend class iterator;
223 m_current_class(I.m_current_class),
224 m_I(I.m_I), m_val(I.m_val.first, *
this) {}
226 m_current_class(I.m_current_class),
227 m_I(I.m_I), m_val(I.m_val.first, *
this) {}
240 bool operator!=(
const const_iterator& I)
const {
return !operator==(I);}
255 typedef std::pair<std::string,PsuedoElement> value_type;
257 const value_type& operator*()
const {
return m_val;}
258 const value_type* operator->()
const {
return &m_val;}
263 Message::MapType::const_iterator m_I;
267 friend class const_iterator;
269 iterator begin() {
return iterator(*
this, -1);}
270 iterator end() {
return iterator(*
this, BASE_OBJECT_NO);}
271 iterator find(
const std::string&);
273 const_iterator begin()
const {
return const_iterator(*
this, -1);}
274 const_iterator end()
const {
return const_iterator(*
this, BASE_OBJECT_NO);}
275 const_iterator find(
const std::string&)
const;
280 virtual int getAttrClass(
const std::string& name)
const;
283 virtual int getAttrFlag(
const std::string& name)
const;
286 virtual void iterate(
int& current_class, std::string& attr)
const;
294 std::map<std::string, Atlas::Message::Element> m_attributes;
299 void BaseObjectData::incRef() {
303 void BaseObjectData::decRef() {
305 assert( m_refCount >= 0 );
313 BaseObjectData::iterator BaseObjectData::iterator::operator++(
int)
315 iterator tmp = *
this;
320 BaseObjectData::const_iterator BaseObjectData::const_iterator::operator++(
int)
322 const_iterator tmp = *
this;
virtual void addToMessage(Atlas::Message::MapType &) const
Write this object to an existing Element.
virtual int copyAttr(const std::string &name, Atlas::Message::Element &attr) const
Retrieve the attribute "name".
Definition: BaseObject.h:216
virtual void free()=0
Free an instance of this class, returning it to the memory pool.
Atlas stream bridge.
Definition: Bridge.h:35
const std::string & getName() const
Get the name of the attribute which does not exist.
Definition: BaseObject.h:41
The iterator first iterates over the contents of m_obj->m_attributes, holding an iterator to the attr...
Definition: BaseObject.h:159
virtual void setAttr(const std::string &name, const Atlas::Message::Element &attr)
Set the attribute "name" to the value given by "attr".
const Atlas::Message::MapType asMessage() const
Convert this object to a Object.
virtual int getAttrClass(const std::string &name) const
Find the class which contains the attribute "name".
virtual void removeAttr(const std::string &name)
Remove the attribute "name".
Multi-type container.
Definition: Element.h:59
virtual int getAttrFlag(const std::string &name) const
Find the flag for the attribute "name".
virtual bool instanceOf(int classNo) const
Is this instance of some class?
int getClassNo() const
Get class number:
Definition: BaseObject.h:79
The Atlas namespace.
Definition: Bridge.h:20
An exception indicating the requested attribute does not exist.
Definition: BaseObject.h:32
virtual void sendContents(Atlas::Bridge &b) const
Send the contents of this object to a Bridge.
Definition: BaseObject.h:183
bool hasAttr(const std::string &name) const
Check whether the attribute "name" exists.
static BaseObjectData * alloc()
Allocate a new instance of this class, using an existing instance if available.
Definition: BaseObject.h:133
virtual void iterate(int ¤t_class, std::string &attr) const
Iterate over the attributes of this instance.
bool hasAttrFlag(int flag) const
Check whether the attribute "name" exists.
virtual void removeAttrFlag(int flag)
Remove the attribute "name".
const Atlas::Message::Element getAttr(const std::string &name) const
Retrieve the attribute "name".
Definition: BaseObject.h:242
BaseObjectData(BaseObjectData *defaults)
Construct a new BaseObjectData from a subclass.
Atlas base object class.
Definition: BaseObject.h:67
Base class for all exceptions thrown by Atlas-C++.
Definition: Exception.h:17