client-cpp  0.7.0
AbstractKaaTransport.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 ABSTRACTKAATRANSPORT_HPP_
18 #define ABSTRACTKAATRANSPORT_HPP_
19 
24 
25 namespace kaa {
26 
27 template <TransportType Type>
29 {
30 public:
31  virtual ~AbstractKaaTransport() {}
32 
34  : type_(Type), channelManager_(channelManager), clientStatus_(nullptr) {}
35 
37  {
38  if (status) {
39  clientStatus_ = status;
40  }
41  }
42 
43 private:
44  IDataChannelPtr getChannel(TransportType transportType = Type)
45  {
47  if (channel) {
48  return channel;
49  }
50  throw KaaException("Cannot find appropriate channel");
51  }
52 
53 protected:
54  void syncByType(TransportType transportType = Type)
55  {
56  getChannel(transportType)->sync(transportType);
57  }
58 
59  void syncAll()
60  {
61  getChannel()->syncAll();
62  }
63 
64  void syncAck(TransportType transportType = Type)
65  {
66  getChannel(transportType)->syncAck(transportType);
67  }
68 
69 protected:
73 };
74 
75 } // namespace kaa
76 
77 
78 #endif /* ABSTRACTKAATRANSPORT_HPP_ */
virtual void setClientState(IKaaClientStateStoragePtr status)
virtual void syncAck(TransportType type)=0
virtual void syncAll()=0
virtual void sync(TransportType type)=0
virtual IDataChannelPtr getChannelByTransportType(TransportType type)=0
IKaaClientStateStoragePtr clientStatus_
AbstractKaaTransport(IKaaChannelManager &channelManager)
void syncAck(TransportType transportType=Type)
IKaaChannelManager & channelManager_
std::shared_ptr< IKaaClientStateStorage > IKaaClientStateStoragePtr
void syncByType(TransportType transportType=Type)