Skip to content

Commit

Permalink
New methods in GroupProcessor
Browse files Browse the repository at this point in the history
For faster shortcuts in the Groovy bridge
  • Loading branch information
sylvainhalle committed Aug 28, 2024
1 parent 2fa8e4a commit 0bfd183
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Core/src/ca/uqac/lif/cep/GroupProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,31 @@ protected void associateEndpoints(GroupProcessor group,
group.associateOutput(output_number, clone_p, pa.m_ioNumber);
}
}

public Processor in(Processor p)
{
addProcessor(p);
associateInput(p);
return p;
}

public Processor out(Processor p)
{
addProcessor(p);
associateOutput(p);
collectProcessors(p);
return p;
}

/**
* Crawls the network of processors and adds to {@link #m_processors} any
* processor that is not already present in the list.
* @param start The starting point of the collection
*/
protected void collectProcessors(Processor start)
{
new CollectCrawler().crawl(start);;
}

/**
* Creates a copy of a processor.
Expand Down Expand Up @@ -599,6 +624,21 @@ public void visit(Processor p)
}
}
}

/**
* A crawler that adds to the group any processor it encounters.
*/
protected class CollectCrawler extends PipeCrawler
{
@Override
public void visit(Processor p)
{
if (!m_processors.contains(p))
{
m_processors.add(p);
}
}
}

@Override
public void setContext(Context context)
Expand Down

0 comments on commit 0bfd183

Please sign in to comment.