client-cpp  0.0.1-SNAPSHOT
BootstrapManager.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 BOOTSTRAPMANAGER_HPP_
18 #define BOOTSTRAPMANAGER_HPP_
19 
22 #include "kaa/gen/BootstrapGen.hpp"
23 
24 #include <boost/thread/recursive_mutex.hpp>
25 
26 namespace kaa {
27 
28 class BootstrapManager : public IBootstrapManager, public boost::noncopyable {
29 public:
32 
33  virtual void receiveOperationsServerList();
34  virtual void useNextOperationsServer(ChannelType type);
35  virtual void useNextOperationsServerByDnsName(const std::string& name);
36  virtual void setTransport(IBootstrapTransport* transport);
37  virtual void setChannelManager(IKaaChannelManager* manager);
38  virtual void onServerListUpdated(const OperationsServerList& list);
39  virtual const std::vector<OperationsServer>& getOperationsServerList();
40 
41 private:
42 
43  const OperationsServer* getOPSByDnsName(const std::string& name);
44  IServerInfoPtr getServerInfoByChannel(const OperationsServer& server, const SupportedChannel& channel);
45  IServerInfoPtr getServerInfoByChannelType(const OperationsServer& server, ChannelType channelType);
46  void notifyChannelManangerAboutServer(const OperationsServer& server);
47 
48  std::vector<OperationsServer> operationServerList_;
49  std::map<ChannelType, std::vector<OperationsServer> > operationServers_;
50  std::map<ChannelType, /*std::vector<OperationsServer>::const_iterator*/ size_t > operationServersIterators_;
51 
52  BootstrapTransport *bootstrapTransport_;
53  IKaaChannelManager *channelManager_;
54 
55  std::string serverToApply;
56  mutable boost::recursive_mutex guard_;
57 };
58 
59 }
60 
61 
62 
63 #endif /* BOOTSTRAPMANAGER_HPP_ */
virtual void setTransport(IBootstrapTransport *transport)
virtual void useNextOperationsServerByDnsName(const std::string &name)
virtual void setChannelManager(IKaaChannelManager *manager)
virtual const std::vector< OperationsServer > & getOperationsServerList()
boost::shared_ptr< IServerInfo > IServerInfoPtr
Definition: IServerInfo.hpp:55
virtual void useNextOperationsServer(ChannelType type)
virtual void receiveOperationsServerList()
virtual void onServerListUpdated(const OperationsServerList &list)