client-cpp  0.8.1
Profile management

Copyright 2014-2016 CyberVision, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Profile subsystem is based on auto-generated class(es) according to the profile schema used during sdk generation.

Assume a profile schema has the following form:

{
"name": "Profile",
"namespace": "org.kaaproject.kaa.client.example",
"type": "record",
"fields": [
{
"name": "data",
"type": "string"
}
]
}

After calling avrogen.sh script Avro C++ compiler will be generated appropriate code and put it into ProfileGen.hpp header. So auto-generated notification class will be like:

struct Profile {
std::string data;
};

Below is an example of a profile container for C++:

#include "kaa/Kaa.hpp"
using namespace kaa;
// Kaa client initialization based on BasicProfileContainer
void init(){
//Create client for Kaa SDK
Kaa::init();
IKaaClient &kaaClient = Kaa::getKaaClient();
//Sample profile
KaaProfile profile;
profile.data = "some useful data";
//Create instance of profile container
ProfileContainerPtr container(new DefaultProfileContainer(profile));
//Set simple profile container.
kaaClient.setProfileContainer(container);
// Update method should be called to notify about changes in the profile.
kaaClient.updateProfile();
//Starts Kaa
Kaa::start();
}