torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::generic::VisitNet Class Reference

Public Types

typedef boost::shared_ptr< NetNetSharedPtr
 

Public Member Functions

void operator() (NetSharedPtr &inNetPtr) const
 

Detailed Description

Definition at line 36 of file Om1UnitTest.cpp.

Member Typedef Documentation

typedef boost::shared_ptr<Net> torc::generic::VisitNet::NetSharedPtr

Definition at line 38 of file Om1UnitTest.cpp.

Member Function Documentation

void torc::generic::VisitNet::operator() ( NetSharedPtr inNetPtr) const
inline

Definition at line 39 of file Om1UnitTest.cpp.

39  {
40  int sources = 0;
41  int sinks = 0;
42  // look for a single source and a single sink on the net
43  // get the ports
44  typedef boost::shared_ptr<Port> PortSharedPtr;
45  std::vector<PortSharedPtr> ports;
46  inNetPtr->getConnectedPorts(ports);
47  std::vector<PortSharedPtr>::const_iterator pp = ports.begin();
48  std::vector<PortSharedPtr>::const_iterator pe = ports.end();
49  while(pp < pe) {
50  const PortSharedPtr& portPtr = *pp++;
51  EPortDirection direction = portPtr->getDirection();
52  switch(direction) {
53  case ePortDirectionIn: sources++; break;
54  case ePortDirectionOut: sinks++; break;
55  case ePortDirectionInOut: sources++; sinks++; break;
56  default: break;
57  }
58  }
59  // get the port refs
60  typedef boost::shared_ptr<PortReference> PortReferenceSharedPtr;
61  std::vector<PortReferenceSharedPtr> portReferences;
62  inNetPtr->getConnectedPortRefs(portReferences);
63  // convert the port refs to ports
64  std::vector<PortReferenceSharedPtr>::const_iterator rp = portReferences.begin();
65  std::vector<PortReferenceSharedPtr>::const_iterator re = portReferences.end();
66  while(rp < re) {
67  const PortReferenceSharedPtr& portRefPtr = *rp++;
68  const PortSharedPtr& portPtr = portRefPtr->getMaster();
69  EPortDirection direction = portPtr->getDirection();
70  switch(direction) {
71  case ePortDirectionIn: sinks++; break;
72  case ePortDirectionOut: sources++; break;
73  case ePortDirectionInOut: sources++; sinks++; break;
74  default: break;
75  }
76  }
77  BOOST_REQUIRE_EQUAL(sources, 1);
78  std::cerr << "Net " << inNetPtr->getName() << ": "
79  << ports.size() << " ports, "
80  << portReferences.size() << " portRefs, "
81  << sources << " sources, "
82  << sinks << " sinks"
83  << std::endl;
84  }
boost::shared_ptr< PortReference > PortReferenceSharedPtr
boost::shared_ptr< Port > PortSharedPtr

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