1 //******************************************************************
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
9 // ============================================================================
11 // ============================================================================
14 #include "Description.hpp"
15 #include "Service.hpp"
16 #include "Characteristic.hpp"
18 // ============================================================================
20 // ============================================================================
26 // ============================================================
28 // ============================================================
30 typedef std::shared_ptr<Link> SharedPtr;
31 typedef std::weak_ptr<Link> WeakPtr;
33 typedef std::function<void (const std::string& propertyName, const PropertyGetFunction& asyncReturnFunc)> RegisteredGetPropFunction;
34 typedef std::function<void (const std::string& propertyName, const std::string& propertyValue, const PropertySetFunction& asyncReturnFunc)> RegisteredSetPropFunction;
35 typedef std::function<void (const DescriptionGetFunction& asyncReturnFunc)> RegisteredGetDescriptionFunction;
39 name_ = "unknown link name";
40 registeredGetPropFunction_ = nullptr;
41 registeredSetPropFunction_ = nullptr;
42 registeredGetDescriptionFunction_ = nullptr;
47 virtual const std::string& getName() {
51 virtual void setName(const std::string name) {
55 // Used at application interface
56 virtual void getProperty(const std::string& propertyName, PropertyGetFunction& asyncReturnFunc) {
57 // Call registered function
58 if (nullptr != registeredGetPropFunction_) {
59 registeredGetPropFunction_(propertyName, asyncReturnFunc);
63 virtual void setProperty(const std::string& propertyName, const std::string& propertyValue, PropertySetFunction& asyncReturnFunc) {
64 if (nullptr != registeredSetPropFunction_) {
65 registeredSetPropFunction_(propertyName, propertyValue, asyncReturnFunc);
69 virtual void getDescription(DescriptionGetFunction& asyncReturnFunc) {
70 if (nullptr != registeredGetDescriptionFunction_) {
71 registeredGetDescriptionFunction_(asyncReturnFunc);
75 // Used at protocol interface
76 virtual void registerGetPropertyFunction(RegisteredGetPropFunction& registeredGetPropFunction) {
77 registeredGetPropFunction_ = registeredGetPropFunction;
80 virtual void registerSetPropertyFunction(RegisteredSetPropFunction& registeredSetPropFunction) {
81 registeredSetPropFunction_ = registeredSetPropFunction;
84 virtual void registerGetDescriptionFunction(RegisteredGetDescriptionFunction& registeredGetDescriptionFunction) {
85 registeredGetDescriptionFunction_ = registeredGetDescriptionFunction;
90 RegisteredGetPropFunction registeredGetPropFunction_;
91 RegisteredSetPropFunction registeredSetPropFunction_;
92 RegisteredGetDescriptionFunction registeredGetDescriptionFunction_;
99 #endif /* LINK_HPP_ */