Debian Codegraph @

Doc/features.tex

raw
1 \documentclass[12pt]{article}
2
3 \begin{document}
4 \begin{center}
5 \bf \LARGE Some features of {\sc Lorene 2}
6 \end{center}
7
8 \vspace{1cm}
9
10 \section{Encapsulation}
11
12 (Most of) all data are encapsulated, i.e. one cannot have access to
13 member data of an object (it is declared {\tt protected} or
14 {\tt private} in the class definition).
15 The access to data is performed by member functions {\tt get\_xxx()}
16 for read-only of data or {\tt set\_xxx()} for modifying the data.
17 Some read-only is also performed via the {\tt operator()}, e.g.
18 {\tt a(2)} to read the element no. 2 of the {\tt Tbl a}.
19
20 The advantage of encapsulation is a safe handling of the
21 dependencies among the data. Indeed invoquing the function
22 {\tt set\_xxx()} will not only modify the data {\tt xxx}, but will
23 modify accordingly all the data or objects which depend on {\tt xxx}.
24
25
26 \section{Const-correctness}
27
28 {\sc Lorene} is const-correct, i.e. the constancy
29 of objects is systematically specified, by mean of the C++ qualifier
30 {\tt const}:
31 \begin{itemize}
32 \item {\tt A::f(const B\& b)} : the member function {\tt f} of class
33 {\tt A} does not modify its argument {\tt b}.
34 \item {\tt A::f() const} : the member function {\tt f} of class {\tt A}
35 does not modify the object for which it is invoqued.
36 \item {\tt const B\& A::get\_xxx() const} : the member function
37 {\tt get\_xxx} of class {\tt A} returns a reference on a constant object
38 of class {\tt B} (representing the data {\tt xxx}); this
39 function thus cannot be used to modify the object {\tt A}, hence the
40 second qualifier {\tt const}.
41 \end{itemize}
42
43 \section{Construction of objects}
44
45 There are at least 3 ways to create a {\sc Lorene} object, corresponding
46 to 3 types of C++ constructors:
47 \begin{itemize}
48 \item Constructor from scratch (in {\sc Lorene} terminology,
49 {\em standard constructor}), i.e. using the basic informations
50 to set up an object; for example: {\tt Tbl a(5) ;} (construction of a
51 {\tt Tbl} of dimension 5).
52 \item Constructor from copy of a pre-existing object of same class;
53 for example: {\tt Tbl b = a ; } (construction of a {\tt Tbl b} which is
54 identical to {\tt a}).
55 \item Constructor from a file; for example: {\tt Tbl c(file) ;}
56 (where {\tt file} is pointer (of C type {\tt FILE*}) towards a
57 file where a {\tt Tbl} has been written before, via the function
58 {\tt Tbl::sauve}).
59 \end{itemize}
60 In addition, there exists some constructors {by conversion} of
61 a object from a different class, for example
62 {\tt Mtbl::Mtbl(const Coord\& )}, but these are pretty rare and
63 most of single argument constructors are protected against
64 automatic type conversion from the compiler by the C++
65 qualifier {\tt explicit}.
66
67
68 \section{Object states}
69
70 Most of {\sc Lorene} objects can exist under three states:
71
72 \begin{itemize}
73 \item {\bf undefined state} ({\tt ETATNONDEF}) :
74 this states generally results from the creation of the object from
75 scratch (via the so-called {\em standard constructor}).
76 \item {\bf zero state} ({\tt ETATZERO}) : the object has the value zero.
77 \item {\bf ordinary state} ({\tt ETATQCQ}) : the object has a well
78 defined value, different from zero.
79 \end{itemize}
80
81 In the undefined and zero states, no memory allocation is performed for
82 the object data. The switch to the ordinary state and the
83 memory allocation is performed by the method {\tt set\_etat\_qcq()}.
84 This method is automatically invoqued when necessary
85 in all global manipulations, such as the the assignment to another
86 object. However, for efficiency purpose, the function {\tt set\_etat\_qcq()}
87 is not called by functions of the type {\tt set\_xxx()}.
88 It should be thus call by hand prior to {\tt set\_xxx()}. For example:
89 {\tt
90 \begin{verbatim}
91 Tbl a(5) ; // creation of an array of size 5 :
92 // state = undefined
93 a.set_etat_qcq() ; // switches the state to ordinary and
94 // performs the memory allocation
95 // for the array elements
96 a.set(0) = 1 ; // OK
97 \end{verbatim}
98 }
99
100
101 \section{Input/output}
102
103 Most of all {\sc Lorene} objects can be displayed on the
104 screen, or in a formatted file, by means of the {\tt operator<<}.
105 For example: {\tt cout << a << endl ;} where {\tt a} is some
106 {\sc Lorene} object.
107
108
109 Most of all {\sc Lorene} objects can by written in (binary) files
110 by means of the member function {\tt sauve(FILE* )}.
111 The reverse operation is possible, i.e. for most all classes
112 there exists a constructor from a file.
113
114 The graphical display is ensured by means of functions
115 based on the PGPLOT library (2-D drawings) or
116 formatting data for 3-D visualization via Iris Explorer (NAG).
117 These functions are not member functions of any class
118 to ensure full portability of the non-graphical part of
119 {\sc Lorene}.
120
121
122 \end{document}