26 #include <blackboard/bbconfig.h>
27 #include <blackboard/exceptions.h>
28 #include <blackboard/internal/memory_manager.h>
29 #include <blackboard/local.h>
30 #include <core/exceptions/system.h>
31 #include <interfaces/TestInterface.h>
45 signal_handler(
int signum)
53 main(
int argc,
char **argv)
55 signal(SIGINT, signal_handler);
66 cout <<
"Opening interfaces.. " << flush;
73 cout <<
"failed! Aborting" << endl;
79 cout <<
"Trying to open second writer.. " << flush;
82 bb->
close(ti_writer_two);
83 cout <<
"BUG: Detection of second writer did NOT work!" << endl;
86 cout <<
"exception caught as expected, detected and prevented second writer!" << endl;
89 cout <<
"Printing some meminfo ===============================================" << endl;
90 cout <<
"Free chunks:" << endl;
92 cout <<
"Allocated chunks:" << endl;
95 cout <<
"End of meminfo ======================================================" << endl;
98 cout <<
"Trying to open third writer.. " << flush;
101 cout <<
"No exception as expected, different ID ok!" << endl;
102 bb->
close(ti_writer_three);
104 cout <<
"BUG: Third writer with different ID detected as another writer!" << endl;
110 <<
"Running data tests ==================================================" << endl;
112 cout <<
"Writing initial value (" << TestInterface::TEST_CONSTANT <<
") into interface as TestInt"
118 cout <<
"BUG: caught write denied exception" << endl;
122 cout <<
"Reading value from reader interface.. " << flush;
125 if (val == TestInterface::TEST_CONSTANT) {
126 cout <<
" success, value is " << ti_reader->
test_int() <<
" as expected" << endl;
128 cout <<
" failure, value is " << ti_reader->
test_int() <<
", expected "
129 << TestInterface::TEST_CONSTANT << endl;
132 cout <<
"Iterating over reader interface.." << endl;
135 printf(
"Name: %20s Type: %10s Value: %s\n",
140 cout <<
"done" << endl;
142 cout <<
"Harnessing interface by excessive reading and writing, use Ctrl-C to interrupt" << endl
143 <<
"If you do not see any output everything is fine" << endl;
145 int expval = ti_reader->
test_int() + 1;
152 cout <<
"BUG: caught write denied exception" << endl;
162 cout <<
" failure, value is " << ti_reader->
test_int() <<
", expected " << expval << endl;
168 cout <<
"Tests done" << endl;
170 bb->
close(ti_reader);
171 bb->
close(ti_writer);
BlackBoard memory manager.
void print_free_chunks_info() const
Print out info about free chunks.
void print_allocated_chunks_info() const
Print out info about allocated chunks.
void print_performance_info() const
Prints out performance info.
Thrown if a writer is already active on an interface that writing has been requested for.
The BlackBoard abstract class.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for writing.
virtual void close(Interface *interface)=0
Close interface.
Base class for exceptions in Fawkes.
void print_trace() noexcept
Prints trace to stderr.
Interface field iterator.
const char * get_name() const
Get name of current field.
const char * get_value_string(const char *array_sep=", ")
Get value of current field as string.
const char * get_typename() const
Get type of current field as string.
This exception is thrown if a write has been attempted on a read-only interface.
const char * hash_printable() const
Get printable interface hash.
InterfaceFieldIterator fields_end()
Invalid iterator.
void write()
Write from local copy into BlackBoard memory.
InterfaceFieldIterator fields()
Get iterator over all fields of this interface instance.
void read()
Read from BlackBoard into local copy.
const BlackBoardMemoryManager * memory_manager() const
Get memory manager.
TestInterface Fawkes BlackBoard Interface.
void set_test_int(const int32_t new_test_int)
Set test_int value.
int32_t test_int() const
Get test_int value.
Fawkes library namespace.