client-cpp  0.6.1
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 public:
30  virtual ~AbstractKaaTransport() {}
31 
33  : type_(Type), channelManager_(channelManager), clientStatus_(nullptr) {}
34 
36  if (status != nullptr) {
37  clientStatus_ = status;
38  }
39  }
40 
41 private:
42  IDataChannelPtr getChannel(TransportType transportType = Type) {
44  if (channel) {
45  return channel;
46  }
47  throw KaaException("Cannot find appropriate channel");
48  }
49 
50 protected:
51  void syncByType(TransportType transportType = Type) {
52  getChannel(transportType)->sync(transportType);
53  }
54 
55  void syncAll() {
56  getChannel()->syncAll();
57  }
58 
59  void syncAck(TransportType transportType = Type) {
60  getChannel(transportType)->syncAck(transportType);
61  }
62 
63 protected:
67 };
68 
69 } // namespace kaa
70 
71 
72 #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)