client-cpp  0.10.0
AbstractKaaTransport.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 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 ABSTRACTKAATRANSPORT_HPP_
18 #define ABSTRACTKAATRANSPORT_HPP_
19 
25 
26 namespace kaa {
27 
28 template <TransportType Type>
30 {
31 public:
32  virtual ~AbstractKaaTransport() {}
33 
35  : type_(Type), channelManager_(channelManager), context_(context) {}
36 
37 private:
38  IDataChannelPtr getChannel(TransportType transportType = Type)
39  {
41  if (channel) {
42  return channel;
43  }
44  throw KaaException("Cannot find appropriate channel");
45  }
46 
47 protected:
48  void syncByType(TransportType transportType = Type)
49  {
50  getChannel(transportType)->sync(transportType);
51  }
52 
53  void syncAll()
54  {
55  getChannel()->syncAll();
56  }
57 
58  void syncAck(TransportType transportType = Type)
59  {
60  getChannel(transportType)->syncAck(transportType);
61  }
62 
63 protected:
67 };
68 
69 } // namespace kaa
70 
71 
72 #endif /* ABSTRACTKAATRANSPORT_HPP_ */
virtual void syncAck(TransportType type)=0
virtual void syncAll()=0
AbstractKaaTransport(IKaaChannelManager &channelManager, IKaaClientContext &context)
virtual void sync(TransportType type)=0
virtual IDataChannelPtr getChannelByTransportType(TransportType type)=0
void syncAck(TransportType transportType=Type)
IKaaChannelManager & channelManager_
void syncByType(TransportType transportType=Type)