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 YMLNODE_H 00038 #define YMLNODE_H 00039 00040 #include <map> 00041 #include <BasicUtils/BasicArray.h> 00042 00043 #include "ymlentity.h" 00044 #include "ymlport.h" 00045 #include <string> 00046 00047 class YMLNetwork; 00048 class YMLConnection; 00049 class YMLEntityFactory; 00050 class TraceChannel; 00051 00052 #define NAME_DELIM '.' 00053 00054 #ifndef LTSTR 00055 #define LTSTR 00056 #include <string.h> 00057 struct ltstr { 00058 bool operator()(const char* s1, const char* s2) const { 00059 return strcmp(s1, s2) < 0; 00060 } 00061 }; 00062 #endif 00063 00064 // YMLNode 00065 class YMLNode: public YMLEntity { 00066 public: 00068 static const int aName = 0; 00070 static const int aClass = 1; 00071 00072 private: 00074 typedef std::map<const char *, YMLPort *, ltstr> portMap_t; 00075 portMap_t portMap; 00076 00077 BasicArray<YMLPort *> ports; 00078 BasicArray<YMLPort *> mappedPorts; 00079 00081 YMLNetwork *network; 00082 00083 TraceChannel *traceChannel; 00084 int channelID; 00085 00086 00087 public: 00088 YMLNode(); 00089 virtual ~YMLNode(); 00090 00091 void addPort(YMLPort *port); 00092 00100 YMLPort *findPort(const char *name); 00101 00107 int getNumPorts() {return ports.getSize();} 00108 00116 YMLPort *getPort(int id); 00117 00118 YMLPort *getPortByIdx(int idx) {return ports[idx];} 00119 00125 YMLNetwork *getNetwork() const {return network;} 00126 00132 void setNetwork(YMLNetwork *network) {this->network = network;} 00133 void dumpFullName(std::ostream &stream); 00134 std::string getFullName(); 00135 00139 const char *getName() {return getArg(aName);} 00140 00144 const char *getClass() {return getArg(aClass);} 00145 00150 virtual ymlentity_t getType() {return ymlNode;} 00151 00152 void setTraceChannel(TraceChannel *traceChannel); 00153 TraceChannel *getTraceChannel(); 00154 void setChannelID(int channelID) {this->channelID = channelID;} 00155 int getChannelID() const; 00156 00157 void dumpXMLPorts(XMLSerializer &stream); 00158 virtual void dumpXML(XMLSerializer &stream); 00159 virtual void dumpDOT(std::ostream &stream, int tabLevel); 00160 virtual void doFinalizePorts(); 00161 virtual void doFinalize(); 00165 virtual void init() {} 00166 }; 00167 00168 #endif