00001 /* Sets for Connectors. 00002 */ 00003 00004 #ifndef ConnectorSet_hh 00005 #define ConnectorSet_hh 00006 00007 #include "connector.hh" 00008 #include "toolbox/set.hh" 00009 00010 namespace concepts { 00011 00012 // ******************************************************** Set<Attribute> ** 00013 00014 template<> 00015 class Set<Attribute> : public BaseSet<Attribute> { 00016 public: 00018 Set() : BaseSet<Attribute>() {} 00020 Set(const Set<uint>& set) : BaseSet<Attribute>() { 00021 for(Set<uint>::const_iterator i = set.begin(); i != set.end();) 00022 this->insert(*i++); 00023 } 00029 Set(const std::string& str) : BaseSet<Attribute>() { 00030 *this = Set<uint>(str); 00031 } 00033 Set(const Attribute& attr) : BaseSet<Attribute>() { insert(attr); } 00035 template<class F> 00036 Set(const F& set) : BaseSet<Attribute>(set) {} 00037 virtual ~Set() {} 00038 }; 00039 00040 // ******************************************************* Set<const Key*> ** 00041 00042 template<> 00043 class Set<const Key*> : public BaseSet<const Key*> { 00044 public: 00045 Set() : BaseSet<const Key*>() {} 00046 template<class F> 00047 Set(const F& set) : BaseSet<const Key*>(set) {} 00048 virtual ~Set() {} 00049 00050 Set<uint> key() const; 00051 }; 00052 00053 // ************************************************* Set<const Connector*> ** 00054 00055 template<> 00056 class Set<const Connector*> : public BaseSet<const Connector*> { 00057 public: 00058 Set() : BaseSet<const Connector*>() {} 00059 template<class F> 00060 Set(const F& set) : BaseSet<const Connector*>(set) {} 00061 virtual ~Set() {} 00062 00063 Set<const Key*> key() const; 00064 }; 00065 00066 // ******************************************************* Set<Connector*> ** 00067 00068 template<> 00069 class Set<Connector*> : public BaseSet<Connector*> { 00070 public: 00071 Set() : BaseSet<Connector*>() {} 00072 template<class F> 00073 Set(const F& set) : BaseSet<Connector*>(set) {} 00074 virtual ~Set() {} 00075 00076 Set<const Key*> key() const; 00077 }; 00078 00079 // ************************************************ Set<const Connector0*> ** 00080 00081 template<> 00082 class Set<const Connector0*> : public Set<const Connector*>, 00083 public BaseSet<const Connector0*> { 00084 public: 00085 Set() : BaseSet<const Connector0*>() {} 00086 template<class F> 00087 Set(const F& set) : BaseSet<const Connector0*>(set) {} 00088 // virtual ~Set() {} 00089 00090 // Set<const Key*> key() const; 00091 }; 00092 00093 // ****************************************************** Set<Connector0*> ** 00094 00095 template<> 00096 class Set<Connector0*> : public Set<Connector*>, 00097 public BaseSet<Connector0*> { 00098 public: 00099 Set() : BaseSet<Connector0*>() {} 00100 template<class F> 00101 Set(const F& set) : BaseSet<Connector0*>(set) {} 00102 // virtual ~Set() {} 00103 00104 // Set<const Key*> key() const; 00105 }; 00106 00107 // ************************************************ Set<const Connector1*> ** 00108 00109 template<> 00110 class Set<const Connector1*> : 00111 public BaseSet<const Connector1*> { 00112 public: 00113 Set() : BaseSet<const Connector1*>() {} 00114 template<class F> 00115 Set(const F& set) : BaseSet<const Connector1*>(set) {} 00116 virtual ~Set() {} 00117 00118 Set<const Key*> key() const; 00119 Set<Connector0*> vertex(uint i) const; 00120 Set<const Connector1*> child(uint i) const; 00121 }; 00122 00123 // ****************************************************** Set<Connector1*> ** 00124 00125 template<> 00126 class Set<Connector1*> : public BaseSet<Connector1*> { 00127 public: 00128 Set() : BaseSet<Connector1*>() {} 00129 template<class F> 00130 Set(const F& set) : BaseSet<Connector1*>(set) {} 00131 virtual ~Set() {} 00132 00133 Set<const Key*> key() const; 00134 Set<Connector0*> vertex(uint i) const; 00135 Set<const Connector1*> child(uint i) const; 00136 }; 00137 00138 // ************************************************ Set<const Connector2*> ** 00139 00140 template<> 00141 class Set<const Connector2*> : 00142 public BaseSet<const Connector2*> { 00143 public: 00144 Set() : BaseSet<const Connector2*>() {} 00145 template<class F> 00146 Set(const F& set) : BaseSet<const Connector2*>(set) {} 00147 virtual ~Set() {} 00148 00149 Set<const Key*> key() const; 00150 Set<Connector0*> vertex(uint i) const; 00151 Set<Connector1*> edge(uint i) const; 00152 Set<const Connector2*> child(uint i) const; 00153 }; 00154 00155 // ****************************************************** Set<Connector2*> ** 00156 00157 template<> 00158 class Set<Connector2*> : public BaseSet<Connector2*> { 00159 public: 00160 Set() : BaseSet<Connector2*>() {} 00161 template<class F> 00162 Set(const F& set) : BaseSet<Connector2*>(set) {} 00163 virtual ~Set() {} 00164 00165 Set<const Key*> key() const; 00166 Set<Connector0*> vertex(uint i) const; 00167 Set<Connector1*> edge(uint i) const; 00168 Set<const Connector2*> child(uint i) const; 00169 }; 00170 00171 // ********************************************************* allConnectors ** 00172 00179 template<class F, class G> 00180 void allConnectors(const F& cntr, G* (F::*fun)(uint) const, Set<G*>& set) { 00181 G* cntri; // connectors inside cntr 00182 uint i = 0; 00183 while ((cntri = (cntr.*fun)(i++)) != 0) set.insert(cntri); 00184 } 00185 00186 } // namespace concepts 00187 00188 #endif // ConnectorSet_hh 00189