diff --git a/container/src/root/macro/crypto/hash.C b/container/src/root/macro/crypto/hash.C index 7dd97a0..bc0bff3 100644 --- a/container/src/root/macro/crypto/hash.C +++ b/container/src/root/macro/crypto/hash.C @@ -1,6 +1,6 @@ // docker-finance | modern accounting for the power-user // -// Copyright (C) 2024-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) +// Copyright (C) 2024-2026 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 @@ -47,8 +47,8 @@ namespace common = ::dfi::macro::common; namespace libsodium = common::crypto::libsodium; namespace cryptopp = common::crypto::cryptopp; namespace botan = common::crypto::botan; - //! \brief Hash generator macro +//! \since docker-finance 1.0.0 class Hash final { //! Text description of Hash impl, encoded digest @@ -248,6 +248,48 @@ class Hash final //! \param message Message to encode static void run(const std::string& message) { Hash::encode(message); } }; + +//! \brief Pluggable entrypoint +//! \ingroup cpp_macro_impl +//! \since docker-finance 1.1.0 +class hash_C final +{ + public: + hash_C() = default; + ~hash_C() = default; + + hash_C(const hash_C&) = default; + hash_C& operator=(const hash_C&) = default; + + hash_C(hash_C&&) = default; + hash_C& operator=(hash_C&&) = default; + + public: + //! \brief Macro auto-loader + //! \param arg Message to encode + static void load(const std::string& arg = {}) + { + std::string message{arg}; + + // If no message is given, default to unique profile/subprofile + if (message.empty()) + { + message += ::dfi::common::get_env("global_parent_profile"); + message += ::dfi::common::get_env("global_arg_delim_1"); + message += ::dfi::common::get_env("global_child_profile"); + } + + Hash::run(message); + } + + //! \brief Macro auto-unloader + //! \param arg Optional code to execute before unloading + static void unload(const std::string& arg = {}) + { + if (!arg.empty()) + ::dfi::common::line(arg); + } +}; } // namespace crypto } // namespace macro } // namespace dfi diff --git a/container/src/root/macro/crypto/random.C b/container/src/root/macro/crypto/random.C index bd0da58..38d4906 100644 --- a/container/src/root/macro/crypto/random.C +++ b/container/src/root/macro/crypto/random.C @@ -1,6 +1,6 @@ // docker-finance | modern accounting for the power-user // -// Copyright (C) 2024-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) +// Copyright (C) 2024-2026 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 @@ -50,8 +50,8 @@ namespace botan = common::crypto::botan; #ifdef __DFI_PLUGIN_BITCOIN__ namespace bitcoin = common::crypto::bitcoin; #endif - //! \brief CSPRNG macro +//! \since docker-finance 1.0.0 class Random final { //! Text description of number type, random number @@ -155,6 +155,41 @@ class Random final //! \brief Wrapper to Random generator static void run() { Random::generate(); } }; + +//! \brief Pluggable entrypoint +//! \ingroup cpp_macro_impl +//! \since docker-finance 1.1.0 +class random_C final +{ + public: + random_C() = default; + ~random_C() = default; + + random_C(const random_C&) = default; + random_C& operator=(const random_C&) = default; + + random_C(random_C&&) = default; + random_C& operator=(random_C&&) = default; + + public: + //! \brief Macro auto-loader + //! \param arg Optional code to execute after loading + static void load(const std::string& arg = {}) + { + if (!arg.empty()) + ::dfi::common::line(arg); + + Random::run(); + } + + //! \brief Macro auto-unloader + //! \param arg Optional code to execute before unloading + static void unload(const std::string& arg = {}) + { + if (!arg.empty()) + ::dfi::common::line(arg); + } +}; } // namespace crypto } // namespace macro } // namespace dfi diff --git a/container/src/root/macro/test/benchmark.C b/container/src/root/macro/test/benchmark.C index 4b93c95..edebb3c 100644 --- a/container/src/root/macro/test/benchmark.C +++ b/container/src/root/macro/test/benchmark.C @@ -1,6 +1,6 @@ // docker-finance | modern accounting for the power-user // -// Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) +// Copyright (C) 2021-2026 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 @@ -61,27 +61,61 @@ class Benchmark public: //! \brief Macro for running all benchmarks - //! \todo parameter arg that takes list of benchmarks - static void run() + static void run() { ::benchmark::RunSpecifiedBenchmarks(); } + + public: + static constexpr std::initializer_list m_paths{ + {"test/benchmark/hash.hh"}, + {"test/benchmark/random.hh"}, + {"test/benchmark/utility.hh"}}; +}; + +//! \brief Pluggable entrypoint +//! \ingroup cpp_macro_impl +//! \since docker-finance 1.1.0 +class benchmark_C final +{ + public: + benchmark_C() = default; + ~benchmark_C() = default; + + benchmark_C(const benchmark_C&) = default; + benchmark_C& operator=(const benchmark_C&) = default; + + benchmark_C(benchmark_C&&) = default; + benchmark_C& operator=(benchmark_C&&) = default; + + public: + //! \brief Macro auto-loader + //! \param arg Optional code to execute after loading + static void load(const std::string& arg = {}) { - static bool loaded{false}; - static const std::initializer_list paths{ - {"test/benchmark/hash.hh"}, - {"test/benchmark/random.hh"}, - {"test/benchmark/utility.hh"}}; + for (auto path : Benchmark::m_paths) + ::dfi::common::load(std::string{path}); - if (!loaded) - { - ::dfi::common::Command::load(paths); - loaded = true; - } - - // TODO(unassigned): add argc,argv to macro/function signatures static int argc{1}; static const char* argv{"docker-finance"}; ::benchmark::Initialize(&argc, const_cast(&argv)); - ::benchmark::RunSpecifiedBenchmarks(); + + // NOTE: benchmark filters can only be set via environment + // (when calling this macro via `dfi` `root`, as an argument) + Benchmark::run(); + + if (!arg.empty()) + ::dfi::common::line(arg); + } + + //! \brief Macro auto-unloader + //! \param arg Optional code to execute before unloading + static void unload(const std::string& arg = {}) + { + if (!arg.empty()) + ::dfi::common::line(arg); + ::benchmark::Shutdown(); + + for (auto path : Benchmark::m_paths) + ::dfi::common::unload(std::string{path}); } }; } // namespace test diff --git a/container/src/root/macro/test/unit.C b/container/src/root/macro/test/unit.C index 0cf69b6..9e72c6e 100644 --- a/container/src/root/macro/test/unit.C +++ b/container/src/root/macro/test/unit.C @@ -1,6 +1,6 @@ // docker-finance | modern accounting for the power-user // -// Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) +// Copyright (C) 2021-2026 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 @@ -61,24 +61,57 @@ class Unit public: //! \brief Macro for running all tests - //! \todo parameter arg that takes list of tests - static int run() + static int run(const std::string& arg) { - static bool loaded{false}; - static const std::initializer_list paths{ - {"test/unit/hash.hh"}, - {"test/unit/random.hh"}, - {"test/unit/type.hh"}, - {"test/unit/utility.hh"}}; + ::testing::GTEST_FLAG(filter) = arg.empty() ? "*" : arg; + return RUN_ALL_TESTS(); + } - if (!loaded) - { - ::dfi::common::Command::load(paths); - loaded = true; - } + public: + static constexpr std::initializer_list m_paths{ + {"test/unit/hash.hh"}, + {"test/unit/random.hh"}, + {"test/unit/type.hh"}, + {"test/unit/utility.hh"}}; +}; + +//! \brief Pluggable entrypoint +//! \ingroup cpp_macro_impl +//! \since docker-finance 1.1.0 +class unit_C final +{ + public: + unit_C() = default; + ~unit_C() = default; + + unit_C(const unit_C&) = default; + unit_C& operator=(const unit_C&) = default; + + unit_C(unit_C&&) = default; + unit_C& operator=(unit_C&&) = default; + + public: + //! \brief Macro auto-loader + //! \param arg GoogleTest regex filter + static void load(const std::string& arg = {}) + { + for (auto path : Unit::m_paths) + ::dfi::common::load(std::string{path}); ::testing::InitGoogleTest(); - return RUN_ALL_TESTS(); // TODO(unassigned): caller do something about this + + Unit::run(arg); + } + + //! \brief Macro auto-unloader + //! \param arg Optional code to execute before unloading + static void unload(const std::string& arg = {}) + { + if (!arg.empty()) + ::dfi::common::line(arg); + + for (auto path : Unit::m_paths) + ::dfi::common::unload(std::string{path}); } }; } // namespace test diff --git a/container/src/root/macro/web/internal/crypto.C b/container/src/root/macro/web/internal/crypto.C index 18ec291..d89a825 100644 --- a/container/src/root/macro/web/internal/crypto.C +++ b/container/src/root/macro/web/internal/crypto.C @@ -1,6 +1,6 @@ // docker-finance | modern accounting for the power-user // -// Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) +// Copyright (C) 2021-2026 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 @@ -51,7 +51,8 @@ namespace macro namespace web { //! \namespace dfi::macro::web::internal -//! \brief ROOT web-based macros for internal use only +//! \brief ROOT web server dfi macros for internal use only +//! \details Primarily implementation for public-consuming macros //! \since docker-finance 1.0.0 namespace internal { diff --git a/container/src/root/macro/web/internal/meta.C b/container/src/root/macro/web/internal/meta.C index 2e6dfae..6a6c279 100644 --- a/container/src/root/macro/web/internal/meta.C +++ b/container/src/root/macro/web/internal/meta.C @@ -1,6 +1,6 @@ // docker-finance | modern accounting for the power-user // -// Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) +// Copyright (C) 2021-2026 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 @@ -49,7 +49,8 @@ namespace macro namespace web { //! \namespace dfi::macro::web::internal -//! \brief ROOT web-based macros for internal use only +//! \brief ROOT web server dfi macros for internal use only +//! \details Primarily implementation for public-consuming macros //! \since docker-finance 1.0.0 namespace internal { diff --git a/container/src/root/macro/web/server.C b/container/src/root/macro/web/server.C index 97bb9b2..7982176 100644 --- a/container/src/root/macro/web/server.C +++ b/container/src/root/macro/web/server.C @@ -1,6 +1,6 @@ // docker-finance | modern accounting for the power-user // -// Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) +// Copyright (C) 2021-2026 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 @@ -60,16 +60,14 @@ class Server final //! \details Registers internal macros static void register_commands() { - namespace macro = ::dfi::macro; - - macro::load("macro/web/internal/crypto.C"); - macro::common::g_HTTPServer->RegisterCommand( + ::dfi::common::load("macro/web/internal/crypto.C"); + ::dfi::macro::common::g_HTTPServer->RegisterCommand( "/rng_sample", "::dfi::macro::web::internal::Random::rng_sample(\"%arg1%" "\")"); - macro::load("macro/web/internal/meta.C"); - macro::common::g_HTTPServer->RegisterCommand( + ::dfi::common::load("macro/web/internal/meta.C"); + ::dfi::macro::common::g_HTTPServer->RegisterCommand( "/meta_sample", "::dfi::macro::web::internal::Meta::meta_sample(\"%arg1%" "\")"); @@ -79,6 +77,41 @@ class Server final //! \brief Start webserver static void run() { Server::register_commands(); } }; + +//! \brief Pluggable entrypoint +//! \ingroup cpp_macro_impl +//! \since docker-finance 1.1.0 +class server_C final +{ + public: + server_C() = default; + ~server_C() = default; + + server_C(const server_C&) = default; + server_C& operator=(const server_C&) = default; + + server_C(server_C&&) = default; + server_C& operator=(server_C&&) = default; + + public: + //! \brief Macro auto-loader + //! \param arg Optional code to execute after loading + static void load(const std::string& arg = {}) + { + if (!arg.empty()) + ::dfi::common::line(arg); + + Server::run(); + } + + //! \brief Macro auto-unloader + //! \param arg Optional code to execute before unloading + static void unload(const std::string& arg = {}) + { + if (!arg.empty()) + ::dfi::common::line(arg); + } +}; } // namespace web } // namespace macro } // namespace dfi