From f3e7f0bb9866edb30682b1e1b72db7c4f6946378 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Tue, 26 Aug 2014 11:39:34 +0200 Subject: conditionalized debugging std::couts --- src/uscxml/Interpreter.cpp | 14 +++++++------- src/uscxml/interpreter/InterpreterRC.cpp | 32 ++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index eface5e..b87efed 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -745,7 +745,7 @@ InterpreterState InterpreterImpl::step(int waitForMS) { // goto initial configuration NodeSet initialTransitions = getDocumentInitialTransitions(); assert(initialTransitions.size() > 0); -#if 1 +#if VERBOSE std::cout << _name << ": initialTransitions: " << std::endl; for (int i = 0; i < initialTransitions.size(); i++) { std::cout << initialTransitions[i] << std::endl; @@ -1042,7 +1042,7 @@ Arabica::XPath::NodeSet InterpreterImpl::selectEventlessTransitions } states.to_document_order(); -#if 0 +#if VERBOSE std::cout << "Atomic States: "; for (int i = 0; i < atomicStates.size(); i++) { std::cout << ATTR(atomicStates[i], "id") << ", "; @@ -1072,7 +1072,7 @@ Arabica::XPath::NodeSet InterpreterImpl::selectEventlessTransitions index++; } -#if 0 +#if VERBOSE std::cout << "Enabled eventless transitions: " << std::endl; for (int i = 0; i < enabledTransitions.size(); i++) { std::cout << enabledTransitions[i] << std::endl << "----" << std::endl; @@ -2231,7 +2231,7 @@ void InterpreterImpl::executeContent(const Arabica::DOM::Element& c } else if (iequals(TAGNAME(content), _nsInfo.xmlNSPrefix + "if")) { // --- IF / ELSEIF / ELSE -------------- Arabica::DOM::Element ifElem = (Arabica::DOM::Element)content; -#if 0 +#if VERBOSE if (HAS_ATTR(ifElem, "cond")) std::cout << ATTR(ifElem, "cond") << std::endl; #endif @@ -2550,7 +2550,7 @@ Arabica::DOM::Node InterpreterImpl::getAncestorElement(const Arabic */ Arabica::DOM::Node InterpreterImpl::findLCCA(const Arabica::XPath::NodeSet& states) { -#if 0 +#if VERBOSE std::cout << "findLCCA: "; for (int i = 0; i < states.size(); i++) { std::cout << ATTR(states[i], "id") << " - " << TAGNAME(states[i]) << ", "; @@ -2565,7 +2565,7 @@ Arabica::DOM::Node InterpreterImpl::findLCCA(const Arabica::XPath:: if (!isCompound(Element(ancestors[i]))) continue; for (int j = 0; j < states.size(); j++) { -#if 0 +#if VERBOSE std::cout << "Checking " << TAGNAME(states[j]) << " and " << TAGNAME(ancestors[i]) << std::endl; #endif if (!isDescendant(states[j], ancestors[i]) && (states[j] != ancestors[i])) @@ -2581,7 +2581,7 @@ NEXT_ANCESTOR: if (!ancestor) ancestor = _scxml; assert(ancestor); -#if 0 +#if VERBOSE std::cout << " -> " << ATTR(ancestor, "id") << " " << ancestor.getLocalName() << std::endl; #endif return ancestor; diff --git a/src/uscxml/interpreter/InterpreterRC.cpp b/src/uscxml/interpreter/InterpreterRC.cpp index 6aea740..d91eadb 100644 --- a/src/uscxml/interpreter/InterpreterRC.cpp +++ b/src/uscxml/interpreter/InterpreterRC.cpp @@ -26,6 +26,8 @@ #include "uscxml/UUID.h" #include "uscxml/DOMUtils.h" +#define VERBOSE 0 + namespace uscxml { using namespace Arabica::XPath; @@ -170,7 +172,7 @@ Arabica::XPath::NodeSet InterpreterRC::computeExitSet(const Arabica } } } -#if 0 +#if VERBOSE std::cout << "computeExitSet: "; for (int i = 0; i < statesToExit.size(); i++) { std::cout << ATTR(statesToExit[i], "id") << " "; @@ -272,7 +274,7 @@ void InterpreterRC::computeEntrySet(const Arabica::XPath::NodeSet& NodeSet targets = getTargetStates(t); -#if 1 +#if VERBOSE std::cout << "computeEntrySet: "; for (int i = 0; i < targets.size(); i++) { std::cout << ATTR_CAST(targets[i], "id") << " "; @@ -291,7 +293,7 @@ void InterpreterRC::computeEntrySet(const Arabica::XPath::NodeSet& addDescendantStatesToEnter(s,statesToEnter,statesForDefaultEntry, defaultHistoryContent); } -#if 1 +#if VERBOSE std::cout << "after addDescendantStatesToEnter: "; for (int i = 0; i < statesToEnter.size(); i++) { std::cout << ATTR_CAST(statesToEnter[i], "id") << " "; @@ -307,7 +309,7 @@ void InterpreterRC::computeEntrySet(const Arabica::XPath::NodeSet& addAncestorStatesToEnter(s, ancestor, statesToEnter, statesForDefaultEntry, defaultHistoryContent); } -#if 1 +#if VERBOSE std::cout << "after addAncestorStatesToEnter: "; for (int i = 0; i < statesToEnter.size(); i++) { std::cout << ATTR_CAST(statesToEnter[i], "id") << " "; @@ -327,13 +329,15 @@ void InterpreterRC::computeEntrySet(const Arabica::XPath::NodeSet& NodeSet targets = getTargetStates(t); for (int j = 0; j < targets.size(); j++) { if (!isMember(targets[j], statesToEnter)) { +#if VERBOSE std::cout << "adding: " << ATTR_CAST(anc, "id") << std::endl; +#endif statesToEnter.push_back(targets[j]); } } } -#if 1 +#if VERBOSE std::cout << "before addDescendantStatesToEnter: "; for (int i = 0; i < statesToEnter.size(); i++) { std::cout << ATTR_CAST(statesToEnter[i], "id") << " "; @@ -347,7 +351,7 @@ void InterpreterRC::computeEntrySet(const Arabica::XPath::NodeSet& addDescendantStatesToEnter(tmp[i],statesToEnter,statesForDefaultEntry, defaultHistoryContent); } -#if 1 +#if VERBOSE std::cout << "after addDescendantStatesToEnter: "; for (int i = 0; i < statesToEnter.size(); i++) { std::cout << ATTR_CAST(statesToEnter[i], "id") << " "; @@ -365,7 +369,7 @@ void InterpreterRC::computeEntrySet(const Arabica::XPath::NodeSet& } } -#if 1 +#if VERBOSE std::cout << "after addAncestorStatesToEnter: "; for (int i = 0; i < statesToEnter.size(); i++) { std::cout << ATTR_CAST(statesToEnter[i], "id") << " "; @@ -413,9 +417,11 @@ void InterpreterRC::addDescendantStatesToEnter(const Arabica::DOM::Element& statesForDefaultEntry, std::map > defaultHistoryContent) { +#if VERBOSE std::cout << getPadding() << "addDescendantStatesToEnter: " << ATTR(state, "id") << std::endl; padding++; - +#endif + if (isHistory(state)) { std::string stateId = ATTR(state, "id"); @@ -446,7 +452,9 @@ void InterpreterRC::addDescendantStatesToEnter(const Arabica::DOM::Element& statesForDefaultEntry, std::map > defaultHistoryContent) { +#if VERBOSE std::cout << getPadding() << "addAncestorStatesToEnter: " << ATTR(state, "id") << " - " << ATTR(ancestor, "id") << std::endl; padding++; - +#endif + NodeSet ancestors = getProperAncestors(state, ancestor); for (int i = 0; i < ancestors.size(); i++) { const Node& anc = ancestors[i]; +#if VERBOSE std::cout << getPadding() << "adding: " << ATTR_CAST(anc, "id") << std::endl; +#endif statesToEnter.push_back(anc); if (isParallel(Element(anc))) { NodeSet childStates = getChildStates(anc); @@ -550,7 +562,7 @@ BREAK_LOOP: NodeSet tStates = getTargetStates(transition); Node source = getSourceState(transition); -#if 0 +#if VERBOSE std::cout << "getTransitionDomain: " << std::endl << transition << std::endl; #endif -- cgit v0.12