// docker-finance | modern accounting for the power-user
//
// Copyright (C) 2024-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation  either version 3 of the License  or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not  see <https://www.gnu.org/licenses/>.

//! \file
//! \author Aaron Fiore (Founder, Evergreen Crypto LLC)
//! \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
//!          and work within their own inner namespace
//! \since docker-finance 1.0.0
namespace dfi::plugin
{
//! \namespace dfi::plugin::example
//! \brief docker-finance plugin example namespace
//! \details An example namespace used only within this example file
//!
//! \warning
//!   This namespace *MUST* match the parent plugin directory,
//!   e.g., `example/anyfile.cc` must be `dfi::plugin::example`
//!   in order to benefit from the plugin auto-loader.
//!   Otherwise, use general common file loader.
//!
//! \note Not a real namespace - for example purposes only
//! \since docker-finance 1.1.0
namespace example
{
//! \brief Example auto-loader
//! \param arg String to pass to auto-loader (use-case is plugin-implementation defined)
void load(const std::string& arg = {})
{
  // 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, 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);
}

//! \brief Example auto-unloader
//! \param arg String to pass to auto-unloader (use-case is plugin-implementation defined)
void unload(const std::string& arg = {})
{
  // 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);

  // 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());
}

// NOTE: to auto-reload this plugin, load()/unload() here or utilize one of the `dfi::plugin::reload()` functions.

}  // namespace example
}  // namespace dfi::plugin

// # vim: sw=2 sts=2 si ai et
