1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 // ============================================================================
26 // ============================================================================
29 #include "Description.hpp"
30 #include "Service.hpp"
31 #include "Characteristic.hpp"
33 // ============================================================================
35 // ============================================================================
41 // ============================================================
43 // ============================================================
45 typedef std::shared_ptr<Link> SharedPtr;
46 typedef std::weak_ptr<Link> WeakPtr;
48 typedef std::function<void (const std::string& propertyName, const PropertyGetFunction& asyncReturnFunc)> RegisteredGetPropFunction;
49 typedef std::function<void (const std::string& propertyName, const std::string& propertyValue, const PropertySetFunction& asyncReturnFunc)> RegisteredSetPropFunction;
50 typedef std::function<void (const DescriptionGetFunction& asyncReturnFunc)> RegisteredGetDescriptionFunction;
54 name_ = "unknown link name";
55 registeredGetPropFunction_ = nullptr;
56 registeredSetPropFunction_ = nullptr;
57 registeredGetDescriptionFunction_ = nullptr;
62 virtual const std::string& getName() {
66 virtual void setName(const std::string name) {
70 // Used at application interface
71 virtual void getProperty(const std::string& propertyName, PropertyGetFunction& asyncReturnFunc) {
72 // Call registered function
73 if (nullptr != registeredGetPropFunction_) {
74 registeredGetPropFunction_(propertyName, asyncReturnFunc);
78 virtual void setProperty(const std::string& propertyName, const std::string& propertyValue, PropertySetFunction& asyncReturnFunc) {
79 if (nullptr != registeredSetPropFunction_) {
80 registeredSetPropFunction_(propertyName, propertyValue, asyncReturnFunc);
84 virtual void getDescription(DescriptionGetFunction& asyncReturnFunc) {
85 if (nullptr != registeredGetDescriptionFunction_) {
86 registeredGetDescriptionFunction_(asyncReturnFunc);
90 // Used at protocol interface
91 virtual void registerGetPropertyFunction(RegisteredGetPropFunction& registeredGetPropFunction) {
92 registeredGetPropFunction_ = registeredGetPropFunction;
95 virtual void registerSetPropertyFunction(RegisteredSetPropFunction& registeredSetPropFunction) {
96 registeredSetPropFunction_ = registeredSetPropFunction;
99 virtual void registerGetDescriptionFunction(RegisteredGetDescriptionFunction& registeredGetDescriptionFunction) {
100 registeredGetDescriptionFunction_ = registeredGetDescriptionFunction;
105 RegisteredGetPropFunction registeredGetPropFunction_;
106 RegisteredSetPropFunction registeredSetPropFunction_;
107 RegisteredGetDescriptionFunction registeredGetDescriptionFunction_;
114 #endif /* LINK_HPP_ */