(file) Return to IDFactory.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

 1 mike  1.2 
 2           //%2006////////////////////////////////////////////////////////////////////////
 3           //
 4           // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 5           // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
 6           // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
 7           // IBM Corp.; EMC Corporation, The Open Group.
 8           // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
 9           // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
10           // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
11           // EMC Corporation; VERITAS Software Corporation; The Open Group.
12           // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
13           // EMC Corporation; Symantec Corporation; The Open Group.
14           //
15           // Permission is hereby granted, free of charge, to any person obtaining a copy
16           // of this software and associated documentation files (the "Software"), to
17           // deal in the Software without restriction, including without limitation the
18           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
19           // sell copies of the Software, and to permit persons to whom the Software is
20           // furnished to do so, subject to the following conditions:
21           // 
22 mike  1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
23           // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
24           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
25           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
26           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30           //
31           //==============================================================================
32           //
33           //%/////////////////////////////////////////////////////////////////////////////
34           
35           #ifndef Pegasus_IDFactory_h
36           #define Pegasus_IDFactory_h
37           
38           #include <Pegasus/Common/Config.h>
39           #include <Pegasus/Common/Mutex.h>
40           #include <Pegasus/Common/Stack.h>
41           #include <Pegasus/Common/Magic.h>
42           
43 mike  1.2 PEGASUS_NAMESPACE_BEGIN
44           
45           
46           /** The IDFactory provides a thread-safe interface for assigning unique 
47               integer identifiers. The getID() method is used to obtain the next unique 
48               identifier. The putID(), returns a unique identifier to the id pool. Note
49               that if putID() is never called, then getID() will assigns a sequence of
50               monotonically increasing ids.
51           */
52           class PEGASUS_COMMON_LINKAGE IDFactory
53           {
54           public:
55           
56               /** Constructor. The firstID argument is the id that is first returned
57           	by getID().
58               */
59               IDFactory(Uint32 firstID = 1);
60           
61               /** Destructor.
62               */
63               ~IDFactory();
64 mike  1.2 
65               /** Obtain the next id.
66               */
67               Uint32 getID() const;
68           
69               /** Return an id to the pool (optional).
70               */
71               void putID(Uint32 id);
72           
73 kumpf 1.3 private:
74 mike  1.2 
75               Magic<0x94E91236> _magic;
76               Stack<Uint32> _pool;
77               Uint32 _firstID;
78               Uint32 _nextID;
79               Mutex _mutex;
80           };
81           
82           PEGASUS_NAMESPACE_END
83           
84           #endif /* Pegasus_IDFactory_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2