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

#include <Port.h>

Public Types

enum  Type {
  tail =0, output =0, head =1, input =1,
  ntypes =2
}
 

Public Member Functions

 Port (Node *node, Type type, std::string signature, std::string name="")
 
bool isinput ()
 
bool isoutput ()
 
Edge edge ()
 
Edge plug (Edge edge)
 
size_t size ()
 
bool empty ()
 
Data get (bool pop=true)
 
void put (Data &data)
 
Nodenode ()
 
const std::stringname ()
 
const std::stringsignature ()
 

Private Attributes

Nodem_node
 
Type m_type
 
std::string m_name
 
std::string m_sig
 
Edge m_edge
 

Detailed Description

Definition at line 31 of file Port.h.

Member Enumeration Documentation

Enumerator
tail 
output 
head 
input 
ntypes 

Definition at line 33 of file Port.h.

Constructor & Destructor Documentation

Port< T >::Port ( Node node,
Type  type,
std::string  signature,
std::string  name = "" 
)

Definition at line 9 of file Port.cxx.

10  : m_node(node)
11  , m_type(type)
12  , m_name(name)
13  , m_sig(signature)
14  , m_edge(nullptr)
15 { }
const std::string & name()
Definition: Port.cxx:72
std::string m_name
Definition: Port.h:66
const std::string & signature()
Definition: Port.cxx:73
std::string m_sig
Definition: Port.h:66

Member Function Documentation

Edge Port< T >::edge ( )

Definition at line 20 of file Port.cxx.

20 { return m_edge; }
bool Port< T >::empty ( void  )

Definition at line 36 of file Port.cxx.

36  {
37  if (!m_edge or m_edge->empty()) { return true; }
38  return false;
39 }
Data Port< T >::get ( bool  pop = true)

Definition at line 43 of file Port.cxx.

43  {
44  if (isoutput()) {
45  THROW(RuntimeError()
46  << errmsg{"can not get from output port"});
47  }
48  if (!m_edge) {
49  THROW(RuntimeError() << errmsg{"port has no edge"});
50  }
51  if (m_edge->empty()) {
52  THROW(RuntimeError() << errmsg{"edge is empty"});
53  }
54  Data ret = m_edge->front();
55  if (pop) {
56  m_edge->pop_front();
57  }
58  return ret;
59 }
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
#define THROW(e)
Definition: Exceptions.h:25
bool Port< T >::isinput ( )

Definition at line 17 of file Port.cxx.

bool Port< T >::isoutput ( )

Definition at line 18 of file Port.cxx.

const std::string & Port< T >::name ( )

Definition at line 72 of file Port.cxx.

72 { return m_name; }
std::string m_name
Definition: Port.h:66
Node* WireCell::Pgraph::Port::node ( )
Edge Port< T >::plug ( Edge  edge)

Definition at line 23 of file Port.cxx.

23  {
24  Edge ret = m_edge;
25  m_edge = edge;
26  return ret;
27 }
std::shared_ptr< Queue > Edge
Definition: Port.h:27
void Port< T >::put ( Data data)

Definition at line 62 of file Port.cxx.

62  {
63  if (isinput()) {
64  THROW(RuntimeError() << errmsg{"can not put to input port"});
65  }
66  if (!m_edge) {
67  THROW(RuntimeError() << errmsg{"port has no edge"});
68  }
69  m_edge->push_back(data);
70 }
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
#define THROW(e)
Definition: Exceptions.h:25
const std::string & Port< T >::signature ( )

Definition at line 73 of file Port.cxx.

73 { return m_sig; }
std::string m_sig
Definition: Port.h:66
size_t Port< T >::size ( void  )

Definition at line 30 of file Port.cxx.

30  {
31  if (!m_edge) { return 0; }
32  return m_edge->size();
33 }

Member Data Documentation

Edge WireCell::Pgraph::Port::m_edge
private

Definition at line 67 of file Port.h.

std::string WireCell::Pgraph::Port::m_name
private

Definition at line 66 of file Port.h.

Node* WireCell::Pgraph::Port::m_node
private

Definition at line 64 of file Port.h.

std::string WireCell::Pgraph::Port::m_sig
private

Definition at line 66 of file Port.h.

Type WireCell::Pgraph::Port::m_type
private

Definition at line 65 of file Port.h.


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