container: plugins: root: update example plugin

`dfi` API headers must be managed on an as-needed basis.
This commit is contained in:
2025-12-17 14:03:26 -08:00
parent a54c7f25a5
commit a609e4d936
3 changed files with 34 additions and 14 deletions

View File

@@ -20,8 +20,6 @@
//! \note File intended to be loaded into ROOT.cern framework / Cling interpreter
//! \since docker-finance 1.0.0
// NOTE: `dfi` API headers are included by default
//! \namespace dfi::plugin
//! \brief docker-finance plugins
//! \warning All plugins (repo/custom) must exist within this namespace
@@ -47,30 +45,56 @@ namespace example
//! \param arg String to pass to auto-loader (use-case is plugin-implementation defined)
void load(const std::string& arg = {})
{
namespace plugin = ::dfi::plugin;
namespace common = ::dfi::common;
// Any code can follow here: run example functions, etc.
// For this example, get absolute path of this plugin's implementation and load.
::dfi::plugin::common::PluginPath path("repo/example/internal/example.cc");
::dfi::common::load(path.absolute());
//
// For this example:
//
// 1. Load needed requirements for this plugin's impl
// 2. Get absolute path of plugin's impl and then load
//
const std::string src{common::get_root_path() + "src/"};
common::load(src + "hash.hh");
common::load(src + "random.hh");
// ...add as needed
plugin::common::PluginPath path("repo/example/internal/example.cc");
common::load(path.absolute());
// For this example, expect and pass a line of code to the interpreter after loading
// NOTE: the following arg code can utilize any code that was loaded/interpreted in load()
if (!arg.empty())
::dfi::common::line(arg);
common::line(arg);
}
//! \brief Example auto-unloader
//! \param arg String to pass to auto-unloader (use-case is plugin-implementation defined)
void unload(const std::string& arg = {})
{
namespace plugin = ::dfi::plugin;
namespace common = ::dfi::common;
// For this example, expect and pass a line of code to the interpreter before unloading.
// NOTE: the following arg code can utilize any code that was previously loaded/interpreted
if (!arg.empty())
::dfi::common::line(arg);
common::line(arg);
// Any code can follow here: run example functions, etc.
// For this example, get absolute path of this plugin's implementation and unload.
::dfi::plugin::common::PluginPath path("repo/example/internal/example.cc");
::dfi::common::unload(path.absolute());
//
// For this example:
//
// 1. Unload needed requirements for this plugin's impl
// 2. Get absolute path of plugin's impl and then unload
//
const std::string src{common::get_root_path() + "src/"};
common::unload(src + "hash.hh");
common::unload(src + "random.hh");
// ...add as needed
plugin::common::PluginPath path("repo/example/internal/example.cc");
common::unload(path.absolute());
}
// NOTE: to auto-reload this plugin, load()/unload() here or utilize one of the `dfi::plugin::reload()` functions.

View File

@@ -20,8 +20,6 @@
//! \note File intended to be loaded into ROOT.cern framework / Cling interpreter
//! \since docker-finance 1.1.0
// NOTE: `dfi` API headers are included by default
#include "./example.hh"
#include <limits>

View File

@@ -25,8 +25,6 @@
#include <string>
// NOTE: `dfi` API headers are included by default
namespace dfi::plugin::example
{
//! \brief An example plugin implementation class