1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 // As a special exception, you may use this file as part of a free software
19 // library without restriction. Specifically, if other files instantiate
20 // templates or use macros or inline functions from this file, or you compile
21 // this file and link it with other files to produce an executable, this
22 // file does not by itself cause the resulting executable to be covered by
23 // the GNU General Public License. This exception does not however
24 // invalidate any other reasons why the executable file might be covered by
25 // the GNU General Public License.
26 //
27 // This exception applies only to the code released under the name GNU
28 // Common C++. If you copy code from other releases into a copy of GNU
29 // Common C++, as the General Public License permits, the exception does
30 // not apply to the code that you add in this way. To avoid misleading
31 // anyone as to the status of such modified files, you must delete
32 // this exception notice from them.
33 //
34 // If you write modifications of your own for GNU Common C++, it is your choice
35 // whether to permit this exception to apply to your modifications.
36 // If you do not wish that, delete this exception notice.
37 //
38
45 #ifndef CCXX_OBJECT_H_
46 #define CCXX_OBJECT_H_
47
48 #ifndef CCXX_MISSING_H_
50 #endif
51
52 #ifdef CCXX_NAMESPACES
53 namespace ost {
54 #endif
55
58
67 {
68 protected:
70
72
77 {refCount = 0;};
78
84
85 public:
95 };
96
106 {
107 protected:
109
113 void detach(void);
114
119 virtual void enterLock(void);
120
125 virtual void leaveLock(void);
126
127 public:
132 {ref = NULL;};
133
140
147
149
151
153 {return getObject();};
154
156 {return getObject();};
157
158 void *getObject(void) const;
159
160 bool operator!() const;
161 };
162
171 {
172 protected:
174
176 {nextObject = NULL;};
177
179
180 public:
191
200
208 {return nextObject;};
209
218
220 };
221
230 {
231 protected:
233
235 {nextObject = prevObject = NULL;};
236
238
239 virtual void enterLock(void);
240
241 virtual void leaveLock(void);
242
244
246
247 public:
248
254 {
259 };
260
269
278
287
295 {return nextObject;};
296
303 {return prevObject;};
304
313 virtual void insert(
LinkedDouble& obj, InsertMode position = modeAtLast);
314
318 virtual void detach(void);
319
321
323 };
324
336 {
337 protected:
343
344 void cleanup(void);
345
346 public:
353
358
367 virtual unsigned getIndex(const char *id);
368
375 {return range;};
376
383 {return count;};
384
392 void *getObject(const char *id);
393
407 void *getFirst();
408
415 void *getLast();
416
424 { return NULL; };
425
435 void *getFree(void);
436
444
452
461 };
462
473 {
475
476 public :
477
482 {};
483
490 {};
491
498 {};
499
507 { return (void*)thisObject; }
508
515
522
529 { return this->operator++(); }
530
537 {
return thisObject == theIndex.
thisObject; };
538
540 { return !(*this == theIndex); };
541
549 { return thisObject == theObject; };
550
552 { return !(*this == theObject); };
553 };
554
564 {
565 protected:
571
572 public:
573
577 void detach(void);
578
585 };
586
587 #ifdef CCXX_NAMESPACES
588 }
589 #endif
590
591 #endif
592
LinkedDouble * getNext(void)
Get next object, for convenience.
InsertMode
Requested in overloaded insert() method to indicate how to insert data into list. ...
Self managed double linked list object chain.
bool operator==(const MapObject *theObject) const
Comparison operator, between the MapIndex and a MapObject, useful to avoid casts for sake of clearnes...
LinkedDouble * prevObject
bool operator!=(const MapIndex &theIndex) const
insert at first position in list pointed by current object
void * getEnd()
Get table's end, useful for cycle control; it is returned as void * for easy re-cast.
The MapIndex allows linear access into a MapTable, that otherwise could have its elements being retri...
LinkedSingle * getNext(void)
Get next object, for convenience.
A reference countable object.
Pointer to reference counted objects.
substitute functions which may be missing in target platform libc.
unsigned getSize(void)
Return the number of object stored in this table.
RefPointer()
Create an unattached pointer.
The Mutex class is used to protect a section of code so that at any given time only a single thread c...
insert at last position in list pointed by current object
void * operator->() const
LinkedDouble * getPrev(void)
Get prev object in the list.
void * getObject(void) const
LinkedSingle * nextObject
A map table allows for entities to be mapped (hash index) onto it.
The MapObject is a base class which can be used to make a derived class operate on a MapTable...
RefObject()
The constructor simply initializes the count.
MapIndex(const MapIndex &theIndex)
Creates a copy of a given map index.
MapIndex operator++(int)
Postfix increment operator, to be used in loops and such.
bool operator==(const MapIndex &theIndex) const
Comparison operator, between two MapIndex's.
void * operator*() const
Dereference operator: the pointed object it is returned as void * for easy re-cast.
Self managed single linked list object chain.
bool operator!=(const MapObject *theObject) const
MapIndex(MapObject *theObject)
Creates a map index pointing to a specific map object.
unsigned getRange(void)
Return range of this table.
MapIndex()
Creates an empty map index (pointing to nothing).
insert in list before current object