|
quantities/Ports.hGo to the documentation of this file.00001 //============================================================================ 00002 // Author : Alessandro Pinto <apinto@eecs.berkeley.edu> 00003 // University of California, Berkeley 00004 // 545 Cory Hall, Berkeley, CA 94720 00005 // Copyright : See COPYING file that comes with this distribution 00006 //============================================================================ 00007 00008 #ifndef PORTS_H_ 00009 #define PORTS_H_ 00010 00011 #include <iostream> 00012 #include <string> 00013 #include <map> 00014 #include "core/IdGraph.h" 00015 #include "Bandwidth.h" 00016 00017 namespace cosi { 00018 00019 class PortInterface { 00020 public: 00021 enum tDirection {IN,OUT,INOUT}; 00022 PortInterface(); 00023 ~PortInterface(); 00024 tDirection GetDirection() const; 00025 void SetDirection(tDirection pDir); 00026 std::string GetName() const; 00027 void SetName(std::string pName); 00028 bool operator==(const PortInterface &pP) const; 00029 bool operator!=(const PortInterface &pP) const; 00030 friend std::ostream& operator<<(std::ostream &pOs, const PortInterface &pP); 00031 private: 00032 std::string mName; 00033 tDirection mDir; 00034 }; 00035 00036 class Ports : public Quantity { 00037 std::map<std::string,PortInterface> mPorts; 00038 std::map<std::string,Edge> mBound; 00039 public: 00040 Ports(); 00041 ~Ports(); 00042 static std::string GetQuantityType(); 00043 static std::string GetQuantityName(); 00044 00045 Ports Get(); 00046 void Set(Ports pP); 00047 std::map<std::string,PortInterface> GetValue(); 00048 00049 void AddPort(std::string pName, std::string pType, 00050 PortInterface::tDirection pDir); 00051 void AddPort(std::string pName, PortInterface pIf); 00052 bool HasPortType(std::string pType); 00053 bool HasPort(std::string pName); 00054 00055 bool IsBound(std::string pName); 00056 Edge BoundTo(std::string pName); 00057 void BoundTo(std::string pName, Edge pE); 00058 string IsBoundTo(Edge pE , PortInterface::tDirection pDir = PortInterface::OUT) ; 00059 00060 typedef std::map<string,PortInterface>::iterator iterator; 00061 00062 iterator Begin(); 00063 iterator End(); 00064 string Name(iterator It); 00065 PortInterface If(iterator It); 00066 00067 string GetInputPortNotBound(); 00068 string GetOutputPortNotBound(); 00069 string GetInputOutputPortNotBound(); 00070 00071 std::vector<std::string> GetNotBoundIn(); 00072 std::vector<std::string> GetNotBoundOut(); 00073 std::vector<std::string> GetNotBoundInOut(); 00074 00075 bool operator==(Ports pP); 00076 00077 Ports operator+(Ports pT); 00078 Ports operator-(Ports pT); 00079 00080 friend std::ostream& operator<<(std::ostream &pOs, const Ports &pP); 00081 PortInterface operator[](std::string pName); 00082 00083 static std::string sQuantityType; 00084 static std::string sQuantityName; 00085 }; 00086 00087 class PortRates : public Quantity { 00088 std::map<std::string,Bandwidth> mPortRates; 00089 public: 00090 PortRates(); 00091 virtual ~PortRates(); 00092 00093 PortRates Get(); 00094 void Set(PortRates pP); 00095 00096 std::map<std::string,Bandwidth> GetValue(); 00097 00098 bool HasPort(std::string pName); 00099 00100 void AddRate(std::string pName, Bandwidth pB); 00101 void AddRate(std::string pName, double pValue); 00102 00103 Bandwidth GetRate(std::string pName); 00104 00105 bool operator==(PortRates pP); 00106 00107 PortRates operator+(PortRates pP); 00108 00109 void operator<<(PortRates pP); 00110 00111 static std::string sQuantityType; 00112 static std::string sQuantityName; 00113 }; 00114 00115 class PortCapacities : public PortRates { 00116 public: 00117 PortCapacities(); 00118 00119 ~PortCapacities(); 00120 00121 PortCapacities Get(); 00122 00123 PortRates operator+(PortRates pP); 00124 00125 static std::string sQuantityType; 00126 static std::string sQuantityName; 00127 }; 00128 00129 } 00130 00131 #endif /*PORTS_H_*/ Generated on Sun Sep 7 18:37:43 2008 for COSI by 1.5.4 |