00001 // 00002 00003 #ifndef __MESSAGEABLE_H 00004 #define __MESSAGEABLE_H 00005 00006 extern "C" { 00007 #include <pthread.h> 00008 }; 00009 00010 #include <deque> 00011 00012 #include "message.h" 00013 00015 class Messageable 00016 { 00017 public: 00018 Messageable(); 00019 virtual ~Messageable(); 00020 00022 void queue_message(MessageP&); 00023 00024 // XXX - we need to have something that receives messages from the queue, 00025 // and either deals with them or passes them to handle_message() 00026 // void message_receiver(??) 00027 00028 virtual std::string get_id(void) const = 0; 00029 00030 protected: 00034 MessageP get_message(void); 00035 00039 /* XXX - Where is this Data from? Who allocates it? Who free's it? */ 00040 Data *handle_message(MessageP&); 00041 00042 private: 00044 std::deque<MessageP> msg_queue; 00046 pthread_mutex_t msg_mutex; 00048 pthread_cond_t msg_avail; 00050 typedef std::deque<MessageP>::iterator queue_iterator; 00051 }; 00052 00053 #endif /* __MESSAGEABLE_H */