27 #include <blackboard/internal/memory_manager.h> 28 #include <blackboard/local.h> 29 #include <blackboard/exceptions.h> 30 #include <blackboard/bbconfig.h> 32 #include <interfaces/TestInterface.h> 34 #include <core/exceptions/system.h> 50 signal_handler(
int signum)
59 main(
int argc,
char **argv)
62 signal(SIGINT, signal_handler);
73 cout <<
"Opening interfaces.. " << flush;
76 cout <<
"success, " <<
80 cout <<
"failed! Aborting" << endl;
86 cout <<
"Trying to open second writer.. " << flush;
89 bb->
close(ti_writer_two);
90 cout <<
"BUG: Detection of second writer did NOT work!" << endl;
93 cout <<
"exception caught as expected, detected and prevented second writer!" << endl;
96 cout <<
"Printing some meminfo ===============================================" << endl;
97 cout <<
"Free chunks:" << endl;
99 cout <<
"Allocated chunks:" << endl;
102 cout <<
"End of meminfo ======================================================" << endl;
105 cout <<
"Trying to open third writer.. " << flush;
108 cout <<
"No exception as expected, different ID ok!" << endl;
109 bb->
close(ti_writer_three);
111 cout <<
"BUG: Third writer with different ID detected as another writer!" << endl;
116 <<
"Running data tests ==================================================" << endl;
118 cout <<
"Writing initial value (" 119 << TestInterface::TEST_CONSTANT <<
") into interface as TestInt" << endl;
120 ti_writer->
set_test_int( TestInterface::TEST_CONSTANT );
124 cout <<
"BUG: caught write denied exception" << endl;
128 cout <<
"Reading value from reader interface.. " << flush;
131 if ( val == TestInterface::TEST_CONSTANT ) {
132 cout <<
" success, value is " << ti_reader->
test_int() <<
" as expected" << endl;
134 cout <<
" failure, value is " << ti_reader->
test_int() <<
", expected " 135 << TestInterface::TEST_CONSTANT << endl;
139 cout <<
"Iterating over reader interface.." << endl;
144 cout <<
"done" << endl;
146 cout <<
"Harnessing interface by excessive reading and writing, use Ctrl-C to interrupt" << endl
147 <<
"If you do not see any output everything is fine" << endl;
149 int expval = ti_reader->
test_int() + 1;
156 cout <<
"BUG: caught write denied exception" << endl;
163 if ( val == expval ) {
166 cout <<
" failure, value is " << ti_reader->
test_int() <<
", expected " 173 cout <<
"Tests done" << endl;
175 bb->
close(ti_reader);
176 bb->
close(ti_writer);
void print_performance_info() const
Prints out performance info.
Interface field iterator.
const char * get_typename() const
Get type of current field as string.
void print_allocated_chunks_info() const
Print out info about allocated chunks.
Fawkes library namespace.
BlackBoard memory manager.
const char * get_value_string(const char *array_sep=", ")
Get value of current field as string.
void write()
Write from local copy into BlackBoard memory.
void set_test_int(const int32_t new_test_int)
Set test_int value.
void print_free_chunks_info() const
Print out info about free chunks.
Base class for exceptions in Fawkes.
void read()
Read from BlackBoard into local copy.
const char * get_name() const
Get name of current field.
void print_trace()
Prints trace to stderr.
InterfaceFieldIterator fields_end()
Invalid iterator.
int32_t test_int() const
Get test_int value.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
const BlackBoardMemoryManager * memory_manager() const
Get memory manager.
The BlackBoard abstract class.
Thrown if a writer is already active on an interface that writing has been requested for...
InterfaceFieldIterator fields()
Get iterator over all fields of this interface instance.
This exception is thrown if a write has been attempted on a read-only interface.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for writing.
TestInterface Fawkes BlackBoard Interface.
const char * hash_printable() const
Get printable interface hash.
virtual void close(Interface *interface)=0
Close interface.