|
@@ -43,6 +43,27 @@ template < class Time,
|
|
|
class GraphManager : public common::GraphManager < Time >
|
|
|
{
|
|
|
public:
|
|
|
+ typedef GraphManager < Time, GraphParameters > type;
|
|
|
+
|
|
|
+ struct ModelPort
|
|
|
+ {
|
|
|
+ common::Model < Time >* model;
|
|
|
+ unsigned int port_index;
|
|
|
+ type* graph_manager;
|
|
|
+
|
|
|
+ ModelPort(common::Model < Time >* model,
|
|
|
+ unsigned int port_index) : model(model),
|
|
|
+ port_index(port_index),
|
|
|
+ graph_manager(nullptr)
|
|
|
+ {}
|
|
|
+
|
|
|
+ void operator>>(const ModelPort& dst)
|
|
|
+ {
|
|
|
+ graph_manager->add_link(model, port_index,
|
|
|
+ dst.model, dst.port_index);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
GraphManager(common::Coordinator < Time >* coordinator,
|
|
|
const GraphParameters& /* parameters */) :
|
|
|
common::GraphManager < Time >(coordinator)
|
|
@@ -51,26 +72,11 @@ public:
|
|
|
virtual ~GraphManager()
|
|
|
{ }
|
|
|
|
|
|
- void add_link(common::Model < Time >* src_model,
|
|
|
- const std::string& src_port_name,
|
|
|
- common::Model < Time >* dst_model,
|
|
|
- const std::string& dst_port_name)
|
|
|
- {
|
|
|
- assert((src_model != common::GraphManager < Time >::_coordinator and
|
|
|
- dst_model != common::GraphManager < Time >::_coordinator and
|
|
|
- src_model->exist_out_port(src_port_name) and
|
|
|
- dst_model->exist_in_port(dst_port_name)) or
|
|
|
- (src_model == common::GraphManager < Time >::_coordinator and
|
|
|
- dst_model != common::GraphManager < Time >::_coordinator and
|
|
|
- src_model->exist_in_port(src_port_name) and
|
|
|
- dst_model->exist_in_port(dst_port_name)) or
|
|
|
- (src_model != common::GraphManager < Time >::_coordinator and
|
|
|
- dst_model == common::GraphManager < Time >::_coordinator and
|
|
|
- src_model->exist_out_port(src_port_name) and
|
|
|
- dst_model->exist_out_port(dst_port_name)));
|
|
|
+ ModelPort in(ModelPort p)
|
|
|
+ { p.graph_manager = this; return p; }
|
|
|
|
|
|
- _link_list.add(src_model, src_port_name, dst_model, dst_port_name);
|
|
|
- }
|
|
|
+ ModelPort out(ModelPort p)
|
|
|
+ { p.graph_manager = this; return p; }
|
|
|
|
|
|
void dispatch_events(common::Bag < Time > bag,
|
|
|
typename Time::type t)
|
|
@@ -78,7 +84,7 @@ public:
|
|
|
for (auto & ymsg : bag) {
|
|
|
typename common::Links < Time >::Result result_model =
|
|
|
_link_list.find(ymsg.get_model(),
|
|
|
- ymsg.get_port_name());
|
|
|
+ ymsg.get_port_index());
|
|
|
|
|
|
for (typename common::Links < Time >::
|
|
|
const_iterator it = result_model.first;
|
|
@@ -112,12 +118,12 @@ public:
|
|
|
}
|
|
|
|
|
|
bool exist_link(common::Model < Time >* src_model,
|
|
|
- const std::string& src_port_name,
|
|
|
+ unsigned int src_port_index,
|
|
|
common::Model < Time >* dst_model,
|
|
|
- const std::string& dst_port_name) const
|
|
|
+ unsigned int dst_port_index) const
|
|
|
{
|
|
|
- return _link_list.exist(src_model, src_port_name, dst_model,
|
|
|
- dst_port_name);
|
|
|
+ return _link_list.exist(src_model, src_port_index, dst_model,
|
|
|
+ dst_port_index);
|
|
|
}
|
|
|
|
|
|
void post_event(typename Time::type t,
|
|
@@ -125,7 +131,7 @@ public:
|
|
|
{
|
|
|
typename common::Links < Time >::Result result =
|
|
|
_link_list.find(common::GraphManager < Time >::_coordinator,
|
|
|
- event.get_port_name());
|
|
|
+ event.get_port_index());
|
|
|
|
|
|
for (typename common::Links < Time >::const_iterator it_r =
|
|
|
result.first; it_r != result.second; ++it_r) {
|
|
@@ -148,6 +154,27 @@ public:
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
+ void add_link(common::Model < Time >* src_model,
|
|
|
+ unsigned int src_port_index,
|
|
|
+ common::Model < Time >* dst_model,
|
|
|
+ unsigned int dst_port_index)
|
|
|
+ {
|
|
|
+ assert((src_model != common::GraphManager < Time >::_coordinator and
|
|
|
+ dst_model != common::GraphManager < Time >::_coordinator and
|
|
|
+ src_model->exist_out_port(src_port_index) and
|
|
|
+ dst_model->exist_in_port(dst_port_index)) or
|
|
|
+ (src_model == common::GraphManager < Time >::_coordinator and
|
|
|
+ dst_model != common::GraphManager < Time >::_coordinator and
|
|
|
+ src_model->exist_in_port(src_port_index) and
|
|
|
+ dst_model->exist_in_port(dst_port_index)) or
|
|
|
+ (src_model != common::GraphManager < Time >::_coordinator and
|
|
|
+ dst_model == common::GraphManager < Time >::_coordinator and
|
|
|
+ src_model->exist_out_port(src_port_index) and
|
|
|
+ dst_model->exist_out_port(dst_port_index)));
|
|
|
+
|
|
|
+ _link_list.add(src_model, src_port_index, dst_model, dst_port_index);
|
|
|
+ }
|
|
|
+
|
|
|
common::Links < Time > _link_list;
|
|
|
};
|
|
|
|