sipxportlib  Version 3.3
UtlContainer.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _UtlContainer_h_
13 #define _UtlContainer_h_
14 
15 // SYSTEM INCLUDES
16 #include <stdlib.h>
17 
18 // APPLICATION INCLUDES
19 #include "utl/UtlDefs.h"
20 #include "utl/UtlLink.h"
21 #include "utl/UtlContainable.h"
22 #include "utl/UtlIterator.h"
23 #include "os/OsBSem.h"
24 
25 // DEFINES
26 // MACROS
27 // EXTERNAL FUNCTIONS
28 // EXTERNAL VARIABLES
29 // CONSTANTS
30 // STRUCTS
31 // TYPEDEFS
32 // FORWARD DECLARATIONS
33 
39 {
40 /* //////////////////////////// PUBLIC //////////////////////////////////// */
41 public:
42 
43  static const UtlContainableType TYPE ;
45 /* ============================ CREATORS ================================== */
46 
50  UtlContainer();
51 
55  virtual ~UtlContainer();
56 
57 /* ============================ MANIPULATORS ============================== */
58 
64  virtual UtlContainable* insert(UtlContainable* obj) = 0 ;
65 
70  virtual UtlBoolean destroy(UtlContainable*) = 0 ;
71 
75  virtual void destroyAll() = 0 ;
76 
83  virtual UtlContainable* removeReference(const UtlContainable* object) = 0;
84 
88  virtual void removeAll() = 0 ;
89 
90 /* ============================ ACCESSORS ================================= */
91 
95  virtual UtlContainable* find(const UtlContainable*) const = 0 ;
96 
97 
103  virtual unsigned hash() const;
104 
108  virtual UtlContainableType getContainableType() const;
109 
110 
111 /* ============================ INQUIRY =================================== */
112 
116  virtual UtlBoolean isEmpty() const = 0 ;
117 
121  virtual UtlBoolean contains(const UtlContainable *) const = 0 ;
122 
126  virtual size_t entries() const = 0 ;
127 
128 
135  virtual int compareTo(const UtlContainable* otherObject) const;
136 
138  static void acquireIteratorConnectionLock();
147  static void releaseIteratorConnectionLock();
149 
150 /* //////////////////////////// PROTECTED ///////////////////////////////// */
151 protected:
152  friend class UtlIterator;
153  friend class UtlInit;
154 
156  void addIterator(UtlIterator* newIterator
157  ) const; // this const is a lie, but not a detectable one...
166  void removeIterator(UtlIterator* existingIterator
168  ) const;
179  void invalidateIterators();
189  mutable OsBSem mContainerLock;
191 
192 
203 
204 /* //////////////////////////// PRIVATE /////////////////////////////////// */
205 private:
207  static OsBSem* spIteratorConnectionLock;
273  UtlContainer(const UtlContainer& copy );
274 
278  UtlContainer& operator=(const UtlContainer& copy );
279 
280 } ;
281 
282 /* ============================ INLINE METHODS ============================ */
283 
284 #endif // _UtlContainer_h_
285 
void addIterator(UtlIterator *newIterator) const
Add an iterator to the list to be notified of changes to this container.
Definition: UtlContainer.cpp:131
static void releaseIteratorConnectionLock()
Unlock the linkage between containers and iterators.
Definition: UtlContainer.cpp:126
virtual UtlContainable * removeReference(const UtlContainable *object)=0
OsBSem mContainerLock
Must be taken when making any change to container state.
Definition: UtlContainer.h:190
virtual UtlContainableType getContainableType() const
Definition: UtlContainer.cpp:97
virtual UtlBoolean isEmpty() const =0
virtual void removeAll()=0
virtual int compareTo(const UtlContainable *otherObject) const
Definition: UtlContainer.cpp:111
UtlChain mIteratorList
Definition: UtlContainer.h:202
const char *const UtlContainableType
Definition: UtlDefs.h:70
Definition: UtlIterator.h:57
Definition: UtlLink.h:49
Definition: UtlContainable.h:37
virtual unsigned hash() const
Definition: UtlContainer.cpp:87
virtual ~UtlContainer()
Definition: UtlContainer.cpp:46
static const UtlContainableType TYPE
Definition: UtlContainer.h:43
virtual void destroyAll()=0
virtual UtlBoolean contains(const UtlContainable *) const =0
Utl initializer class. Solves the problem with ordering of constructors & destructors.
Definition: UtlInit.h:40
void invalidateIterators()
Call the invalidate method on all iterators.
Definition: UtlContainer.cpp:53
int UtlBoolean
Definition: UtlDefs.h:41
static void acquireIteratorConnectionLock()
Lock the linkage between containers and iterators.
Definition: UtlContainer.cpp:120
virtual UtlContainable * find(const UtlContainable *) const =0
void removeIterator(UtlIterator *existingIterator) const
Called from iterator destructor to prevent further notices.
Definition: UtlContainer.cpp:152
UtlContainer()
Definition: UtlContainer.cpp:39
Definition: UtlContainer.h:38
virtual UtlBoolean destroy(UtlContainable *)=0
virtual size_t entries() const =0
virtual UtlContainable * insert(UtlContainable *obj)=0