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 YMLPORT_H 00038 #define YMLPORT_H 00039 00040 #include "ymlentity.h" 00041 #include "ymlportside.h" 00042 00043 #include <BasicUtils/BasicArray.h> 00044 00045 #include <string> 00046 00047 class YMLNode; 00048 class YMLEntityFactory; 00049 class YMLPortSide; 00050 class YMLConnection; 00051 00052 class YMLPort: public YMLEntity { 00053 public: 00055 static const int aName = 0; 00057 static const int aDir = 1; 00058 typedef enum {dUnknown = -1, dIn, dOut} dir_t; 00059 private: 00060 00062 YMLNode *parent; 00063 00065 dir_t dir; 00066 00068 YMLPortSide inSide; 00069 00071 YMLPortSide outSide; 00072 00073 BasicArray<YMLConnection *> connections; 00074 00075 int id; 00076 00077 public: 00078 YMLPort(); 00079 00085 const char *getName() {return getArg(aName);} 00086 void dumpFullName(std::ostream &stream); 00087 std::string getFullName(); 00088 00094 dir_t getDir() {if (dir == dUnknown) resolveDir(); return dir;} 00095 00101 YMLNode *getParent() {return parent;} 00102 00108 void setParent(YMLNode *parent) {this->parent = parent;} 00109 00115 YMLPortSide *getInSide() {return &inSide;} 00116 00122 YMLPortSide *getOutSide() {return &outSide;} 00123 00124 00125 YMLPort *getRemotePort(); 00126 void getRemotePorts(BasicArray<YMLPort *> &ports); 00127 00128 void addConnection(YMLConnection *con) {connections.put(con);} 00129 YMLConnection *getConnection(); 00130 const BasicArray<YMLConnection *> &getConnections() {return connections;} 00131 00132 void setID(int id); 00133 int getID(); 00134 00135 virtual void dumpXML(XMLSerializer &stream); 00136 00140 virtual void doFinalize() {finalize();} 00141 00147 ymlentity_t getType() {return ymlPort;} 00148 00149 protected: 00150 YMLPort *getRemotePort(YMLConnection *connection); 00151 void resolveDir(); 00152 }; 00153 #endif