libUTL++
ObjectRegistry.h
1 #pragma once
2 
4 
5 #include <libutl/RBtree.h>
6 #include <libutl/RWlock.h>
7 
9 
10 UTL_NS_BEGIN;
11 
13 
29 
31 class ObjectRegistry : public Object
32 {
38 
39 public:
40  typedef RBtree::iterator iterator;
41 
42 public:
45  {
46  init();
47  setOrdering(ordering);
48  }
49 
50  virtual size_t innerAllocatedSize() const;
51 
53  void setOrdering(Ordering* ordering);
54 
60  Object* add(Object* object);
61 
66  void remove(Object* object);
67 
69  RWlock&
70  lock()
71  {
72  return _lock;
73  }
74 
76  iterator
78  {
79  return _objects.begin();
80  }
81 
83  iterator
84  end()
85  {
86  return _objects.end();
87  }
88 
89 private:
90  RBtree _objects;
91  mutable RWlock _lock;
92 };
93 
95 
96 UTL_NS_END;
iterator end()
Get end iterator.
#define UTL_CLASS_DEFID
Default init() and deInit() (which are merely place-holders).
Definition: macros.h:532
Read/write lock.
Definition: RWlock.h:33
Object comparison abstraction.
Definition: Ordering.h:30
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
RWlock & lock()
Access the lock.
iterator begin()
Get begin iterator.
Red/black tree.
Definition: RBtree.h:37
ObjectRegistry(Ordering *ordering)
Constructor.
In-order bi-directional BinTree iterator.
Definition: BinTreeIt.h:22
#define UTL_CLASS_NO_SERIALIZE
Declare that a class cannot do serialize().
Definition: macros.h:384
Object registry.
#define UTL_CLASS_NO_COMPARE
Declare that a class cannot do compare().
Definition: macros.h:344
#define UTL_CLASS_NO_COPY
Declare that a class cannot do copy().
Definition: macros.h:358
Root of UTL++ class hierarchy.
Definition: Object.h:52
void init()
Initialize UTL++.