Pol  Revision:cb584c9
objecthash.h
Go to the documentation of this file.
1 
7 #ifndef __OBJECTHASH_H
8 #define __OBJECTHASH_H
9 
10 #include <map>
11 #include <unordered_set>
12 #include <utility>
13 
14 #include "../clib/rawtypes.h"
15 #include "reftypes.h"
16 
17 namespace Pol
18 {
19 namespace Core
20 {
21 class UObject;
22 } // namespace Core
23 } // namespace Pol
24 
25 namespace Pol
26 {
27 namespace Clib
28 {
29 class StreamWriter;
30 }
31 
32 namespace Core
33 {
34 /*
35 template <class _Key> struct myhash { };
36 _STLP_TEMPLATE_nullptr struct myhash<UObject*> {
37 size_t operator()(UObject* obj) const { return obj->serial; }
38 };
39 */
41 {
42 public:
43  typedef std::unordered_set<u32> ds;
44  typedef std::pair<u32, UObjectRef> hashpair;
45  typedef std::map<u32, UObjectRef> hs;
46  typedef hs::iterator OH_iterator;
47  typedef hs::const_iterator OH_const_iterator;
48 
49  ObjectHash();
50  ~ObjectHash();
51 
52  bool Insert( UObject* obj );
53  bool Remove( u32 serial );
54  void Clear();
55  void Reap();
56 
57  UObject* Find( u32 serial );
58  u32 GetNextUnusedItemSerial();
59  u32 GetNextUnusedCharSerial();
60  void PrintContents( Clib::StreamWriter& sw ) const;
61 
62  hs::const_iterator begin() const;
63  hs::const_iterator end() const;
64  void ClearCharacterAccountReferences();
65 
66  ds::const_iterator dirty_deleted_begin() const;
67  ds::const_iterator dirty_deleted_end() const;
68 
69  void CleanDeleted();
70  void ClearDeleted();
71 
72  void RegisterCleanDeletedSerial( u32 serial );
73 
74 private:
75  hs hash;
76  OH_iterator reap_iterator;
77 
80 };
81 }
82 }
83 #endif
std::map< u32, UObjectRef > hs
Definition: objecthash.h:45
std::unordered_set< u32 > ds
Definition: objecthash.h:43
hs::const_iterator OH_const_iterator
Definition: objecthash.h:47
OH_iterator reap_iterator
Definition: objecthash.h:76
hs::iterator OH_iterator
Definition: objecthash.h:46
unsigned int u32
Definition: rawtypes.h:27
std::pair< u32, UObjectRef > hashpair
Definition: objecthash.h:44
Definition: berror.cpp:12