Public Member Functions | Private Attributes | List of all members
WireCell::Pgraph::Hydra Class Reference

#include <Wrappers.h>

Inheritance diagram for WireCell::Pgraph::Hydra:
WireCell::Pgraph::PortedNode WireCell::Pgraph::Node

Public Member Functions

 Hydra (INode::pointer wcnode)
 
virtual ~Hydra ()
 
virtual bool operator() ()
 
- Public Member Functions inherited from WireCell::Pgraph::PortedNode
 PortedNode (INode::pointer wcnode)
 
virtual std::string ident ()
 
- Public Member Functions inherited from WireCell::Pgraph::Node
 Node ()
 
virtual ~Node ()
 
Portiport (size_t ind=0)
 
Portoport (size_t ind=0)
 
PortListinput_ports ()
 
PortListoutput_ports ()
 
Portport (Port::Type type, size_t ind=0)
 
Portport (Port::Type type, const std::string &name)
 
bool connected ()
 

Private Attributes

IHydraNodeBase::pointer m_wcnode
 

Additional Inherited Members

- Protected Attributes inherited from WireCell::Pgraph::Node
PortList m_ports [Port::ntypes]
 

Detailed Description

Definition at line 279 of file Wrappers.h.

Constructor & Destructor Documentation

WireCell::Pgraph::Hydra::Hydra ( INode::pointer  wcnode)
inline

Definition at line 282 of file Wrappers.h.

282  : PortedNode(wcnode) {
283  m_wcnode = std::dynamic_pointer_cast<IHydraNodeBase>(wcnode);
284  }
IHydraNodeBase::pointer m_wcnode
Definition: Wrappers.h:280
PortedNode(INode::pointer wcnode)
Definition: Wrappers.h:40
virtual WireCell::Pgraph::Hydra::~Hydra ( )
inlinevirtual

Definition at line 285 of file Wrappers.h.

285 { }

Member Function Documentation

virtual bool WireCell::Pgraph::Hydra::operator() ( void  )
inlinevirtual

Implements WireCell::Pgraph::Node.

Definition at line 287 of file Wrappers.h.

287  {
288  auto& iports = input_ports();
289  size_t nin = iports.size();
290 
291  // 0) Hydra needs all input ports full to be ready.
292  // For EOS, the concrete INode better retain the
293  // terminating nullptr in its input stream.
294  for (size_t ind=0; ind < nin; ++ind) {
295  if (iports[ind].empty()) {
296  return false;
297  }
298  }
299 
300  // 1) fill input any queue vector
302  for (size_t ind=0; ind < nin; ++ind) {
303  Edge edge = iports[ind].edge();
304  if (!edge) {
305  std::cerr << "Hydra: got broken edge\n";
306  continue;
307  }
308  if (edge->empty()) {
309  continue;
310  }
311  inqv[ind].insert(inqv[ind].begin(), edge->begin(), edge->end());
312  }
313 
314  auto& oports = output_ports();
315  size_t nout = oports.size();
316 
317  // 2) create output any queue vector
319 
320  // 3) call
321  bool ok = (*m_wcnode)(inqv, outqv);
322  if (!ok) { return false; } // fixme: this probably
323  // needs to reflect into
324  // ready().
325 
326  // 4) pop dfp input queues to match. BIG FAT
327  // WARNING: this trimming assumes calller only
328  // pop_front's. Really should hunt for which ones
329  // have been removed.
330  for (size_t ind=0; ind < nin; ++ind) {
331  size_t want = inqv[ind].size();
332  while (iports[ind].size() > want) {
333  iports[ind].get();
334  }
335  }
336 
337  // 5) send out output any queue vectors
338  for (size_t ind=0; ind < nout; ++ind) {
339  Edge edge = oports[ind].edge();
340  edge->insert(edge->end(), outqv[ind].begin(), outqv[ind].end());
341  }
342 
343  return true;
344  }
PortList & input_ports()
Definition: Node.h:29
std::shared_ptr< Queue > Edge
Definition: Port.h:27
std::pair< int, int > edge(const realseq_t &wave)
Definition: Waveform.cxx:121
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:87
std::vector< any_queue > any_queue_vector
Definition: IHydraNode.h:31
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:67
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:92
PortList & output_ports()
Definition: Node.h:32

Member Data Documentation

IHydraNodeBase::pointer WireCell::Pgraph::Hydra::m_wcnode
private

Definition at line 280 of file Wrappers.h.


The documentation for this class was generated from the following file: