Object Class Reference

#include <object.h>

Inheritance diagram for Object:

Inheritance graph
[legend]
Collaboration diagram for Object:

Collaboration graph
[legend]
List of all members.

Detailed Description

Base object class.

Definition at line 151 of file object.h.


Public Types

typedef std::map< ObjectId,
Object * >::const_iterator 
CIter
 Internal map constant iterator.

Public Member Functions

 DECLARE_EVENT_TABLE (Object *, ObjectEvent)
Accessors for internal data members.
std::string getName () const
 Retrieve the name of this object.
ObjectId getId () const
 Retrieve the unique identifier for this object.
void setName (const std::string &name)
 Rename this object.
ObjectgetParent () const
 Retrieve the parent of this object.
void setParent (Object *newParent)
 Change the parent of this object.
uint32_t getChildCount () const
 Retrieve the number of children this object has.
ObjectgetChild (uint32_t id) const
 Retrieve a specific child.
bool hasChildren () const
 Check if this object has children.
Customization
Modules deriving their objects from this class in order to make them available to user interface can override any of these virtual functions to describe themselves to the user interface, allow access to internal data structures and perform operations with themselves.

virtual uint8_t getDataCount () const
 Retrieve the number of data fields within this object.
virtual std::string getData (uint8_t num) const
 Retrieve the data at specific field.
virtual std::string getFieldName (uint8_t num) const
 Retrieve the data field name.
virtual DataType getFieldType (uint8_t num) const
 Retrieve the data type of the field.
virtual void getValueChoices (std::vector< std::string > *cont) const
 Fill the passed vector with possible values for this field.
virtual uint8_t getOperCount () const
 Retrieve the number of operations for this object.
virtual Operation getOper (uint8_t n) const
 Retrieve a specific operation description.
virtual void doOper (const Operation &oper)
 Perform an operation with this object.
virtual void setData (uint8_t num, const std::string &data)
 Modify the data at specific field.
Iterators and accessors for our internal data tree for easier
navigation.

The iterators are const to avoid outside world modifying our internal structures.

CIter begin () const
 Iterator to the beginning of our internal map.
CIter end () const
 Iterator to the one-past-end of our internal map.

Static Public Member Functions

static ObjectfindObject (ObjectId id)
 Static accessors for locating an object with a specific identifier from the entire hierarchy.

Protected Member Functions

 Object (Object *parent, const std::string &name="")
 Only allowed constructor.
virtual ~Object ()
 Protected destructor.
void notify (ObjectId source, ObjectEvent event)
 Notify about an event.
void notify (ObjectEvent event=OBJ_MODIFIED)
 More convenient function for derived classes - no need to pass source id, and event type has convenient default value.
Convenience methods for derived classes.
Override these functions to receive notifications about the object's contents changes.

virtual void onChildAdded (ObjectId id)
 A child has been added.
virtual void onChildRemoved (ObjectId id)
 A child has been removed (either deleted or reparented).

Private Types

typedef std::map< ObjectId,
Object * >::iterator 
Iter
 Private iterator for the internal data container.

Private Member Functions

 Object ()
 Default constructor is private - Object needs parent for construction to avoid having Object's around w/o parents.
Copying is not allowed
 Object (const Object &)
Objectoperator= (Object &)
Internal usage functions. These are private on purpose.
void addChild (Object *child)
 Add a new child.
void delChild (Object *child)
 Remove a child.

Private Attributes

Objectm_parent
 Pointer to the parent of this object.
std::string m_name
 Optional name of this object.
ObjectId m_id
 Unique identifier, assigned by parent upon addition.
std::map< ObjectId, Object * > * m_children
 Map of all child objects.

Static Private Attributes

static std::map< ObjectId,
Object * > 
s_usedIds
 Contains all identifiers currently in use and the object they refer to.

Classes

class  Operation
 Operation is a "command" one can perform with an object. More...

