Commit 15901e26 authored by Martin Marinov's avatar Martin Marinov

Add Progress::Node and support functionality. namespace Progress contains...

Add Progress::Node and support functionality. namespace Progress contains symbols used to track operational progress and facilitate interrupt.
parent 40a2bc5b
......@@ -6,6 +6,7 @@ my_add_subdir(Code)
my_add_subdir(Config)
my_add_subdir(Debug)
my_add_subdir(Utils)
my_add_subdir(Progress)
my_add_subdir(Security)
my_add_subdir(Test)
......
set(my_headers
${CMAKE_CURRENT_SOURCE_DIR}/ProgressNode.hh
PARENT_SCOPE
)
set(my_sources
${CMAKE_CURRENT_SOURCE_DIR}/ProgressNode.cc
PARENT_SCOPE
)
// (C) Copyright 2017 by Autodesk, Inc.
#include "Base/Security/Mandatory.hh"
#include "Base/Code/Quality.hh"
#include "ProgressNode.hh"
// (C) Copyright 2017 by Autodesk, Inc.
#ifndef BASE_PROGRESS_NODE_HH_INCLUDED
#define BASE_PROGRESS_NODE_HH_INCLUDED
#ifdef PROGRESS_ON
namespace Progress {
//! Represent an operational node in the progress graph
class Node
{
public:
const char* const name;
Node(const char* const _name,
Node* _next = nullptr, Node* _chld = nullptr)
: name(_name), next_(_next), chld_(_chld)
{}
protected:
Node* next_; //!< next node on the same level, last if nullptr
Node* chld_; //!< first child node, leaf if nullptr
};
extern thread_local Node* actv_node; // active node
typedef Node* (*MakeNodeFunction)(Node* _next);
inline Node* make_children_list() { return nullptr; }
template <typename... ArgT>
inline Node* make_children_list(MakeNodeFunction _make_node_fnct,
const ArgT&... _args)
{
return (*_make_node_fnct)(make_children_list(_args...));
}
} //namespace Progress
#define PROGRESS_NODE_CHILDREN(...) Progress::make_children_list(##__VA_ARGS__)
#define PROGRESS_DEFINE_NODE(OPRT, ...) \
thread_local Progress::Node* Progress::PROGRESS_NODE_NAME(OPRT) = nullptr; \
Progress::Node* Progress::PROGRESS_MAKE_NODE_NAME(OPRT) \
(Progress::Node* _next) \
{ \
static thread_local Node node(#OPRT, _next, \
PROGRESS_NODE_CHILDREN(##__VA_ARGS__));\
return OPRT##_node = &node; \
}
#define PROGRESS_NODE_NAME(OPRT) OPRT##_node
#define PROGRESS_MAKE_NODE_NAME(OPRT) make_##OPRT##_node
#define PROGRESS_DECLARE_NODE(OPRT) \
namespace Progress { \
extern thread_local Node* PROGRESS_NODE_NAME(OPRT); \
Node* PROGRESS_MAKE_NODE_NAME(OPRT)(Node* _next = nullptr); \
} //namespace Progress {
#endif// PROGRESS_ON
#endif//BASE_PROGRESS_NODE_HH_INCLUDED
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment