31 #ifndef __adevs_digraph_h_ 32 #define __adevs_digraph_h_ 47 template <
class VALUE,
class PORT=
int>
class PortValue 89 template <
class VALUE,
class PORT=
int,
class T =
double>
class Digraph:
90 public Network<PortValue<VALUE,PORT>,T>
104 void add(Component* model);
106 void couple(Component* src, PORT srcPort,
107 Component* dst, PORT dstPort);
111 void route(
const IO_Type& x, Component* model,
125 node(Component* model, PORT
port):
140 bool operator<(
const node& other)
const 142 if (model == other.model)
return port < other.port;
143 return model < other.model;
149 std::map<node,Bag<node> > graph;
152 template <
class VALUE,
class PORT,
class T>
155 assert(model !=
this);
156 models.insert(model);
160 template <
class VALUE,
class PORT,
class T>
164 if (src !=
this) add(src);
165 if (dst !=
this) add(dst);
166 node src_node(src,srcPort);
167 node dst_node(dst,dstPort);
168 graph[src_node].insert(dst_node);
171 template <
class VALUE,
class PORT,
class T>
177 template <
class VALUE,
class PORT,
class T>
183 node src_node(model,x.
port);
184 typename std::map<node,Bag<node> >::iterator graph_iter;
185 graph_iter = graph.find(src_node);
187 if (graph_iter == graph.end())
return;
191 for (node_iter = (*graph_iter).second.begin();
192 node_iter != (*graph_iter).second.end(); node_iter++)
194 event.model = (*node_iter).model;
195 event.value.port = (*node_iter).port;
196 event.value.value = x.
value;
200 template <
class VALUE,
class PORT,
class T>
204 for (i = models.begin(); i != models.end(); i++)
Definition: adevs_set.h:42
const PortValue< VALUE, PORT > & operator=(const PortValue< VALUE, PORT > &src)
Assignment operator.
Definition: adevs_digraph.h:69
Digraph()
Construct a network with no components.
Definition: adevs_digraph.h:99
Definition: adevs_digraph.h:47
PortValue(const PortValue &src)
Copy constructor.
Definition: adevs_digraph.h:57
PortValue()
Constructor.
Definition: adevs_digraph.h:51
void route(const IO_Type &x, Component *model, Bag< Event< IO_Type, T > > &r)
Route an event based on the coupling information.
Definition: adevs_digraph.h:179
Definition: adevs_models.h:46
PORT port
The port on which the value appears.
Definition: adevs_digraph.h:80
void setParent(Network< X, T > *parent)
Definition: adevs_models.h:92
Devs< IO_Type, T > Component
A component of the Digraph model.
Definition: adevs_digraph.h:96
~PortValue()
Destructor.
Definition: adevs_digraph.h:76
void couple(Component *src, PORT srcPort, Component *dst, PORT dstPort)
Couple the source model to the destination model.
Definition: adevs_digraph.h:161
PortValue< VALUE, PORT > IO_Type
An input or output to a component model.
Definition: adevs_digraph.h:94
A bidirectional iterator for the Bag.
Definition: adevs_bag.h:49
Definition: adevs_fmi.h:57
PortValue(PORT port, const VALUE &value)
Create an object with the specified port and value.
Definition: adevs_digraph.h:63
~Digraph()
Destructor. Destroys all of the component models.
Definition: adevs_digraph.h:201
VALUE value
The value appearing on the port.
Definition: adevs_digraph.h:82
Definition: adevs_models.h:58
Definition: adevs_digraph.h:89
Definition: adevs_models.h:116
void getComponents(Set< Component * > &c)
Puts the network's components into to c.
Definition: adevs_digraph.h:172
void add(Component *model)
Add a model to the network.
Definition: adevs_digraph.h:153
Definition: adevs_bag.h:45