00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00037 #ifndef YMLNETWORK_H
00038 #define YMLNETWORK_H
00039
00040 #include <map>
00041 #include <list>
00042
00043 #include <BasicUtils/BasicArray.h>
00044
00045 #include "ymlnode.h"
00046
00047 class YMLLink;
00048 class YMLEntityFactory;
00049 class YMLConnection;
00050 class TraceContext;
00051
00052 #ifndef LTSTR
00053 #define LTSTR
00054 #include <string.h>
00055 struct ltstr {
00056 bool operator()(const char* s1, const char* s2) const {
00057 return strcmp(s1, s2) < 0;
00058 }
00059 };
00060 #endif
00061
00062 typedef std::list<YMLNode *> node_list_t;
00063
00064
00065 class YMLNetwork: public YMLNode {
00067 std::map<const char *, YMLNode *, ltstr> node_map;
00069 BasicArray<YMLLink *> links;
00071 BasicArray<YMLNode *> nodes;
00073 BasicArray<YMLConnection *> connections;
00074
00075 TraceContext *traceContext;
00076
00077 public:
00078 YMLNetwork();
00079 virtual ~YMLNetwork();
00080
00081
00087 void addLink(YMLLink *link) {links.put(link);}
00091 int getNumLinks() {return links.getSize();}
00099 YMLLink *getLink(int i) {return links[i];}
00100
00101
00102 void addNode(YMLNode *node);
00110 YMLNode *findNode(const char *name) {return node_map[name];}
00115 int getNumNodes() {return nodes.getSize();}
00123 YMLNode *getNode(int i) {return nodes[i];}
00124 void collectAllNodes(node_list_t &list);
00125
00126
00130 int getNumConnections() {return connections.getSize();}
00138 YMLConnection *getConnection(int i) {return connections[i];}
00139 bool connect();
00140 void createDirectConnections(YMLEntityFactory *factory, YMLPort *source,
00141 YMLPortSide *side, int commChannelID);
00142 void createDirectConnections(YMLEntityFactory *factory);
00143
00144 void setTraceContext(TraceContext *traceContext)
00145 {this->traceContext = traceContext;}
00146 TraceContext *getTraceContext() {return traceContext;}
00147
00148
00149
00150 virtual void dumpXML(XMLSerializer &stream);
00151 void dumpXMLLinks(XMLSerializer &stream);
00152 void dumpXMLNodes(XMLSerializer &stream);
00153
00154
00155 virtual void dumpDOT(std::ostream &stream, int tabLevel, bool flat = false);
00156 void dumpDOTConnections(std::ostream &stream, int tabLevel,
00157 bool flat = false);
00158 void dumpDOTNodes(std::ostream &stream, int tabLevel);
00159 void dumpDOTSubNets(std::ostream &stream, int tabLevel, bool flat = false);
00160 void dumpDOTSubNet(std::ostream &stream, int tabLevel, bool flat = false);
00161
00162
00163 void doFinalizeNodes();
00164 void doFinalizeLinks();
00165 void doFinalize();
00166
00172 ymlentity_t getType() {return ymlNetwork;}
00173
00174 private:
00175 YMLPortSide *getPortSide(const char *nodeName, const char *portName);
00176 };
00177
00178 #endif