Member Typedef Documentation

typedef std::map<ObjectId, Object*>::const_iterator Object::CIter
 

Internal map constant iterator.

Reimplemented in ModManager.

Definition at line 204 of file object.h.

typedef std::map<ObjectId, Object*>::iterator Object::Iter [private]
 

Private iterator for the internal data container.

Reimplemented in ModManager.

Definition at line 397 of file object.h.


Constructor & Destructor Documentation

Object::Object Object parent,
const std::string &  name = ""
[protected]
 

Only allowed constructor.

Parameters:
parent Pointer to the parent object
name Optional name for this object

Definition at line 42 of file object.cpp.

References addChild(), and m_parent.

Here is the call graph for this function:

Object::~Object  )  [protected, virtual]
 

Protected destructor.

Definition at line 51 of file object.cpp.

References delChild(), m_id, m_parent, notify(), and OBJ_DESTROY.

Here is the call graph for this function:

Object::Object  )  [private]
 

Default constructor is private - Object needs parent for construction to avoid having Object's around w/o parents.

Object::Object const Object  )  [private]
 


Member Function Documentation

void Object::addChild Object child  )  [private]
 

Add a new child.

Definition at line 147 of file object.cpp.

References getRandom, logDebug(), logTrace(), m_children, m_id, notify(), OBJ_ADDED, onChildAdded(), s_usedIds, and TRACE_OBJECT.

Referenced by Object(), and setParent().

Here is the call graph for this function:

Object::CIter Object::begin  )  const
 

Iterator to the beginning of our internal map.

Reimplemented in FilesList.

Definition at line 244 of file object.cpp.

References m_children.

Object::DECLARE_EVENT_TABLE Object ,
ObjectEvent 
 

void Object::delChild Object child  )  [private]
 

Remove a child.

Definition at line 193 of file object.cpp.

References logDebug(), m_children, onChildRemoved(), and s_usedIds.

Referenced by setParent(), and ~Object().

Here is the call graph for this function:

void Object::doOper const Operation oper  )  [virtual]
 

Perform an operation with this object.

Reimplemented in FilesList.

Definition at line 96 of file object.cpp.

References logTrace(), m_name, and TRACE_OBJECT.

Here is the call graph for this function:

Object::CIter Object::end  )  const
 

Iterator to the one-past-end of our internal map.

Reimplemented in FilesList.

Definition at line 251 of file object.cpp.

References m_children.

Object * Object::findObject ObjectId  id  )  [static]
 

Static accessors for locating an object with a specific identifier from the entire hierarchy.

May return null if the object could not be found.

Definition at line 261 of file object.cpp.

References s_usedIds.

Object* Object::getChild uint32_t  id  )  const
 

Retrieve a specific child.

uint32_t Object::getChildCount  )  const
 

Retrieve the number of children this object has.

Definition at line 110 of file object.cpp.

References m_children.

std::string Object::getData uint8_t  num  )  const [virtual]
 

Retrieve the data at specific field.

Reimplemented in Prefs.

Definition at line 65 of file object.cpp.

References logTrace(), m_name, and TRACE_OBJECT.

Here is the call graph for this function:

uint8_t Object::getDataCount  )  const [virtual]
 

Retrieve the number of data fields within this object.

Reimplemented in Prefs.

Definition at line 62 of file object.cpp.

std::string Object::getFieldName uint8_t  num  )  const [virtual]
 

Retrieve the data field name.

Reimplemented in Prefs.

Definition at line 72 of file object.cpp.

References logTrace(), m_name, and TRACE_OBJECT.

Here is the call graph for this function:

DataType Object::getFieldType uint8_t  num  )  const [virtual]
 

Retrieve the data type of the field.

Definition at line 80 of file object.cpp.

References ODT_UNKNOWN.

ObjectId Object::getId  )  const [inline]
 

Retrieve the unique identifier for this object.

Definition at line 161 of file object.h.

