client-cpp  0.0.1-SNAPSHOT
NotificationManager.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef DEFAULTNOTIFICATONMANAGER_HPP_
18 #define DEFAULTNOTIFICATONMANAGER_HPP_
19 
20 #include <map>
21 #include <string>
22 
23 #include <boost/signals2.hpp>
24 #include <boost/thread/mutex.hpp>
25 #include <boost/shared_ptr.hpp>
26 
28 #include "kaa/gen/EndpointGen.hpp"
34 
35 namespace kaa {
36 
38 public:
44 
51  virtual void updateTopicSubscriptions(const TopicSubscribers& subscribers);
52 
58  virtual void addMandatoryTopicsListener(INotificationListener* listener);
59 
65 
70  virtual void addTopicsListener(INotificationTopicsListener* listener);
71 
76  virtual void removeTopicsListener(INotificationTopicsListener* listener);
77 
82  virtual void topicsListUpdated(const Topics& topics);
83 
88  virtual void notificationReceived(const Notifications& notifications);
89 
93  virtual const std::map<std::string, Topic>& getTopics() {
94  return topics_;
95  }
96 
100  virtual void setTransport(boost::shared_ptr<NotificationTransport> transport);
101 private:
102  void updateSubscriptionInfo(const std::string& id, SubscriptionCommandType type);
103  void onSubscriptionInfoUpdated();
104 
105 private:
106  typedef boost::signals2::signal<void (const Topics&)> TopicListeners;
107 
108  typedef boost::signals2::signal<void (const std::string&
109  , const std::vector<boost::uint8_t>& )> NotificationListeners;
110 
111 private:
112  boost::shared_ptr<NotificationTransport> transport_;
113  IKaaClientStateStoragePtr clientStatus_;
114 
115  std::map<std::string/*Topic ID*/, Topic> topics_;
116  boost::mutex topicsGuard_;
117 
118  TopicListeners topicListeners_;
119  NotificationListeners mandatoryListeners_;
120 
121  std::map<std::string/*Topic ID*/, boost::shared_ptr<NotificationListeners> > notificationListeners_;
122  boost::mutex notificationListenersGuard_;
123 
124  SubscriptionCommands subscriptions_;
125 };
126 
127 } /* namespace kaa */
128 
129 #endif /* DEFAULTNOTIFICATONMANAGER_HPP_ */
virtual const std::map< std::string, Topic > & getTopics()
boost::shared_ptr< IKaaClientStateStorage > IKaaClientStateStoragePtr
virtual void notificationReceived(const Notifications &notifications)
NotificationManager(IKaaClientStateStoragePtr status)
virtual void topicsListUpdated(const Topics &topics)
virtual void addMandatoryTopicsListener(INotificationListener *listener)
virtual void removeMandatoryTopicsListener(INotificationListener *listener)
virtual void updateTopicSubscriptions(const TopicSubscribers &subscribers)
std::multimap< std::string, TopicSubscriberInfo > TopicSubscribers
virtual void addTopicsListener(INotificationTopicsListener *listener)
std::vector< Notification > Notifications
std::list< SubscriptionCommand > SubscriptionCommands
virtual void setTransport(boost::shared_ptr< NotificationTransport > transport)
std::vector< Topic > Topics
virtual void removeTopicsListener(INotificationTopicsListener *listener)