diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/example.cpp | 16 | ||||
-rw-r--r-- | example/example.hpp | 15 |
2 files changed, 26 insertions, 5 deletions
diff --git a/example/example.cpp b/example/example.cpp index 929e4d1..cc36e88 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -181,11 +181,17 @@ void setupExampleHandler() __attribute__((constructor)); void setupExampleHandler() { - auto* manager = getBlobManager(); - if (!manager->registerHandler(std::make_unique<ExampleBlobHandler>())) - { - log<level::ERR>("Failed to register Example Handler"); - } + // You don't need to do anything in the constructor. } } // namespace blobs + +/** + * This method is required by the blob manager. + * + * It is called to grab a handler for registering the blob handler instance. + */ +std::unique_ptr<blobs::GenericBlobInterface> createHandler() +{ + return std::make_unique<blobs::ExampleBlobHandler>(); +} diff --git a/example/example.hpp b/example/example.hpp index a85c275..335eade 100644 --- a/example/example.hpp +++ b/example/example.hpp @@ -1,10 +1,25 @@ #pragma once #include <blobs-ipmid/blobs.hpp> +#include <memory> #include <string> #include <unordered_map> #include <vector> +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This method must be declared as extern C for blob manager to lookup the + * symbol. + */ +std::unique_ptr<blobs::GenericBlobInterface> createHandler(); + +#ifdef __cplusplus +} +#endif + namespace blobs { |