client-cpp  0.10.0
KaaClientPlatformContext.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 KAACLIENTPLATFORMCONTEXT_HPP_
18 #define KAACLIENTPLATFORMCONTEXT_HPP_
19 
20 #include <memory>
21 
28 
29 namespace kaa {
30 
32 public:
33 
35  : properties_(), executorContext_(std::make_shared<SimpleExecutorContext>())
36  {}
37 
39  : properties_(properties), executorContext_(std::make_shared<SimpleExecutorContext>())
40  {}
41 
43  : properties_(properties), executorContext_(executorContext)
44  {
45  if (!executorContext_) {
46  throw KaaException("Executor context is null");
47  }
48  }
49 
51  {
52  return properties_;
53  }
54 
55  virtual std::unique_ptr<IConnectivityChecker> createConnectivityChecker()
56  {
57  return std::unique_ptr<IConnectivityChecker>(new PingConnectivityChecker);
58  }
59 
61  {
62  return *executorContext_;
63  }
64 
65  KaaClientPlatformContext(const KaaClientPlatformContext& properties) = delete;
66  KaaClientPlatformContext& operator=(const KaaClientPlatformContext& properties) = delete;
67 
70 
71  ~KaaClientPlatformContext() noexcept = default;
72 
73 private:
74  KaaClientProperties properties_;
75  IExecutorContextPtr executorContext_;
76 };
77 
78 } /* namespace kaa */
79 
80 #endif /* KAACLIENTPLATFORMCONTEXT_HPP_ */
virtual KaaClientProperties & getProperties()
Returns platform SDK properties.
~KaaClientPlatformContext() noexcept=default
virtual std::unique_ptr< IConnectivityChecker > createConnectivityChecker()
Returns platform dependent implementation of ConnectivityChecker.
KaaClientPlatformContext & operator=(const KaaClientPlatformContext &properties)=delete
KaaClientPlatformContext(const KaaClientProperties &properties)
virtual IExecutorContext & getExecutorContext()
Returns SDK thread execution context.
KaaClientPlatformContext(const KaaClientProperties &properties, IExecutorContextPtr executorContext)
std::shared_ptr< IExecutorContext > IExecutorContextPtr