Line | |
---|
1 | // Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
|
---|
2 | // http://chaosforge.org/
|
---|
3 | //
|
---|
4 | // This file is part of NV Libraries.
|
---|
5 | // For conditions of distribution and use, see copyright notice in nv.hh
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * @file uid.hh
|
---|
9 | * @author Kornel Kisielewicz
|
---|
10 | * @brief Implements a unique identifier class manager
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef NV_UID_HH
|
---|
14 | #define NV_UID_HH
|
---|
15 |
|
---|
16 | #include <nv/common.hh>
|
---|
17 | #include <unordered_map>
|
---|
18 |
|
---|
19 | namespace nv
|
---|
20 | {
|
---|
21 | class uid_store
|
---|
22 | {
|
---|
23 | public:
|
---|
24 | uid_store();
|
---|
25 | object* get( uid auid ) const;
|
---|
26 | bool remove( uid auid );
|
---|
27 | void insert( object* o, uid auid );
|
---|
28 | uid insert( object* o );
|
---|
29 | uid request_uid();
|
---|
30 | ~uid_store();
|
---|
31 | template< typename T >
|
---|
32 | T* get_as( uid auid ) const
|
---|
33 | {
|
---|
34 | return dynamic_cast< T* >( get(auid) );
|
---|
35 | }
|
---|
36 | private:
|
---|
37 | typedef std::unordered_map< uid, object* > map;
|
---|
38 | map m_map;
|
---|
39 | uid m_current;
|
---|
40 | };
|
---|
41 | }
|
---|
42 |
|
---|
43 | #endif // NV_UID_HH
|
---|
Note: See
TracBrowser
for help on using the repository browser.