client-cpp  0.6.1
KaaClient.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 KAACLIENT_HPP_
18 #define KAACLIENT_HPP_
19 
20 #include "kaa/IKaaClient.hpp"
21 
22 #include "kaa/ClientStatus.hpp"
27 #include "kaa/event/gen/EventFamilyFactory.hpp"
35 #include "kaa/ClientStatus.hpp"
44 #include "kaa/log/LogCollector.hpp"
45 
46 namespace kaa {
47 
48 typedef std::shared_ptr<IBootstrapManager> IBootstrapManagerPtr;
49 
50 #ifdef KAA_USE_CONFIGURATION
51 typedef std::shared_ptr<DefaultDeltaManager> DefaultDeltaManagerPtr;
52 #endif
53 
54 typedef enum KaaOption {
60 } KaaOption;
61 
62 class KaaClient : public IKaaClient {
63 public:
64  KaaClient();
65  virtual ~KaaClient() { }
66 
67  void init(int options = KAA_DEFAULT_OPTIONS);
68  void start();
69  void stop();
70  void pause();
71  void resume();
72 
73  virtual IProfileManager& getProfileManager() { return *profileManager_; }
74 #ifdef KAA_USE_CONFIGURATION
75  virtual ISchemaPersistenceManager& getSchemaPersistenceManager() { return *schemaPersistenceManager_; }
76  virtual IConfigurationPersistenceManager& getConfigurationPersistenceManager() { return *configurationPersistenceManager_; }
77  virtual IDeltaManager& getDeltaManager() { return *deltaManager_; }
78  virtual IConfigurationManager& getConfigurationManager() { return *configurationManager_; }
79 #endif
80 #ifdef KAA_USE_NOTIFICATIONS
81  virtual INotificationManager& getNotificationManager() { return *notificationManager_; }
82 #endif
83 #ifdef KAA_USE_EVENTS
84  virtual IEndpointRegistrationManager& getEndpointRegistrationManager() { return *registrationManager_; }
85  virtual EventFamilyFactory& getEventFamilyFactory() { return *eventFamilyFactory_; }
86  virtual IEventListenersResolver& getEventListenersResolver() { return *eventManager_; }
87 #endif
88  virtual IKaaChannelManager& getChannelManager() { return *channelManager_; }
89  virtual const KeyPair& getClientKeyPair() { return clientKeys_; }
90 #ifdef KAA_USE_LOGGING
91  virtual ILogCollector& getLogCollector() { return *logCollector_; }
92 #endif
93  virtual IKaaDataMultiplexer& getOperationMultiplexer() { return *operationsProcessor_; }
94  virtual IKaaDataDemultiplexer& getOperationDemultiplexer() { return *operationsProcessor_; }
95  virtual IKaaDataMultiplexer& getBootstrapMultiplexer() { return *bootstrapProcessor_; }
96  virtual IKaaDataDemultiplexer& getBootstrapDemultiplexer() { return *bootstrapProcessor_; }
97 private:
98  void initKaaConfiguration();
99  void initKaaTransport();
100  void initClientKeys();
101 
102  void setDefaultConfiguration();
103 
104 public:
108 private:
110  IBootstrapManagerPtr bootstrapManager_;
111  std::unique_ptr<ProfileManager> profileManager_;
112 #ifdef KAA_USE_NOTIFICATIONS
113  std::unique_ptr<NotificationManager> notificationManager_;
114 #endif
115 
116  KeyPair clientKeys_;
117  std::string publicKeyHash_;
118 
119 #ifdef KAA_USE_CONFIGURATION
120  ISchemaProcessorPtr schemaProcessor_;
121  DefaultDeltaManagerPtr deltaManager_;
122  IConfigurationManagerPtr configurationManager_;
123  IConfigurationProcessorPtr configurationProcessor_;
124  ISchemaPersistenceManagerPtr schemaPersistenceManager_;
125  IConfigurationPersistenceManagerPtr configurationPersistenceManager_;
126 #endif
127 #ifdef KAA_USE_EVENTS
128  std::unique_ptr<EventManager> eventManager_;
129  std::unique_ptr<EventFamilyFactory> eventFamilyFactory_;
130  std::unique_ptr<EndpointRegistrationManager> registrationManager_;
131 #endif
132  std::unique_ptr<IKaaChannelManager> channelManager_;
133  std::unique_ptr<BootstrapDataProcessor> bootstrapProcessor_;
134  std::unique_ptr<OperationsDataProcessor> operationsProcessor_;
135 
136 #ifdef KAA_DEFAULT_BOOTSTRAP_HTTP_CHANNEL
137  std::unique_ptr<DefaultBootstrapChannel> bootstrapChannel_;
138 #endif
139 #ifdef KAA_DEFAULT_TCP_CHANNEL
140  std::unique_ptr<DefaultOperationTcpChannel> opsTcpChannel_;
141 #endif
142 #ifdef KAA_DEFAULT_OPERATION_HTTP_CHANNEL
143  std::unique_ptr<DefaultOperationHttpChannel> opsHttpChannel_;
144 #endif
145 #ifdef KAA_DEFAULT_LONG_POLL_CHANNEL
146  std::unique_ptr<DefaultOperationLongPollChannel> opsLongPollChannel_;
147 #endif
148 #ifdef KAA_USE_LOGGING
149  std::unique_ptr<LogCollector> logCollector_;
150 #endif
151 
152  int options_;
153 };
154 
155 }
156 
157 
158 
159 #endif /* KAACLIENT_HPP_ */
virtual IProfileManager & getProfileManager()
Definition: KaaClient.hpp:73
std::pair< Botan::MemoryVector< std::uint8_t >, std::string > KeyPair
Definition: KeyUtils.hpp:29
virtual IKaaDataDemultiplexer & getBootstrapDemultiplexer()
Definition: KaaClient.hpp:96
virtual IKaaChannelManager & getChannelManager()
Definition: KaaClient.hpp:88
void init(int options=KAA_DEFAULT_OPTIONS)
virtual ~KaaClient()
Definition: KaaClient.hpp:65
virtual IKaaDataDemultiplexer & getOperationDemultiplexer()
Definition: KaaClient.hpp:94
virtual IKaaDataMultiplexer & getBootstrapMultiplexer()
Definition: KaaClient.hpp:95
KaaOption
Definition: KaaClient.hpp:54
std::shared_ptr< IBootstrapManager > IBootstrapManagerPtr
Definition: KaaClient.hpp:48
std::shared_ptr< IKaaClientStateStorage > IKaaClientStateStoragePtr
static const int KAA_DEFAULT_OPTIONS
Definition: KaaClient.hpp:105
virtual IKaaDataMultiplexer & getOperationMultiplexer()
Definition: KaaClient.hpp:93
virtual const KeyPair & getClientKeyPair()
Definition: KaaClient.hpp:89