sipxportlib  Version 3.3
OsLockingList.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 _OsLockingList_h_
13 #define _OsLockingList_h_
14 
15 // SYSTEM INCLUDES
16 // APPLICATION INCLUDES
17 #include <os/OsMutex.h>
18 #include "utl/UtlDList.h"
19 #include "utl/UtlDListIterator.h"
20 #include "utl/UtlVoidPtr.h"
21 
22 // DEFINES
23 // MACROS
24 // EXTERNAL FUNCTIONS
25 // EXTERNAL VARIABLES
26 // CONSTANTS
27 // STRUCTS
28 // TYPEDEFS
29 // FORWARD DECLARATIONS
30 
31 //:
32 //
34 {
35 /* //////////////////////////// PUBLIC //////////////////////////////////// */
36 public:
37 
38 /* ============================ CREATORS ================================== */
39 
40  OsLockingList();
41  //:Default constructor
42 
43  virtual
45  //:Destructor
46 
47 /* ============================ MANIPULATORS ============================== */
48 
49  int getIteratorHandle();
50  //: Get a handle to lock the list and allow safe iteration
51 
52  void resetIterator(int iteratorHandle);
53  //: Reset the iterator back to the beginning
54 
55  void* next(int iteratorHandle);
56  //: Get without removing the next element
57 
58  void* remove(int iteratorHandle);
59  //: Get and remove the pointer at the current element
60 
61  void releaseIteratorHandle(int iteratorHandle);
62  //: Release the iterator lock so that other methods may be used
63 
64  void push(void* element);
65  //: Add an element to the end
66  // This method blocks while the iterator is outstanding or other
67  // methods are in use. A NULL element is not allowed.
68 
69  void* pop();
70  //: Get and remove the last element
71  // This method blocks while the iterator is outstanding or other
72  // methods are in use.
73 
74  int getCount();
75  //: Get the number of elements in the list
76 
77 /* ============================ ACCESSORS ================================= */
78 
79 /* ============================ INQUIRY =================================== */
80 
81 /* //////////////////////////// PROTECTED ///////////////////////////////// */
82 protected:
83 
84 /* //////////////////////////// PRIVATE /////////////////////////////////// */
85 private:
86 
87  OsMutex listMutex;
88  int iteratorLockCount;
89  UtlDList list;
90  UtlDListIterator* listIterator;
91  UtlVoidPtr* currentElement;
92 
93  void assertIterator(int iteratorHandle);
94 
95  OsLockingList& operator=(const OsLockingList& rhs);
96  //:Assignment operator
97 
98  OsLockingList(const OsLockingList& rOsLockingList);
99  //:Copy constructor
100 
101 };
102 
103 /* ============================ INLINE METHODS ============================ */
104 
105 #endif // _OsLockingList_h_
106 
void push(void *element)
Definition: OsLockingList.cpp:70
Definition: OsLockingList.h:33
void releaseIteratorHandle(int iteratorHandle)
Definition: OsLockingList.cpp:111
void resetIterator(int iteratorHandle)
Definition: OsLockingList.cpp:121
OsLockingList()
Definition: OsLockingList.cpp:30
void * next(int iteratorHandle)
Definition: OsLockingList.cpp:128
void * pop()
Definition: OsLockingList.cpp:80
int getIteratorHandle()
Definition: OsLockingList.cpp:98
virtual ~OsLockingList()
Definition: OsLockingList.cpp:46
Definition: UtlDList.h:36
Definition: UtlDListIterator.h:37
int getCount()
Definition: OsLockingList.cpp:162
UtlVoidPtr is a UtlContainable wrapper for a void ptr.
Definition: UtlVoidPtr.h:41