Skip to content
12 changes: 6 additions & 6 deletions modules/core/task/include/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,33 @@ class Task {
/// @brief Validates input data and task attributes before execution.
/// @return True if validation is successful.
virtual bool Validation() final {
InternalOrderTest(PPC_FUNC_NAME);
InternalOrderTest(ppc::util::FuncName());
return ValidationImpl();
}

/// @brief Performs preprocessing on the input data.
/// @return True if preprocessing is successful.
virtual bool PreProcessing() final {
InternalOrderTest(PPC_FUNC_NAME);
InternalOrderTest(ppc::util::FuncName());
if (state_of_testing_ == StateOfTesting::kFunc) {
InternalTimeTest(PPC_FUNC_NAME);
InternalTimeTest(ppc::util::FuncName());
}
return PreProcessingImpl();
}

/// @brief Executes the main logic of the task.
/// @return True if execution is successful.
virtual bool Run() final {
InternalOrderTest(PPC_FUNC_NAME);
InternalOrderTest(ppc::util::FuncName());
return RunImpl();
}

/// @brief Performs postprocessing on the output data.
/// @return True if postprocessing is successful.
virtual bool PostProcessing() final {
InternalOrderTest(PPC_FUNC_NAME);
InternalOrderTest(ppc::util::FuncName());
if (state_of_testing_ == StateOfTesting::kFunc) {
InternalTimeTest(PPC_FUNC_NAME);
InternalTimeTest(ppc::util::FuncName());
}
return PostProcessingImpl();
}
Expand Down
20 changes: 18 additions & 2 deletions modules/core/util/include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
#include <cstdint>
#include <cstdlib>
#include <memory>
#include <source_location>
#include <string>
#include <string_view>

#include "nlohmann/json_fwd.hpp"

#define PPC_FUNC_NAME __func__

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4459)
Expand All @@ -27,6 +26,23 @@ using NlohmannJsonTypeError = nlohmann::json::type_error;

namespace ppc::util {

/**
Comment thread
aobolensk marked this conversation as resolved.
* @brief Returns the unqualified name of the current function.
*
* @param loc Source location, defaults to the current function.
* @return Function name without namespaces or parameters.
*/
inline std::string FuncName(const std::source_location& loc = std::source_location::current()) {
std::string s{loc.function_name()};
if (auto p = s.find('('); p != std::string::npos) {
s.resize(p); // drop “(…)”
}
if (auto p = s.rfind("::"); p != std::string::npos) {
s.erase(0, p + 2); // drop namespaces
}
return s;
}

enum GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };

std::string GetAbsoluteTaskPath(const std::string& id_path, const std::string& relative_path);
Expand Down
Loading