ymlnetwork.h

Go to the documentation of this file.
00001 /*******************************************************************\
00002 
00003                    SESAME project software license
00004 
00005               Copyright (C) 2002 University of Amsterdam
00006 
00007     This program is free software; you can redistribute it and/or
00008      modify it under the terms of the GNU General Public License
00009     as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015              GNU General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License
00018      along with this program; if not, write to the Free Software
00019       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00020                            02111-1307, USA.
00021 
00022       For information regarding the SESAME software project see
00023               http://sesamesim.sourceforge.net or email
00024                     jcofflan@users.sourceforge.net
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 // YMLNode
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   // Link operations
00087   void addLink(YMLLink *link) {links.put(link);}
00091   int getNumLinks() {return links.getSize();}
00099   YMLLink *getLink(int i) {return links[i];}
00100 
00101   // Node operations
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   // Connection operations
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   // XML operations
00150   virtual void dumpXML(XMLSerializer &stream);
00151   void dumpXMLLinks(XMLSerializer &stream);
00152   void dumpXMLNodes(XMLSerializer &stream);
00153 
00154   // DOT operations
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   // Finalize operations
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

Generated on Wed Apr 5 20:57:46 2006 for Sesame by  doxygen 1.4.6