File: CLASS_LAYOUT

package info (click to toggle)
wfmath 1.0.2%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,496 kB
  • sloc: sh: 10,965; cpp: 9,069; makefile: 111
file content (63 lines) | stat: -rw-r--r-- 2,243 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
I'm trying to come up with a general class layout that all
(significant) classes will obey. Friend functions are included
under the corresponding section. Currently it's this:

1) Constructors and destructor

The default constructor will not initialize the object. If the default
constructor is used, the object must first be initialized with operator>>(),
FromString(), FromAtlas(), operator=(), or one of the initializer functions
given later in the class. There is no constructor from a string value, as such
construction can fail. The destructor is not virtual, nor is any other
function in the class, as this is a low-level library designed primarily
for speed.

2) operator<<() and operator>>(), toAtlas() and fromAtlas()

friend std::ostream& operator<<(std::ostream& os, const Foo& f);
friend std::istream& operator>>(std::istream& is, Foo& f);

operator>>() indicates a parse failure by setting the fail() flag on the stream.
Failure also indicates that the object is in an invalid state. The definitions
of these functions are placed in the file stream.h, so the class only needs to
include <iosfwd>. The toAtlas() and fromAtlas() functions need a forward
declaration of Atlas::Message::Object, which is done in const.h. They
are only defined for certain classes (see Atlas protocol specs (where?)
for details). The implementations of these functions belong in atlasconv.h,
and must be done inline or as templates, so that the library can be built and
used without libAtlas.

3) operator=()

4) isEqualTo() method

this function is of the form

bool C::isEqualTo(const C& c, CoordType tolerance = WFMATH_EPSILON);

5) operator==(), operator!=()

these call isEqualTo()

6) Class initializers

e.g. zero() for Vector<>, origin() for Point<>, etc.

7) operator<()

sort only, if comparison makes sense stick others here too

8) math operators

9) other operators (e.g. operator[]())

10) other functions

11) dimension-specific constructors/operators/functions

e.g. Vector(CoordType& x, CoordType& y, CoordType& z) for Vector<3>

Every class is also defines two non-member functions:
ToString() and FromString(). These functions are
automatically generated in stream.h using templates
and the operator<<() and operator>>() functions.