Fawkes API
Fawkes Development Version
|
25 #include <interface/message_queue.h>
26 #include <interfaces/test.h>
37 cout <<
"Iterating through messages:" << endl;
40 for (i = mq->
begin(); i != mq->
end(); ++i) {
42 cout <<
"Message " << i.
id()
44 <<
" type: " <<
typeid((*i)).name() << endl;
46 cout <<
"It's just a message" << endl;
48 cout <<
"Message " << i.
id() <<
" is not of correct type, it is " <<
typeid((*i)).name()
56 main(
int argc,
char **argv)
61 cout <<
"Message queue initialized, now appending three test messages" << endl;
68 cout <<
"m1 added with id " <<
id << endl;
70 cout <<
"m1 added with id " <<
id << endl;
72 cout <<
"m2 added with id " <<
id << endl;
74 cout <<
"m3 added with id " <<
id << endl;
76 cout <<
"m4 (of different type!) added with id " <<
id << endl;
78 cout <<
"Size is now " << mq->
size() << endl;
80 cout <<
"Unreferencing messages" << endl;
86 cout <<
"Appending m1 again" << endl;
88 cout <<
"m1 added with id " <<
id << endl;
89 cout <<
"Size is now " << mq->
size() << endl;
90 cout <<
"m1 refcount is now " << m1->
refcount() << endl;
94 cout <<
"Now removing message m1 once" << endl;
98 cout <<
"m1 has refcount " << m1->
refcount() << endl;
100 cout <<
"Now removing message m2" << endl;
104 cout <<
"Now removing message m4" << endl;
108 cout <<
"Size is now " << mq->
size() << endl;
void unref()
Decrement reference count and conditionally delete this instance.
void lock()
Lock message queue.
void unlock()
Unlock message queue.
unsigned int id() const
Get ID of current element or 0 if element is end.
unsigned int size() const
Get number of messages in queue.
bool is() const
Check if message is of given type.
MessageIterator end()
Get iterator to element beyond end of message queue list.
void append(Message *msg)
Append message to queue.
void remove(const Message *msg)
Remove message from queue.
MessageType * get() const
Get current message of given type.
unsigned int refcount()
Get reference count for this instance.
MessageIterator begin()
Get iterator to first element in message queue.