21 #include <tjutils/tjutils.h>
22 #include <tjutils/tjthread.h>
30 class HandlerComponent {
32 static const char* get_compName();
38 template<
class I>
class Handled;
52 Handler(
const Handler& handler);
54 Handler& operator = (
const Handler& handler);
58 const Handler& clear_handledobj()
const;
60 const Handler& set_handled(I handled)
const;
62 I get_handled()
const;
66 friend class Handled<I>;
68 const Handler& handled_remove(Handled<I>* handled)
const;
85 bool is_handled()
const {
return bool(handlers.size());}
88 friend class Handler<I>;
90 const Handled& set_handler(
const Handler<I>& handler)
const;
91 const Handled& erase_handler(
const Handler<I>& handler)
const;
93 mutable STD_list< const Handler<I>* > handlers;
104 typedef STD_map<STD_string, SingletonBase*> SingletonMap;
107 class SingletonBase {
110 virtual void* get_ptr()
const = 0;
112 static SingletonMap* get_singleton_map();
113 static void set_singleton_map_external(SingletonMap* extmap);
117 virtual ~SingletonBase() {}
119 static STD_string get_singleton_label(SingletonBase* sing_ptr);
120 static void* get_external_map_ptr(
const STD_string& sing_label);
122 static SingletonMap* singleton_map;
123 static SingletonMap* singleton_map_external;
137 LockProxy(
volatile T* r,
Mutex* m) : presource(
const_cast<T*
>(r)), pmutex(m) {
if(pmutex) pmutex->
lock();}
139 T* operator -> () {
return presource;}
165 template<
class T,
bool thread_safe>
180 void init (
const char* unique_label);
191 void copy(T& destination)
const;
214 operator bool ()
const {
return (
bool)get_map_ptr();}
221 void* get_ptr()
const {
return ptr;}
223 T* get_map_ptr()
const;
227 STD_string* singleton_label;
LockProxy< T > operator->()
void init(const char *unique_label)
void copy(T &destination) const