Referenced by notify().

std::string Object::getName  )  const
 

Retrieve the name of this object.

Reimplemented in ModuleBase, and SharedFile.

Definition at line 59 of file object.cpp.

References m_name.

Object::Operation Object::getOper uint8_t  n  )  const [virtual]
 

Retrieve a specific operation description.

Reimplemented in FilesList.

Definition at line 85 of file object.cpp.

References logTrace(), m_name, and TRACE_OBJECT.

Here is the call graph for this function:

uint8_t Object::getOperCount  )  const [virtual]
 

Retrieve the number of operations for this object.

Reimplemented in FilesList.

Definition at line 82 of file object.cpp.

Object * Object::getParent  )  const
 

Retrieve the parent of this object.

Definition at line 109 of file object.cpp.

References m_parent.

void Object::getValueChoices std::vector< std::string > *  cont  )  const [virtual]
 

Fill the passed vector with possible values for this field.

Generally used in conjuction with FieldType OFT_CHOICE

Definition at line 81 of file object.cpp.

bool Object::hasChildren  )  const
 

Check if this object has children.

Definition at line 127 of file object.cpp.

References m_children.

void Object::notify ObjectEvent  event = OBJ_MODIFIED  )  [protected]
 

More convenient function for derived classes - no need to pass source id, and event type has convenient default value.

Definition at line 238 of file object.cpp.

References getId(), and notify().

Here is the call graph for this function:

void Object::notify ObjectId  source,
ObjectEvent  event
[protected]
 

Notify about an event.

The event is propagated up the objects hierarchy, and passed to all watchers of this object and all its parent objects.

Parameters:
source Event source object identifier
event Event type

Definition at line 227 of file object.cpp.

References m_parent.

Referenced by addChild(), notify(), and ~Object().

void Object::onChildAdded ObjectId  id  )  [protected, virtual]
 

A child has been added.

Definition at line 271 of file object.cpp.

Referenced by addChild().

void Object::onChildRemoved ObjectId  id  )  [protected, virtual]
 

A child has been removed (either deleted or reparented).

Definition at line 272 of file object.cpp.

Referenced by delChild().

Object& Object::operator= Object  )  [private]
 

void Object::setData uint8_t  num,
const std::string &  data
[virtual]
 

Modify the data at specific field.

Definition at line 101 of file object.cpp.

References logTrace(), m_name, and TRACE_OBJECT.

Here is the call graph for this function:

void Object::setName const std::string &  name  ) 
 

Rename this object.

Definition at line 93 of file object.cpp.

References m_name.

Referenced by SharedFile::SharedFile().

void Object::setParent Object newParent  ) 
 

Change the parent of this object.

Definition at line 135 of file object.cpp.

References addChild(), delChild(), and m_parent.

Here is the call graph for this function:


Member Data Documentation

std::map<ObjectId, Object*>* Object::m_children [private]
 

Map of all child objects.

Definition at line 419 of file object.h.

Referenced by addChild(), begin(), delChild(), end(), getChildCount(), and hasChildren().

ObjectId Object::m_id [private]
 

Unique identifier, assigned by parent upon addition.

Definition at line 416 of file object.h.

Referenced by addChild(), and ~Object().

std::string Object::m_name [private]
 

Optional name of this object.

Reimplemented in ModuleBase.

Definition at line 413 of file object.h.

Referenced by doOper(), getData(), getFieldName(), getName(), getOper(), setData(), and setName().

Object* Object::m_parent [private]
 

Pointer to the parent of this object.

Definition at line 410 of file object.h.

Referenced by getParent(), notify(), Object(), setParent(), and ~Object().

std::map< ObjectId, Object * > Object::s_usedIds [static, private]
 

Contains all identifiers currently in use and the object they refer to.

Definition at line 38 of file object.cpp.

Referenced by addChild(), delChild(), and findObject().


The documentation for this class was generated from the following files: