|
@@ -25,9 +25,10 @@
|
|
|
*/
|
|
|
|
|
|
#ifndef PDEVS_GRAPH_MANANGER
|
|
|
-#define PDEVS_GRAPH_MANANGER 1
|
|
|
+#define PDEVS_GRAPH_MANANGER
|
|
|
|
|
|
#include <paradevs/common/Coordinator.hpp>
|
|
|
+#include <paradevs/common/GraphManager.hpp>
|
|
|
#include <paradevs/common/Links.hpp>
|
|
|
#include <paradevs/common/Model.hpp>
|
|
|
#include <paradevs/common/Parameters.hpp>
|
|
@@ -39,47 +40,38 @@ namespace paradevs { namespace pdevs {
|
|
|
|
|
|
template < class Time,
|
|
|
class GraphParameters = common::NoParameters >
|
|
|
-class GraphManager
|
|
|
+class GraphManager : public common::GraphManager < Time >
|
|
|
{
|
|
|
public:
|
|
|
GraphManager(common::Coordinator < Time >* coordinator,
|
|
|
const GraphParameters& /* parameters */) :
|
|
|
- _coordinator(coordinator)
|
|
|
+ common::GraphManager < Time >(coordinator)
|
|
|
{ }
|
|
|
|
|
|
virtual ~GraphManager()
|
|
|
{ }
|
|
|
|
|
|
- void add_child(common::Model < Time >* child)
|
|
|
- {
|
|
|
- _child_list.push_back(child);
|
|
|
- child->set_parent(_coordinator);
|
|
|
- }
|
|
|
-
|
|
|
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 != _coordinator and
|
|
|
- dst_model != _coordinator and
|
|
|
+ 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 == _coordinator and
|
|
|
- dst_model != _coordinator and
|
|
|
+ (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 != _coordinator and
|
|
|
- dst_model == _coordinator and
|
|
|
+ (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)));
|
|
|
|
|
|
_link_list.add(src_model, src_port_name, dst_model, dst_port_name);
|
|
|
}
|
|
|
|
|
|
- const common::Models < Time >& children() const
|
|
|
- { return _child_list; }
|
|
|
-
|
|
|
void dispatch_events(common::Bag < Time > bag,
|
|
|
typename Time::type t)
|
|
|
{
|
|
@@ -92,7 +84,8 @@ public:
|
|
|
const_iterator it = result_model.first;
|
|
|
it != result_model.second; ++it) {
|
|
|
// event on output port of coupled Model
|
|
|
- if (it->second.get_model() == _coordinator) {
|
|
|
+ if (it->second.get_model() ==
|
|
|
+ common::GraphManager < Time >::_coordinator) {
|
|
|
dispatch_events_to_parent(it->second, ymsg.get_content(),
|
|
|
t);
|
|
|
} else { // event on input port of internal model
|
|
@@ -114,8 +107,8 @@ public:
|
|
|
common::ExternalEvent <Time >(node, content));
|
|
|
|
|
|
dynamic_cast < common::Coordinator < Time >* >(
|
|
|
- _coordinator->get_parent())->dispatch_events(
|
|
|
- ymessages, t);
|
|
|
+ common::GraphManager < Time >::_coordinator->get_parent())
|
|
|
+ ->dispatch_events(ymessages, t);
|
|
|
}
|
|
|
|
|
|
bool exist_link(common::Model < Time >* src_model,
|
|
@@ -127,14 +120,12 @@ public:
|
|
|
dst_port_name);
|
|
|
}
|
|
|
|
|
|
- common::Coordinator < Time >* get_coordinator() const
|
|
|
- { return _coordinator; }
|
|
|
-
|
|
|
void post_event(typename Time::type t,
|
|
|
const common::ExternalEvent < Time >& event)
|
|
|
{
|
|
|
typename common::Links < Time >::Result result =
|
|
|
- _link_list.find(_coordinator, event.get_port_name());
|
|
|
+ _link_list.find(common::GraphManager < Time >::_coordinator,
|
|
|
+ event.get_port_name());
|
|
|
|
|
|
for (typename common::Links < Time >::const_iterator it_r =
|
|
|
result.first; it_r != result.second; ++it_r) {
|
|
@@ -149,17 +140,15 @@ public:
|
|
|
std::ostringstream ss;
|
|
|
|
|
|
ss << common::spaces(level * 2) << "Childs :" << std::endl;
|
|
|
- for (auto & child : _child_list) {
|
|
|
- ss << child->to_string(level + 1);
|
|
|
+ for (auto & child : common::GraphManager < Time >::_child_list) {
|
|
|
+ ss << child.second->to_string(level + 1);
|
|
|
}
|
|
|
ss << _link_list.to_string(level);
|
|
|
return ss.str();
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
- common::Links < Time > _link_list;
|
|
|
- common::Models < Time > _child_list;
|
|
|
- common::Coordinator < Time >* _coordinator;
|
|
|
+ common::Links < Time > _link_list;
|
|
|
};
|
|
|
|
|
|
} } // namespace paradevs pdevs
|