45 #ifndef COMMONCPP_OBJECT_H_
46 #define COMMONCPP_OBJECT_H_
48 #ifndef COMMONCPP_CONFIG_H_
49 #include <commoncpp/config.h>
64 class __EXPORT RefObject
67 __DELETE_COPY(RefObject);
70 friend class RefPointer;
96 virtual void *getObject(
void) = 0;
107 class __EXPORT RefPointer
121 virtual void enterLock(
void);
127 virtual void leaveLock(
void);
133 inline RefPointer() {
142 RefPointer(RefObject *obj);
149 RefPointer(
const RefPointer &ptr);
151 virtual ~RefPointer();
153 RefPointer& operator=(
const RefObject &ref);
155 inline void *operator*()
const {
159 void *getObject(
void)
const;
161 operator bool()
const;
163 bool operator!()
const;
173 class __EXPORT LinkedSingle
176 __DELETE_COPY(LinkedSingle);
179 LinkedSingle *nextObject;
181 inline LinkedSingle() {
185 virtual ~LinkedSingle();
197 virtual LinkedSingle *getFirst(
void);
206 virtual LinkedSingle *getLast(
void);
214 inline LinkedSingle *getNext(
void) {
225 virtual void insert(LinkedSingle& obj);
227 LinkedSingle &operator+=(LinkedSingle &obj);
237 class __EXPORT LinkedDouble
240 __DELETE_COPY(LinkedDouble);
243 LinkedDouble *nextObject, *prevObject;
245 inline LinkedDouble() {
246 nextObject = prevObject = NULL;
249 virtual ~LinkedDouble();
251 virtual void enterLock(
void);
253 virtual void leaveLock(
void);
255 virtual LinkedDouble *firstObject();
257 virtual LinkedDouble *lastObject();
280 virtual LinkedDouble *getFirst(
void);
289 virtual LinkedDouble *getLast(
void);
298 virtual LinkedDouble *getInsert(
void);
306 inline LinkedDouble *getNext(
void) {
315 inline LinkedDouble *getPrev(
void) {
327 virtual void insert(LinkedDouble& obj, InsertMode position = modeAtLast);
332 virtual void detach(
void);
334 LinkedDouble &operator+=(LinkedDouble &obj);
336 LinkedDouble &operator--();
349 class __EXPORT MapTable :
public Mutex
352 __DELETE_COPY(MapTable);
355 friend class MapObject;
356 friend class MapIndex;
369 MapTable(
unsigned size);
384 virtual unsigned getIndex(
const char *
id);
391 inline unsigned getRange(
void) {
400 inline unsigned getSize(
void) {
411 void *getObject(
const char *
id);
419 void addObject(MapObject &obj);
463 void addFree(MapObject *obj);
471 MapTable &operator+=(MapObject &obj);
480 virtual MapTable &operator-=(MapObject &obj);
492 class __EXPORT MapIndex
494 MapObject* thisObject;
501 MapIndex() : thisObject(NULL) {}
508 MapIndex(MapObject* theObject) : thisObject(theObject) {}
515 MapIndex(
const MapIndex& theIndex) : thisObject(theIndex.thisObject) {}
523 void* operator*()
const {
524 return (
void*)thisObject;
532 MapIndex& operator=(MapObject *theObject);
539 MapIndex& operator++();
546 MapIndex operator++(
int) {
547 return this->operator++();
555 bool operator==(
const MapIndex& theIndex)
const {
556 return thisObject == theIndex.thisObject;
559 bool operator!=(
const MapIndex& theIndex)
const {
560 return !(*
this == theIndex);
569 bool operator==(
const MapObject* theObject)
const {
570 return thisObject == theObject;
573 bool operator!=(
const MapObject* theObject)
const {
574 return !(*
this == theObject);
586 class __EXPORT MapObject
589 __DELETE_COPY(MapObject);
592 friend class MapTable;
593 friend class MapIndex;
594 MapObject *nextObject;
595 const char *idObject;
610 MapObject(
const char *
id);