client-cpp  0.7.4
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 
20 #include <vector>
21 
22 #include "kaa/KaaThread.hpp"
26 #include "kaa/utils/KaaTimer.hpp"
27 
28 namespace kaa {
29 
30 class BootstrapManager : public IBootstrapManager, public boost::noncopyable {
31 public:
32  BootstrapManager() : bootstrapTransport_(nullptr), channelManager_(nullptr), retryTimer_("BootstrapManager retryTimer") { }
34 
35  virtual void setFailoverStrategy(IFailoverStrategyPtr strategy);
36  virtual void receiveOperationsServerList();
37  virtual void useNextOperationsServer(const TransportProtocolId& protocolId);
38  virtual void useNextOperationsServerByAccessPointId(std::int32_t id);
39  virtual void setTransport(IBootstrapTransport* transport);
40  virtual void setChannelManager(IKaaChannelManager* manager);
41  virtual void onServerListUpdated(const std::vector<ProtocolMetaData>& operationsServers);
42 
43 private:
44  typedef std::vector<ITransportConnectionInfoPtr> OperationsServers;
45 
46  OperationsServers getOPSByAccessPointId(std::int32_t id);
47  void notifyChannelManangerAboutServer(const OperationsServers& servers);
48 
49 private:
50  std::map<TransportProtocolId, OperationsServers > operationServers_;
51  std::map<TransportProtocolId, OperationsServers::iterator > lastOperationsServers_;
52 
53  BootstrapTransport *bootstrapTransport_;
54  IKaaChannelManager *channelManager_;
55 
56  IFailoverStrategyPtr failoverStrategy_;
57 
58  std::unique_ptr<std::int32_t> serverToApply;
59 
60  KaaTimer<void ()> retryTimer_;
61 
62  KAA_R_MUTEX_MUTABLE_DECLARE(guard_);
63 };
64 
65 }
66 
67 
68 
69 #endif /* BOOTSTRAPMANAGER_HPP_ */
virtual void setTransport(IBootstrapTransport *transport)
std::shared_ptr< IFailoverStrategy > IFailoverStrategyPtr
virtual void setFailoverStrategy(IFailoverStrategyPtr strategy)
virtual void setChannelManager(IKaaChannelManager *manager)
virtual void useNextOperationsServer(const TransportProtocolId &protocolId)
virtual void useNextOperationsServerByAccessPointId(std::int32_t id)
virtual void onServerListUpdated(const std::vector< ProtocolMetaData > &operationsServers)
virtual void receiveOperationsServerList()