client-cpp
0.10.0
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
ProfileManager.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 DEFAULTPROFILEMANAGER_HPP_
18
#define DEFAULTPROFILEMANAGER_HPP_
19
20
#include <memory>
21
22
#include "
kaa/profile/IProfileManager.hpp
"
23
#include "
kaa/profile/IProfileContainer.hpp
"
24
#include "
kaa/profile/DefaultProfileContainer.hpp
"
25
#include "
kaa/common/AvroByteArrayConverter.hpp
"
26
#include "
kaa/channel/transport/IProfileTransport.hpp
"
27
#include "kaa/profile/gen/ProfileDefinitions.hpp"
28
#include "
kaa/IKaaClientContext.hpp
"
29
30
namespace
kaa {
31
36
class
ProfileManager
:
public
IProfileManager
{
37
public
:
38
ProfileManager
(
IKaaClientContext
&context) : profileContainer_(std::make_shared<
DefaultProfileContainer
>()), context_(context) { }
39
44
virtual
void
setProfileContainer
(
IProfileContainerPtr
container)
45
{
46
if
(container) {
47
profileContainer_ = container;
48
}
49
}
50
57
SharedDataBuffer
getSerializedProfile
()
58
{
59
static
AvroByteArrayConverter<KaaProfile>
avroConverter;
60
61
if
(profileContainer_) {
62
return
avroConverter.
toByteArray
(profileContainer_->getProfile());
63
}
64
#if KAA_PROFILE_SCHEMA_VERSION > 0
65
else
{
66
throw
KaaException
(
"Profile container is not set!"
);
67
}
68
#endif
69
70
return
avroConverter.
toByteArray
(KaaProfile());
71
}
72
76
void
updateProfile
()
77
{
78
SharedDataBuffer
serializedProfile =
getSerializedProfile
();
79
if
((serializedProfile.first.get() && serializedProfile.second > 0)
80
|| context_.
getStatus
().
isProfileResyncNeeded
()) {
81
transport_->sync();
82
}
83
}
84
85
virtual
bool
isInitialized
()
86
{
87
#if KAA_PROFILE_SCHEMA_VERSION > 0
88
return
profileContainer_.operator bool();
89
#else
90
return
true
;
91
#endif
92
}
93
98
virtual
void
setTransport
(
IProfileTransportPtr
transport)
99
{
100
if
(transport) {
101
transport_ = transport;
102
}
103
}
104
105
private
:
106
IProfileTransportPtr
transport_;
107
IProfileContainerPtr
profileContainer_;
108
IKaaClientContext
&context_;
109
};
110
111
}
/* namespace kaa */
112
113
#endif
/* DEFAULTPROFILEMANAGER_HPP_ */
kaa::ProfileManager::ProfileManager
ProfileManager(IKaaClientContext &context)
Definition:
ProfileManager.hpp:38
kaa::ProfileManager::updateProfile
void updateProfile()
Definition:
ProfileManager.hpp:76
kaa::KaaException
Definition:
KaaException.hpp:39
kaa::IProfileContainerPtr
std::shared_ptr< IProfileContainer > IProfileContainerPtr
Definition:
IProfileContainer.hpp:43
kaa::ProfileManager::isInitialized
virtual bool isInitialized()
Definition:
ProfileManager.hpp:85
kaa::IProfileManager
Definition:
IProfileManager.hpp:31
kaa::AvroByteArrayConverter::toByteArray
SharedDataBuffer toByteArray(const T &datum)
Definition:
AvroByteArrayConverter.hpp:150
DefaultProfileContainer.hpp
IProfileTransport.hpp
IProfileContainer.hpp
kaa::ProfileManager::getSerializedProfile
SharedDataBuffer getSerializedProfile()
Definition:
ProfileManager.hpp:57
kaa::DefaultProfileContainer
Definition:
DefaultProfileContainer.hpp:25
kaa::IKaaClientContext
Definition:
IKaaClientContext.hpp:29
kaa::IKaaClientStateStorage::isProfileResyncNeeded
virtual bool isProfileResyncNeeded() const =0
kaa::ProfileManager::setTransport
virtual void setTransport(IProfileTransportPtr transport)
Definition:
ProfileManager.hpp:98
kaa::AvroByteArrayConverter
Definition:
AvroByteArrayConverter.hpp:42
AvroByteArrayConverter.hpp
kaa::ProfileManager::setProfileContainer
virtual void setProfileContainer(IProfileContainerPtr container)
Definition:
ProfileManager.hpp:44
kaa::ProfileManager
Definition:
ProfileManager.hpp:36
IProfileManager.hpp
kaa::IKaaClientContext::getStatus
virtual IKaaClientStateStorage & getStatus()=0
kaa::SharedDataBuffer
std::pair< boost::shared_array< std::uint8_t >, std::uint32_t > SharedDataBuffer
Definition:
EndpointObjectHash.hpp:29
kaa::IProfileTransportPtr
std::shared_ptr< IProfileTransport > IProfileTransportPtr
Definition:
IProfileTransport.hpp:73
IKaaClientContext.hpp
architec
Documents
kaa
client
client-multi
client-cpp
kaa
profile
ProfileManager.hpp
Generated on Mon Oct 31 2016 16:51:43 for client-cpp by
1.8.6