Class documentation of Concepts

Loading...
Searching...
No Matches
connector.hh
Go to the documentation of this file.
1
6#ifndef Connector_hh
7#define Connector_hh
8
9#include "basics/typedefs.hh"
11#include <iostream>
12
13namespace concepts {
14
15 // ************************************************************* Attribute **
16
22 class Attribute {
23 friend std::ostream& operator<<(std::ostream& os, const Attribute& a);
24 public:
29 inline Attribute(uint attrib = 0) : attrib_(attrib) {}
30
32 int operator==(const Attribute& a) const { return attrib_ == a.attrib_; }
33
35 inline operator uint() const { return attrib_; }
36
38 inline uint attrib() const { return attrib_; }
39
40 // change attribute
41 inline void set(uint attrib){ attrib_ = attrib;}
42 private:
44 uint attrib_;
45 };
46
47 // ******************************************************************* Key **
48
53 class Key {
54 friend std::ostream& operator<<(std::ostream& os, const Key& k);
55 public:
57 inline Key(uint key = 0) : key_(key) {}
58
60 inline int operator==(const Key& key) const { return key_ == key.key_; }
61
63 inline operator uint() const { return key_; }
64
66 inline uint key() const { return key_; }
67
69 inline static uint noKey() { return (uint)-1; }
70 private:
71 uint key_;
72 };
73
74 // ************************************************************* Connector **
75
85 class Connector : public OutputOperator {
86 public:
90
98 virtual Connector* child(uint i, bool mode = 0) = 0;
99 virtual const Connector* child(uint i) const = 0;
100
102 int operator==(const Connector& cntr) const { return key_ == cntr.key_; }
103
105 const Key& key() const { return key_; }
106
108 const Attribute& attrib() const { return attrib_; }
109
110 //change attribute
111 inline void setAttrib(uint attrb){ attrib_.set(attrb); }
112
124 int related(const Connector& conn) const;
125 protected:
126 virtual std::ostream& info(std::ostream& os) const;
127
130
133 };
134
139
140 // ************************************************************ Connector0 **
141
147 class Connector0 : public Connector {
148 public:
154
155 virtual Connector0* child(uint i, bool mode = 0) = 0;
156 virtual const Connector0* child(uint i) const = 0;
157 protected:
162 inline Connector0(const Attribute attrib, const Key& key)
163 : Connector(key, attrib) {};
164
168 static uint cnt_;
169 };
170
171 // ************************************************************ Connector1 **
172
182 class Connector1 : public Connector {
183 public:
189
196 virtual Connector0* vertex(uint i) const = 0;
197
198 virtual Connector1* child(uint i, bool mode = 0) = 0;
199 virtual const Connector1* child(uint i) const = 0;
200 protected:
205 inline Connector1(const Attribute attrib, const Key& key)
206 : Connector(key, attrib) {};
207
211 static uint cnt_;
212 };
213
214 // ************************************************************ Connector2 **
215
226 class Connector2 : public Connector {
227 public:
233
234 virtual Connector2* child(uint i, bool mode = 0) = 0;
235 virtual const Connector2* child(uint i) const = 0;
236
243 virtual Connector1* edge(uint i) const = 0;
244
251 virtual Connector0* vertex(uint i) const = 0;
252 protected:
257 inline Connector2(const Attribute attrib, const Key& key)
258 : Connector(key, attrib) {};
259
263 static uint cnt_;
264 };
265
266 // ************************************************************ Connector3 **
267
277 class Connector3 : public Connector {
278 public:
284
285 virtual Connector3* child(uint i, bool mode = 0) = 0;
286 virtual const Connector3* child(uint i) const = 0;
287
294 virtual Connector1* edge(uint i) const = 0;
295
302 virtual Connector2* face(uint i) const = 0;
303
310 virtual Connector0* vertex(uint i) const = 0;
311 protected:
316 inline Connector3(const Attribute attrib, const Key& key)
317 : Connector(key, attrib) {};
318
322 static uint cnt_;
323 };
324
325} // namespace concepts
326
327
328namespace test {
329
330
331 // ********************************************************* ResetConnectorN **
332
344 public:
345 static void reset() { cnt_ = 0; }
346 static uint cnt() { return cnt_; }
347 };
349 public:
350 static void reset() { cnt_ = 0; }
351 static uint cnt() { return cnt_; }
352 };
354 public:
355 static void reset() { cnt_ = 0; }
356 static uint cnt() { return cnt_; }
357 };
359 public:
360 static void reset() { cnt_ = 0; }
361 static uint cnt() { return cnt_; }
362 };
363}
364
365#endif // Connector_hh
int operator==(const Attribute &a) const
Comparison operator.
Definition connector.hh:32
uint attrib() const
Returns the attribute.
Definition connector.hh:38
Attribute(uint attrib=0)
Definition connector.hh:29
virtual Connector0 * child(uint i, bool mode=0)=0
Connector0(Attribute attrib)
Definition connector.hh:153
Connector0(const Attribute attrib, const Key &key)
Definition connector.hh:162
Connector1(const Attribute attrib, const Key &key)
Definition connector.hh:205
virtual Connector1 * child(uint i, bool mode=0)=0
virtual Connector0 * vertex(uint i) const =0
Connector1(Attribute attrib)
Definition connector.hh:188
virtual Connector1 * edge(uint i) const =0
Connector2(Attribute attrib)
Definition connector.hh:232
virtual Connector0 * vertex(uint i) const =0
virtual Connector2 * child(uint i, bool mode=0)=0
Connector2(const Attribute attrib, const Key &key)
Definition connector.hh:257
virtual Connector1 * edge(uint i) const =0
virtual Connector0 * vertex(uint i) const =0
virtual Connector3 * child(uint i, bool mode=0)=0
Connector3(const Attribute attrib, const Key &key)
Definition connector.hh:316
virtual Connector2 * face(uint i) const =0
Connector3(Attribute attrib)
Definition connector.hh:283
int operator==(const Connector &cntr) const
Comparison operator.
Definition connector.hh:102
Key key_
Unique key of the connector.
Definition connector.hh:129
int related(const Connector &conn) const
Attribute attrib_
Attribute.
Definition connector.hh:132
const Key & key() const
Returns the key of the connector.
Definition connector.hh:105
Connector(const uint key, const Attribute attrib)
Constructor.
Definition connector.hh:88
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const Attribute & attrib() const
Returns the attribute of the connector.
Definition connector.hh:108
virtual Connector * child(uint i, bool mode=0)=0
static uint noKey()
Returns a key which never occurs.
Definition connector.hh:69
Key(uint key=0)
Default constructor.
Definition connector.hh:57
uint key() const
Returns the key.
Definition connector.hh:66
int operator==(const Key &key) const
Comparison operator.
Definition connector.hh:60
bool operator<(const Cell &cell_x, const Cell &cell_y)
<-operator could be useful for sorting, e.g. in std::set.
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320