summaryrefslogtreecommitdiffstats
path: root/include/afb/c++/binding-object.hpp
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2019-01-21 10:40:50 +0100
committerLoïc Collignon <loic.collignon@iot.bzh>2019-03-11 13:40:50 +0100
commita5143cea54e70859269556277353ceafedfa8895 (patch)
treeec18c2c67fbfed2d737b7d8d95f3b344d0d4ebc7 /include/afb/c++/binding-object.hpp
parent3f367d8ef3409d3f671816d1a8e4c1504838ad7e (diff)
c++: Inherit of class afb::api
Base the class afb::base_api_t on the raw wrapper class afb::api Change-Id: Idbc4786d548ffcb0062a85b686c196758e49823c Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'include/afb/c++/binding-object.hpp')
-rw-r--r--include/afb/c++/binding-object.hpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/include/afb/c++/binding-object.hpp b/include/afb/c++/binding-object.hpp
index b85331cd..1744535f 100644
--- a/include/afb/c++/binding-object.hpp
+++ b/include/afb/c++/binding-object.hpp
@@ -17,9 +17,7 @@
* limitations under the License.
*/
-extern "C" {
-#include <afb/afb-binding.h>
-}
+#include <afb/c++/binding-wrap.hpp>
#include <cassert>
#include <string>
@@ -93,7 +91,7 @@ namespace afb
return -2;
}
- api->handle_ = handle;
+ api->api_ = handle;
return api->preinit(handle);
}
@@ -201,6 +199,7 @@ namespace afb
typename TTraits = ApiTraits<TApi>
>
class base_api_t
+ : public api
{
friend TTraits;
@@ -213,8 +212,6 @@ namespace afb
base_api_t& operator=(const base_api_t&) = delete;
protected:
- afb_api_t handle_;
-
/**
* @brief Default constructor.
*/
@@ -239,7 +236,7 @@ namespace afb
int add_verb(const std::string& verb, const std::string& info, void* vcbdata = nullptr, const struct afb_auth* auth = nullptr, uint32_t session = AFB_SESSION_NONE_X2, int glob = 0)
{
return afb_api_add_verb(
- handle_,
+ api_,
verb.c_str(),
info == "" ? nullptr : info.c_str(),
TTraits::template verb<Callback>,
@@ -264,7 +261,7 @@ namespace afb
int add_verb(const std::string& verb, const std::string& info, void* vcbdata = nullptr, const struct afb_auth* auth = nullptr, uint32_t session = AFB_SESSION_NONE_X2, int glob = 0)
{
return afb_api_add_verb(
- handle_,
+ api_,
verb.c_str(),
info == "" ? nullptr : info.c_str(),
TTraits::template verb<Callback>,
@@ -285,21 +282,21 @@ namespace afb
* @brief Get the API's handle.
* @return The API's handle.
*/
- afb_api_t handle() const { return handle_; }
+ afb_api_t handle() const { return api_; }
/**
* @brief Implicit conversion to C handle.
* @return The API's handle.
*/
- operator afb_api_t() const { return handle_; }
+ operator afb_api_t() const { return api_; }
/**
* @brief Destructor.
*/
virtual ~base_api_t()
{
- if (handle_ && afb_api_delete_api(handle_))
- AFB_API_ERROR(handle_, "Failed to delete API.");
+ if (api_ && afb_api_delete_api(api_))
+ AFB_API_ERROR(api_, "Failed to delete API.");
}
/**