From c209a900cf83138abc8a09fd1bfd3a7b0505ed05 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 5 Mar 2015 22:14:07 +0100 Subject: [PATCH] [DEV] add a dot interface --- drain/Process.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++- drain/Process.h | 6 ++++ 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/drain/Process.cpp b/drain/Process.cpp index da6bc94..5eb0eed 100644 --- a/drain/Process.cpp +++ b/drain/Process.cpp @@ -441,4 +441,81 @@ bool drain::Process::processIn(void* _inData, DRAIN_VERBOSE("Copy " << _outNbChunk << " chunks byte size=" << audio::getFormatBytes(m_outputConfig.getFormat()) << " nbChan=" << m_outputConfig.getMap().size() << " format=" << m_outputConfig.getFormat()); memcpy(_outData, outData, _outNbChunk*audio::getFormatBytes(m_outputConfig.getFormat()) * m_outputConfig.getMap().size()); return false; -} \ No newline at end of file +} + +static void link(etk::FSNode& _node, const std::string& _first, const std::string& _op, const std::string& _second, bool _isLink=true) { + if (_op == "->") { + if (_isLink) { + _node << " " << _first << " -> " << _second << ";\n"; + } else { + _node << " " << _first << " -> " << _second << " [style=dashed];\n"; + } + } else if (_op == "<-") { + _node << " " << _first << " -> " <<_second<< " [color=transparent];\n"; + if (_isLink) { + _node << " " << _second << " -> " << _first << " [constraint=false];\n"; + } else { + _node << " " << _second << " -> " << _first << " [constraint=false, style=dashed];\n"; + } + } +} + +void drain::Process::generateDot(etk::FSNode& _node, int32_t _offset, int32_t _basicID, std::string& _nameIn, std::string& _nameOut, bool _reserseGraph) { + _node << " subgraph clusterNode_" << _basicID << "_process {\n"; + _node << " label=\"Drain::Process\";\n"; + _node << " node [shape=ellipse];\n"; + + if (_reserseGraph == false) { + _nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in"; + _node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat()) + << "\\n freq=" << getInputConfig().getFrequency() + << "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n"; + } else { + _nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out"; + _node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat()) + << "\\n freq=" << getOutputConfig().getFrequency() + << "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n"; + } + std::string connectString = _nameIn; + _node << " node [shape=box];\n"; + if (_reserseGraph == false) { + for (size_t iii=0; iiigetType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n"; + link(_node, connectString, "->", connectStringSecond); + connectString = connectStringSecond; + } + } else { + for (int32_t iii=m_listAlgo.size()-1; iii>=0; --iii) { + if (m_listAlgo[iii] == nullptr) { + continue; + } + std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii); + _node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n"; + link(_node, connectStringSecond, "<-", connectString); + connectString = connectStringSecond; + } + } + _node << " node [shape=ellipse];\n"; + if (_reserseGraph == false) { + _nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out"; + _node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat()) + << "\\n freq=" << getOutputConfig().getFrequency() + << "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n"; + } else { + _nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in"; + _node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat()) + << "\\n freq=" << getInputConfig().getFrequency() + << "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n"; + } + if (_reserseGraph == false) { + link(_node, connectString, "->", _nameOut); + } else { + link(_node, _nameOut, "<-", connectString); + } + _node << " }\n"; +} + diff --git a/drain/Process.h b/drain/Process.h index a5577ae..6f27444 100644 --- a/drain/Process.h +++ b/drain/Process.h @@ -16,6 +16,7 @@ #include #include #include +#include namespace drain{ class Process { @@ -111,6 +112,9 @@ namespace drain{ std::vector >::iterator end() { return m_listAlgo.end(); } + std11::shared_ptr operator[](int32_t _id) { + return m_listAlgo[_id]; + } template std11::shared_ptr get(const std::string& _name) { for (size_t iii=0; iii