Go to the documentation of this file.
45 #ifndef COMMONCPP_OBJECT_H_
46 #define COMMONCPP_OBJECT_H_
48 #ifndef COMMONCPP_CONFIG_H_
49 #include <commoncpp/config.h>
155 inline void *operator*()
const {
159 void *getObject(
void)
const;
161 operator bool()
const;
163 bool operator!()
const;
246 nextObject = prevObject = NULL;
251 virtual void enterLock(
void);
253 virtual void leaveLock(
void);
524 return (
void*)thisObject;
547 return this->operator++();
556 return thisObject == theIndex.thisObject;
559 bool operator!=(
const MapIndex& theIndex)
const {
560 return !(*
this == theIndex);
570 return thisObject == theObject;
573 bool operator!=(
const MapObject* theObject)
const {
574 return !(*
this == theObject);
595 const char *idObject;
virtual MapTable & operator-=(MapObject &obj)
This operator is virtual in case it must also add the object to a managed free list.
@ modeAtFirst
insert at first position in list pointed by current object
virtual void detach(void)
Remove object from chain.
void addObject(MapObject &obj)
Map an object to our table.
Self managed double linked list object chain.
void addFree(MapObject *obj)
Add an object to the managed free list.
virtual ~MapTable()
Destroy the table, calls cleanup.
MapIndex & operator=(MapObject *theObject)
Assignment operator to avoid implicit cast.
virtual LinkedSingle * getLast(void)
Gets the last object in the list.
RefObject()
The constructor simply initializes the count.
MapIndex(const MapIndex &theIndex)
Creates a copy of a given map index.
@ modeAtLast
insert at last position in list pointed by current object
MapObject(const char *id)
Save id, mark as not using any table.
RefPointer()
Create an unattached pointer.
void * getFirst()
Get the first element into table, it is returned as void * for easy re-cast.
MapTable & operator+=(MapObject &obj)
An operator to map an object to the table.
virtual void insert(LinkedDouble &obj, InsertMode position=modeAtLast)
Insert object into chain at given pos, as indicated by InsertMode; If no pos is given,...
InsertMode
Requested in overloaded insert() method to indicate how to insert data into list.
unsigned getRange(void)
Return range of this table.
MapTable(unsigned size)
Create a map table with a specified number of slots.
LinkedDouble * getNext(void)
Get next object, for convenience.
void * getLast()
Get the last element into table, it is returned as void * for easy re-cast.
virtual void insert(LinkedSingle &obj)
Insert object into chain.
@ modeBefore
insert in list before current object
The MapIndex allows linear access into a MapTable, that otherwise could have its elements being retri...
Self managed single linked list object chain.
bool operator==(const MapIndex &theIndex) const
Comparison operator, between two MapIndex's.
virtual unsigned getIndex(const char *id)
Get index value from id string.
LinkedDouble * getPrev(void)
Get prev object in the list.
bool operator==(const MapObject *theObject) const
Comparison operator, between the MapIndex and a MapObject, useful to avoid casts for sake of clearnes...
The MapObject is a base class which can be used to make a derived class operate on a MapTable.
RefPointer(RefObject *obj)
Create a pointer attached to a reference counted object.
void * getObject(const char *id)
Lookup an object by id key.
virtual LinkedDouble * getInsert(void)
Virtual to get the insert point to use when adding new members.
void * operator*() const
Dereference operator: the pointed object it is returned as void * for easy re-cast.
A reference countable object.
MapIndex()
Creates an empty map index (pointing to nothing).
void * getEnd()
Get table's end, useful for cycle control; it is returned as void * for easy re-cast.
MapIndex & operator++()
Prefix increment operator, to be used in loops and such.
A map table allows for entities to be mapped (hash index) onto it.
MapIndex(MapObject *theObject)
Creates a map index pointing to a specific map object.
Pointer to reference counted objects.
virtual void * getObject(void)=0
The actual object being managed can be returned by this method as a void and then recast to the actua...
virtual LinkedSingle * getFirst(void)
Get first linked object in list.
void * getFree(void)
Get next object from managed free list.
unsigned getSize(void)
Return the number of object stored in this table.
virtual void leaveLock(void)
Patch point for a mutex in derived class.
virtual LinkedDouble * getLast(void)
Gets the last object in the list.
MapIndex operator++(int)
Postfix increment operator, to be used in loops and such.
void detach(void)
Detach current object, for example, when changing pointer.
virtual void enterLock(void)
Patch point for mutex in derived class.
virtual LinkedDouble * getFirst(void)
Get first linked object in list.
RefPointer(const RefPointer &ptr)
A copy constructor.
void detach(void)
Remove the object from it's current table.
virtual ~RefObject()
The destructor is called when the reference count returns to zero.
LinkedSingle * getNext(void)
Get next object, for convenience.