32 #ifndef DATAFLOW_NETWORK_PORTMANAGER_H
33 #define DATAFLOW_NETWORK_PORTMANAGER_H
38 #include <boost/foreach.hpp>
39 #include <boost/range/adaptors.hpp>
40 #include <boost/range/algorithm/copy.hpp>
52 typedef std::map<PortId, T> PortMap;
59 size_t add(
const T& item);
60 void remove(
const PortId& id);
65 std::vector<T>
view()
const;
87 ports_[item->id()] = item;
90 auto index =
size() - 1;
98 auto it = ports_.find(
id);
99 if (it == ports_.end())
101 std::ostringstream ostr;
102 ostr <<
"PortManager tried to remove a port that does not exist: " << id;
107 BOOST_FOREACH(
typename PortMap::value_type& portPair, ports_)
108 portPair.second->setIndex(i++);
115 auto it = ports_.find(
id);
116 if (it == ports_.end())
123 std::ostringstream ostr;
124 ostr <<
"PortManager tried to access a port that does not exist: " << id;
133 std::vector<T> portsWithName;
136 ports_ | boost::adaptors::map_values
137 | boost::adaptors::filtered([&](
const T& port) {
return port->get_portname() ==
name; }), std::back_inserter(portsWithName));
139 if (portsWithName.empty())
144 return portsWithName;
150 std::vector<T> portVector;
151 boost::copy(ports_ | boost::adaptors::map_values, std::back_inserter(portVector));
152 std::sort(portVector.begin(), portVector.end(), [](
const T& lhs,
const T& rhs) {
return lhs->getIndex() < rhs->getIndex(); });
159 return ports_.find(
id) != ports_.end();
Definition: PortManager.h:68
Definition: ModuleInterface.h:81
void set_module(ModuleInterface *mod)
Definition: PortManager.h:64
boost::error_info< struct tag_error_message, std::string > ErrorMessage
Definition: Exception.h:52
size_t size() const
Definition: PortManager.h:78
std::vector< T > view() const
Definition: PortManager.h:148
bool hasPort(const PortId &id) const
Definition: PortManager.h:157
Definition: Exception.h:46
const char * name[]
Definition: BoostGraphExampleTests.cc:87
size_t add(const T &item)
Definition: PortManager.h:85
void remove(const PortId &id)
Definition: PortManager.h:96
T operator[](const PortId &id) const
Definition: PortManager.h:113
Definition: ModuleDescription.h:45
PortManager()
Definition: PortManager.h:71
int size
Definition: eabLatVolData.py:2
Definition: PortManager.h:49