20 : m_name(name), m_id(id) {
22 for (
size_t ind=0; ind<nin; ++ind) {
26 for (
size_t ind=0; ind<nout; ++ind) {
27 m_ports[Port::output].push_back(
31 int id() {
return m_id; }
35 ss << m_name <<
"[" << m_id <<
"]";
39 std::cerr << ident() <<
":\t" <<
s;
46 if (
p.empty())
return false;
59 :
IdNode(
"src", id, 0, 1), m_num(beg), m_end(end) {}
83 if (iport().
empty()) {
return false; }
84 int d = boost::any_cast<
int>(iport().get());
93 auto& ip = input_ports();
94 for (
size_t ind=0; ind<ip.size(); ++ind) {
105 auto& o =
msg(
"join: ");
106 for (
auto p : input_ports()) {
111 int n = boost::any_cast<
int>(
d);
130 if (!m_buf.empty()) {
137 if (iport().empty()) {
145 auto d = m_buf.front();
158 if (iport().
empty()) {
161 auto obj = iport().get();
162 int d = boost::any_cast<
int>(obj);
164 for (
auto p : output_ports()) {
175 if (iport().
empty()) {
179 int d = boost::any_cast<
int>(out);
194 auto src1 =
new Source(count++, 0,4);
195 auto src2 =
new Source(count++, 10,14);
196 auto dst1 =
new Sink(count++);
197 auto dst2 =
new Sink(count++);
198 auto fun1 =
new Func(count++);
199 auto fun2 =
new Func(count++);
200 auto fun3 =
new Func(count++);
201 auto fan1 =
new Nfan(count++, 2);
202 auto joi1 =
new Njoin(count++, 2);
207 g.connect(src1,fun1);
208 g.connect(fun1,fan1);
209 g.connect(fan1,dst1);
210 g.connect(fan1,fun2,1);
211 g.connect(fun2,joi1);
212 g.connect(src2,fun3);
213 g.connect(fun3,joi1,0,1);
214 g.connect(joi1,sqb1);
215 g.connect(sqb1,dst2);
217 auto sorted = g.sort_kahn();
218 cout <<
"Sorted to " << sorted.size() <<
" nodes\n";
220 for (
size_t ind=0; ind<sorted.size(); ++ind) {
222 idn->
msg(
"at index ") << ind <<
endl;
224 cout <<
"Executing:\n";
virtual bool operator()()
virtual bool operator()()
void msg(const char *fmt,...)
virtual std::string ident()
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
virtual bool operator()()
virtual bool operator()()
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, VertexData, boost::property< boost::edge_weight_t, double, EdgeData > > Graph
define the boost-graph
virtual bool operator()()
Source(int id, int beg, int end)
std::ostream & msg(const std::string s)
IdNode(const std::string &name, int id, size_t nin=0, size_t nout=0)
virtual bool operator()()
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
QTextStream & endl(QTextStream &s)