connector.hh

Go to the documentation of this file.
1 
6 #ifndef Connector_hh
7 #define Connector_hh
8 
9 #include "basics/typedefs.hh"
10 #include "basics/outputOperator.hh"
11 #include <iostream>
12 
13 namespace 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:
88  Connector(const uint key, const Attribute attrib) :
89  key_(key), attrib_(attrib) {}
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 
138  bool operator<(const Connector& cntr_x, const Connector& cntr_y);
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 
328 namespace 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
static uint cnt_
Counter for the connectors.
Definition: connector.hh:206
Key key_
Unique key of the connector.
Definition: connector.hh:129
Connector1(Attribute attrib)
Constructor.
Definition: connector.hh:188
A 3D element of the topology.
Definition: connector.hh:277
virtual Connector0 * vertex(uint i) const =0
Returns a 0D component: vertex A 2D element consists of 1D and 0D elements, the vertices can be queri...
virtual Connector1 * edge(uint i) const =0
Returns a 1D component: edge.
virtual const Connector1 * child(uint i) const =0
Connector0(Attribute attrib)
Constructor.
Definition: connector.hh:153
static void reset()
Definition: connector.hh:360
virtual const Connector2 * child(uint i) const =0
const Attribute & attrib() const
Returns the attribute of the connector.
Definition: connector.hh:108
uint attrib() const
Returns the attribute.
Definition: connector.hh:38
static uint cnt_
Counter for the connectors.
Definition: connector.hh:258
static uint cnt()
Definition: connector.hh:351
static uint cnt()
Definition: connector.hh:346
Attribute attrib_
Attribute.
Definition: connector.hh:132
virtual Connector1 * child(uint i, bool mode=0)=0
Returns the ith child of the connector.
int operator==(const Attribute &a) const
Comparison operator.
Definition: connector.hh:32
virtual Connector0 * vertex(uint i) const =0
Returns a 0D component: vertex A 3D element consists of 2D, 1D and 0D elements, the vertices can be q...
friend std::ostream & operator<<(std::ostream &os, const Attribute &a)
uint attrib_
Attribute.
Definition: connector.hh:44
Unit tests.
Definition: testcase.hh:66
Connector(const uint key, const Attribute attrib)
Constructor.
Definition: connector.hh:88
void setAttrib(uint attrb)
Definition: connector.hh:111
Attribute(uint attrib=0)
Constructor.
Definition: connector.hh:29
static uint cnt()
Definition: connector.hh:361
virtual Connector * child(uint i, bool mode=0)=0
Returns the ith child of the connector.
virtual Connector2 * child(uint i, bool mode=0)=0
Returns the ith child of the connector.
static uint cnt()
Definition: connector.hh:356
const Key & key() const
Returns the key of the connector.
Definition: connector.hh:105
Connector0(const Attribute attrib, const Key &key)
Constructor.
Definition: connector.hh:162
Classes which allow for testing purpose (!) to reset internal counter of each connector type.
Definition: connector.hh:343
void set(uint attrib)
Definition: connector.hh:41
A 2D element of the topology.
Definition: connector.hh:226
int operator==(const Connector &cntr) const
Comparison operator.
Definition: connector.hh:102
static void reset()
Definition: connector.hh:345
virtual Connector0 * child(uint i, bool mode=0)=0
Returns the ith child of the connector.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
int related(const Connector &conn) const
Checks if this connector is related to conn.
virtual const Connector * child(uint i) const =0
virtual const Connector0 * child(uint i) const =0
bool operator<(const Cell &cell_x, const Cell &cell_y)
<-operator could be useful for sorting, e.g. in std::set.
static void reset()
Definition: connector.hh:355
int operator==(const Key &key) const
Comparison operator.
Definition: connector.hh:60
static uint cnt_
Counter for the connectors.
Definition: connector.hh:317
Connector2(const Attribute attrib, const Key &key)
Constructor.
Definition: connector.hh:257
static void reset()
Definition: connector.hh:350
virtual Connector2 * face(uint i) const =0
Returns a 2D component: face.
A 1D element of the topology.
Definition: connector.hh:182
virtual Connector1 * edge(uint i) const =0
Returns a 1D component: edge.
friend std::ostream & operator<<(std::ostream &os, const Key &k)
static uint cnt_
Counter for the connectors.
Definition: connector.hh:163
virtual Connector3 * child(uint i, bool mode=0)=0
Returns the ith child of the connector.
Connector3(const Attribute attrib, const Key &key)
Constructor.
Definition: connector.hh:316
Connector3(Attribute attrib)
Constructor.
Definition: connector.hh:283
Key class.
Definition: connector.hh:53
Connector2(Attribute attrib)
Constructor.
Definition: connector.hh:232
virtual const Connector3 * child(uint i) const =0
virtual Connector0 * vertex(uint i) const =0
Returns a 0D component: vertex A 1D element consists of 0D elements, the vertices can be queried here...
uint key() const
Returns the key.
Definition: connector.hh:66
Connector1(const Attribute attrib, const Key &key)
Constructor.
Definition: connector.hh:205
Class providing an output operator.
Attributes for elements of the topology.
Definition: connector.hh:22
An abstract class for elements of the topology.
Definition: connector.hh:85
static uint noKey()
Returns a key which never occurs.
Definition: connector.hh:69
Key(uint key=0)
Default constructor.
Definition: connector.hh:57
A 0D element of the topology.
Definition: connector.hh:147
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich