• Main Page
  • Related Pages
  • Classes
  • Files
  • File List

src/Subscriber.hh

00001 /*
00002  * This file is part of peekabot.
00003  *
00004  * peekabot is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 3 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * peekabot is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef __PEEKABOT_SUBSCRIBER_HH
00019 #define __PEEKABOT_SUBSCRIBER_HH
00020 
00021 
00022 #include <set>
00023 #include <boost/thread/recursive_mutex.hpp>
00024 
00025 #include "Message.hh"
00026 
00027 
00028 namespace peekabot
00029 {
00030 
00031 
00038     class Subscriber
00039     {
00040         friend class MessageHub;
00041 
00042     public:
00046         virtual void handle_message(const Message &) throw() = 0;
00047 
00052         virtual ~Subscriber();
00053 
00054     private:
00062         void add_subscription(MessageType type, MessageHub *hub) throw();
00063 
00071         void remove_subscription(MessageType type, MessageHub *hub) throw();
00072 
00073     private:
00078         typedef std::set<std::pair<MessageType, MessageHub *> > SubscriptionSet;
00079 
00085         SubscriptionSet m_subscriptions;
00086 
00090         mutable boost::recursive_mutex m_mutex;
00091     };
00092 
00093 }
00094 
00095 
00096 #endif // __PEEKABOT_SUBSCRIBER_HH

Generated on Sun Jan 30 2011 for peekabot by  doxygen 1.7.1