object.h

Go to the documentation of this file.
00001 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 // 
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 // 
00017 // As a special exception, you may use this file as part of a free software
00018 // library without restriction.  Specifically, if other files instantiate
00019 // templates or use macros or inline functions from this file, or you compile
00020 // this file and link it with other files to produce an executable, this
00021 // file does not by itself cause the resulting executable to be covered by
00022 // the GNU General Public License.  This exception does not however    
00023 // invalidate any other reasons why the executable file might be covered by
00024 // the GNU General Public License.    
00025 //
00026 // This exception applies only to the code released under the name GNU
00027 // Common C++.  If you copy code from other releases into a copy of GNU
00028 // Common C++, as the General Public License permits, the exception does
00029 // not apply to the code that you add in this way.  To avoid misleading
00030 // anyone as to the status of such modified files, you must delete
00031 // this exception notice from them.
00032 //
00033 // If you write modifications of your own for GNU Common C++, it is your choice
00034 // whether to permit this exception to apply to your modifications.
00035 // If you do not wish that, delete this exception notice.
00036 //
00037 
00044 #ifndef CCXX_OBJECT_H_
00045 #define CCXX_OBJECT_H_
00046 
00047 #ifndef CCXX_MISSING_H_
00048 #include <cc++/missing.h>
00049 #endif
00050 
00051 #ifdef  CCXX_NAMESPACES
00052 namespace ost {
00053 #endif
00054 
00055 class __EXPORT MapObject;
00056 
00064 class __EXPORT RefObject
00065 {
00066 protected:
00067         friend class RefPointer;
00068 
00069         unsigned refCount;
00070 
00074         inline RefObject()
00075                 {refCount = 0;};
00076 
00081         virtual ~RefObject();
00082 
00083 public:
00092         virtual void *getObject(void) = 0;
00093 };
00094 
00103 class __EXPORT RefPointer
00104 {
00105 protected:
00106         RefObject *ref;
00107 
00111         void detach(void);
00112 
00117         virtual void enterLock(void);
00118 
00123         virtual void leaveLock(void);
00124 
00125 public:
00129         inline RefPointer()
00130                 {ref = NULL;};
00131 
00137         RefPointer(RefObject *obj);
00138         
00144         RefPointer(const RefPointer &ptr);
00145 
00146         virtual ~RefPointer();
00147 
00148         RefPointer& operator=(const RefObject &ref);
00149 
00150         inline void *operator*() const
00151                 {return getObject();};
00152 
00153         inline void *operator->() const
00154                 {return getObject();};
00155 
00156         void *getObject(void) const;
00157 
00158         bool operator!() const;
00159 };      
00160 
00168 class __EXPORT LinkedSingle
00169 {
00170 protected:
00171         LinkedSingle *nextObject;
00172 
00173         inline LinkedSingle()
00174                 {nextObject = NULL;};
00175 
00176         virtual ~LinkedSingle();
00177 
00178 public:
00188         virtual LinkedSingle *getFirst(void);   
00189 
00197         virtual LinkedSingle *getLast(void);
00198 
00205         inline LinkedSingle *getNext(void)
00206                 {return nextObject;};
00207 
00215         virtual void insert(LinkedSingle& obj);
00216 
00217         LinkedSingle &operator+=(LinkedSingle &obj);
00218 };
00219 
00227 class __EXPORT LinkedDouble
00228 {
00229 protected:
00230         LinkedDouble *nextObject, *prevObject;
00231 
00232         inline LinkedDouble()
00233                 {nextObject = prevObject = NULL;};
00234 
00235         virtual ~LinkedDouble();
00236 
00237         virtual void enterLock(void);
00238 
00239         virtual void leaveLock(void);
00240 
00241 public:
00249         virtual LinkedDouble *getFirst(void);   
00250 
00258         virtual LinkedDouble *getLast(void);
00259 
00267         virtual LinkedDouble *getInsert(void);
00268 
00275         inline LinkedDouble *getNext(void)
00276                 {return nextObject;};
00277 
00283         inline LinkedDouble *getPrev(void)
00284                 {return prevObject;};
00285 
00291         void insert(LinkedDouble& obj);
00292 
00296         void detach(void);
00297 
00298         LinkedDouble &operator+=(LinkedDouble &obj);
00299 
00300         LinkedDouble &operator--();
00301 };
00302 
00313 class __EXPORT MapTable : public Mutex
00314 {
00315 protected:
00316         friend class MapObject;
00317         unsigned range;
00318         MapObject **map;
00319 
00320         void cleanup(void);
00321 
00322 public:
00328         MapTable(unsigned size);
00329 
00333         virtual ~MapTable();
00334 
00343         virtual unsigned getIndex(const char *id);
00344 
00350         inline unsigned getRange(void)
00351                 {return range;};
00352 
00360         void *getObject(const char *id);
00361 
00368         void addObject(MapObject &obj);
00369 
00379         void *getFree(void);
00380 
00387         void addFree(MapObject *obj);
00388 
00395         MapTable &operator+=(MapObject &obj);
00396 
00404         virtual MapTable &operator-=(MapObject &obj);
00405 };
00406 
00415 class __EXPORT MapObject
00416 {
00417 protected:
00418         friend class MapTable;
00419         MapObject *nextObject;
00420         const char *idObject;
00421         MapTable *table;
00422 
00426         void detach(void);
00427 
00433         MapObject(const char *id);
00434 };
00435  
00436 #ifdef  CCXX_NAMESPACES
00437 }
00438 #endif
00439 
00440 #endif
00441 

Generated on Fri Dec 15 17:41:25 2006 for GNU CommonC++ by  doxygen 1.5.1