Commit b377ef2d authored by Martin Marinov's avatar Martin Marinov
Browse files

Remove progress node ticks from DEB_warning(). Add enter() and exit() functions to Porgress:Node.

parent c175be23
......@@ -21,9 +21,9 @@
#define DEB_out_if(CC, LL, AA) { PROGRESS_ACTIVE_TICK; }
#define DEB_line(LL, AA) { PROGRESS_ACTIVE_TICK; }
#define DEB_line_if(CC, LL, AA) { PROGRESS_ACTIVE_TICK; }
#define DEB_warning(LL, AA) { PROGRESS_ACTIVE_TICK; }
#define DEB_warning_if(CC, LL, AA) { PROGRESS_ACTIVE_TICK; }
#define DEB_warning(LL, AA) {}
#define DEB_warning_if(CC, LL, AA) {}
#define DEB_error(AA) {}
#define DEB_error_if(CC, AA) {}
......@@ -135,7 +135,8 @@ std::string to_string(const T& _t)
#define DEB_module(MODULE)
//TODO: This should use an atomic thread-safe static int(s)
#define DEB_enter_func PROGRESS_ACTIVE_TICK; \
#define DEB_enter_func \
PROGRESS_ACTIVE_TICK; \
static int deb_nmbr = 0; \
static int deb_lvl = Debug::INVALID_LEVEL; \
::Debug::Enter deb(__FILE__, __FUNCTION__, deb_nmbr, deb_lvl);
......@@ -155,9 +156,9 @@ std::string to_string(const T& _t)
{ if (deb.pass(LL) && (CC)) { deb.stream() << AA << ::Base::LF; } } }
#define DEB_warning(LL, AA) DEB_warning_if(true, LL, AA)
#define DEB_warning_if(CC, LL, AA) { PROGRESS_ACTIVE_TICK; \
#define DEB_warning_if(CC, LL, AA) \
{ if (deb.pass(LL) && (CC)) { ::Base::OStringStream strm; strm << AA; \
::Debug::warning(strm.str, BASE_CODELINK); } } }
::Debug::warning(strm.str, BASE_CODELINK); } }
#define DEB_error(AA) { ::Base::OStringStream strm; strm << AA; \
::Debug::error(strm.str, BASE_CODELINK); }
......
......@@ -22,10 +22,23 @@ public:
Node(const char* const _name,
Node* _next = nullptr, Node* _chld = nullptr)
: name(_name), next_(_next), chld_(_chld),
: name(_name), next_(_next), chld_(_chld), prnt_(nullptr), tick_nmbr_(0),
tick_nmbr_max_(1000000000), abrt_(false)
{}
void enter(Node* _prnt)
{
prnt_ = _prnt;
tick_nmbr_ = 0;
}
Node* exit()
{
auto prnt = prnt_;
prnt_ = nullptr;
return prnt;
}
void tick(const char* const _flnm, const char* const _fnct)
{
++tick_nmbr_;
......@@ -47,6 +60,7 @@ public:
protected:
Node* next_; //!< next node on the same level, last if nullptr
Node* chld_; //!< first child node, leaf if nullptr
Node* prnt_; //!< parent node, set temporarily
private:
TickNumber tick_nmbr_;
......@@ -58,17 +72,19 @@ extern thread_local Node* actv_node; // active node
struct ActiveScope
{
Node* prnt_node;
ActiveScope(Node* _node)
: prnt_node(actv_node)
{
if (_node == nullptr)
return;
_node->enter(actv_node);
actv_node = _node;
}
~ActiveScope()
{
actv_node = prnt_node;
if (actv_node == nullptr)
return;
actv_node = actv_node->exit();
}
};
......
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