23 #ifndef __BLACKBOARD_BLACKBOARD_H_ 24 #define __BLACKBOARD_BLACKBOARD_H_ 26 #include <core/exceptions/software.h> 27 #include <interface/interface.h> 38 class BlackBoardInterfaceManager;
39 class BlackBoardMemoryManager;
40 class BlackBoardMessageManager;
41 class BlackBoardNetworkHandler;
42 class BlackBoardNotifier;
43 class InterfaceInfoList;
44 class BlackBoardInterfaceListener;
45 class BlackBoardInterfaceObserver;
46 class FawkesNetworkHub;
53 virtual Interface * open_for_reading(
const char *interface_type,
54 const char *identifier,
55 const char *owner = NULL) = 0;
56 virtual Interface * open_for_writing(
const char *interface_type,
57 const char *identifier,
58 const char *owner = NULL) = 0;
59 virtual void close(
Interface *interface) = 0;
61 virtual Interface * open_for_reading_f(
const char *interface_type,
62 const char *identifier, ...);
63 virtual Interface * open_for_writing_f(
const char *interface_type,
64 const char *identifier, ...);
69 const char *id_pattern) = 0;
70 virtual bool is_alive()
const throw() = 0;
71 virtual bool try_aliveness_restore()
throw() = 0;
73 virtual std::list<Interface *>
74 open_multiple_for_reading(
const char *type_pattern,
75 const char *id_pattern =
"*",
76 const char *owner = NULL) = 0;
78 template <
class InterfaceType>
79 std::list<InterfaceType *>
80 open_multiple_for_reading(
const char *id_pattern =
"*",
81 const char *owner = NULL);
83 template <
class InterfaceType>
84 InterfaceType * open_for_reading(
const char *identifier,
85 const char *owner = NULL);
87 template <
class InterfaceType>
88 InterfaceType * open_for_writing(
const char *identifier,
89 const char *owner = NULL);
91 template <
class InterfaceType>
92 InterfaceType * open_for_reading_f(
const char *identifier, ...);
94 template <
class InterfaceType>
95 InterfaceType * open_for_writing_f(
const char *identifier, ...);
100 BBIL_FLAG_MESSAGES = 2,
101 BBIL_FLAG_READER = 4,
102 BBIL_FLAG_WRITER = 8,
104 } ListenerRegisterFlag;
107 ListenerRegisterFlag flag = BBIL_FLAG_ALL);
109 ListenerRegisterFlag flag = BBIL_FLAG_ALL);
115 std::string demangle_fawkes_interface_name(
const char *type);
116 std::string format_identifier(
const char *identifier_format, va_list arg);
141 template <
class InterfaceType>
143 BlackBoard::open_for_reading(
const char *identifier,
const char *owner)
145 std::string type_name =
146 demangle_fawkes_interface_name(
typeid(InterfaceType).name());
147 Interface *
interface = open_for_reading(type_name.c_str(), identifier, owner);
148 return static_cast<InterfaceType *
>(interface);
165 template <
class InterfaceType>
167 BlackBoard::open_for_reading_f(
const char *identifier, ...)
170 va_start(arg, identifier);
171 std::string type_name =
172 demangle_fawkes_interface_name(
typeid(InterfaceType).name());
173 std::string identifier_s = format_identifier(identifier, arg);
175 Interface *
interface = open_for_reading(type_name.c_str(), identifier_s.c_str());
176 return static_cast<InterfaceType *
>(interface);
191 template <
class InterfaceType>
192 std::list<InterfaceType *>
193 BlackBoard::open_multiple_for_reading(
const char *id_pattern,
const char *owner)
195 std::string type_name =
196 demangle_fawkes_interface_name(
typeid(InterfaceType).name());
197 std::list<Interface *> il =
198 open_multiple_for_reading(type_name.c_str(), id_pattern, owner);
199 std::list<InterfaceType *> rv;
200 for (std::list<Interface *>::iterator i = il.begin(); i != il.end(); ++i) {
201 rv.push_back(static_cast<InterfaceType *>(*i));
225 template <
class InterfaceType>
227 BlackBoard::open_for_writing(
const char *identifier,
const char *owner)
229 std::string type_name =
230 demangle_fawkes_interface_name(
typeid(InterfaceType).name());
231 Interface *
interface = open_for_writing(type_name.c_str(), identifier, owner);
232 return static_cast<InterfaceType *
>(interface);;
251 template <
class InterfaceType>
253 BlackBoard::open_for_writing_f(
const char *identifier, ...)
256 va_start(arg, identifier);
257 std::string type_name =
258 demangle_fawkes_interface_name(
typeid(InterfaceType).name());
259 std::string identifier_s = format_identifier(identifier, arg);
261 Interface *
interface = open_for_writing(type_name.c_str(), identifier_s.c_str());
262 return static_cast<InterfaceType *
>(interface);;
284 inline BlackBoard::ListenerRegisterFlag
ListenerRegisterFlag
Flags to constrain listener registration/updates.
BlackBoard::ListenerRegisterFlag operator|(const BlackBoard::ListenerRegisterFlag &a, const BlackBoard::ListenerRegisterFlag &b)
Concatenation of register flags.
Fawkes library namespace.
Base class for all Fawkes BlackBoard interfaces.
Interface information list.
BlackBoardNotifier * __notifier
Notifier for BB events.
BlackBoard interface observer.
The BlackBoard abstract class.
BlackBoard::ListenerRegisterFlag operator &(const BlackBoard::ListenerRegisterFlag &a, const BlackBoard::ListenerRegisterFlag &b)
Testing of register flags.
BlackBoard interface listener.