Debian Codegraph @

debian/external_deps/fetk/maloc/doc/doxygen/prog.h

raw
1 /**
2 * <center>
3 * @mainpage MALOC Programmer's Guide
4 * FETK was written by Michael Host.<br>
5 * Additional contributing authors are listed in the code documentation.
6 * </center>
7 *
8 *
9 * <hr width="100%">
10 * @section toc Table of Contents
11 * <ul>
12 * <li> @ref intro
13 * <li> @ref style
14 * <li> @ref api
15 * <ul>
16 * <li> <a href="modules.html">Modules</a>
17 * <li> <a href="annotated.html">Class list</a>
18 * <li> <a href="functions.html">Class members</a>
19 * <li> <a href="globals.html">Class methods</a>
20 * </ul>
21 * <li> @ref license
22 * </ul>
23 *
24 * <p>
25 * <i>
26 * NOTE:
27 * </i>
28 * This documentation provides information about the programming interface
29 * provided by the MALOC software and a general guide to linking to the MALOC
30 * libraries. Information about installation, configuration, and general usage
31 * can be found in the <a href="../../index.html">User's Guide</a>.
32 * <hr>
33 *
34 * \section intro Introduction
35 *
36 * <p>
37 * MALOC
38 * (Minimal Abstraction Layer for Object-oriented C) was written by
39 * <a href="http://www.scicomp.ucsd.edu/~mholst/">Michael Holst</a>
40 * at Caltech and UC San Diego, primarily as a portability layer for
41 * <a href="http://www.fetk.org">FETK</a>
42 * (the Finite Element TookKit).
43 *
44 * \section formalism Clean OO C Formalism
45 *
46 * <p>
47 * MALOC was written in
48 * <a href="../../cooc.html">Clean OO C</a>,
49 * which is a self-imposed disciplined coding formalism for
50 * producing object-oriented ANSI/Standard C which can be
51 * compiled with either a C or C++ compiler.
52 * We will briefly describe the formalism here
53 * (borrowing from N. Baker's nice description in the APBS documentation).
54 *
55 * <p>
56 * Clean OO C formalism requires that all public data is
57 * enclosed in structures which resemble C++ classes. These structures and
58 * member functions are then declared in a public header file which provides a
59 * concise description of the interface (or API) for the class.
60 * Private functions and
61 * data are included in private header files (or simply the source code files
62 * themselves) which are not visible generally visible (data encapsulation).
63 * When using the library, the
64 * user only sees the public header file and the compiled library and is
65 * therefore (hopefully) oblivious to the private members and functions. Each
66 * class is also equipped with a constructor and destructor function which is
67 * responsible for allocating and freeing any memory required by the
68 * instatiated objects.
69 *
70 * <p>
71 * Public data members are enclosed in C structures which
72 * are visible to the library user. Public member functions are generated by
73 * mangling the class and function names and passing a pointer to the
74 * object on which the member function is supposed to act. For example, a
75 * public member function with the C++ declaration
76 * <pre>
77 * public double Foo::bar(int i, double d)
78 * </pre>
79 * would be declared as
80 * <pre>
81 * VEXTERNC double Foo_bar(Foo *thee, int i, double d)
82 * </pre>
83 * where <code>VEXTERNC</code> is a compiler-dependent macro, the underscore
84 * <code>_</code> replaces the C++ double-colon <code>::</code>, and
85 * <code>thee</code> replaces the <code>this</code> variable implicit in all
86 * C++ classes. Since they do not appear in public header files, private
87 * functions could be declared in any format pleasing to the user, however, the
88 * above declaration convention should generally be used for both public and
89 * private functions. Within the source code, the public and private function
90 * declarations/definitions are prefaced by the macros <code>VPUBLIC</code> and
91 * <code>VPRIVATE</code>, respectively. These are macros which reduce global
92 * name pollution, similar to encapsulating private data withing C++ classes.
93 *
94 * <p>
95 * The only C++ functions not explicitly covered by the above declaration
96 * scheme are the constructors (used to allocate and initialize class data
97 * members) and destructors (used to free allocated memory). These are
98 * declared in the following fashion: a constructor with the C++ declaration
99 * <pre>
100 * public void Foo::Foo(int i, double d)
101 * </pre>
102 * would be declared as
103 * <pre>
104 * VEXTERNC Foo* Foo_ctor(int i, double d)
105 * </pre>
106 * which returns a pointer to the newly constructed <code>Foo</code> object.
107 * Likewise, a destructor declared as
108 * <pre>
109 * public void Foo::~Foo()
110 * </pre>
111 * in C++ would be
112 * <pre>
113 * VEXTERNC void Foo_dtor(Foo **thee)
114 * </pre>
115 * in Clean OO C.
116 * <p>
117 * Finally, inline functions in C++ are simply treated as macros in Clean OO C
118 * and declared/defined using "#define" statements in the public
119 * header file.
120 * See any of the MALOC header files for more examples on the Clean OO C
121 * formalism.
122 *
123 * \section style Coding Style
124 *
125 * <p>
126 * The best (and most entertaining) description of a C coding style that is
127 * very close to what I use in MALOC is that described by Linus Torvalds in his
128 * "CodingStyle" file in the Linux kernel sources (usually found in the file
129 * "/usr/src/linux/Documentation/CodingStyle" on any Linux box). He describes
130 * a coding style that is modular, completely documented (but in a spartan way),
131 * and very practical.
132 *
133 * <p>
134 * Below are some additional notes on the coding style
135 * I use in MALOC beyond what Torvalds describes.
136 * These additional guidelines
137 * are mostly concerned with being compatible with the Clean OO C dialect,
138 * giving an object-oriented look and feel to MALOC.
139 * <ul>
140 * <li>
141 * Tabs and spaces ==> Probably the most important rule: NO TABS!
142 * <p>
143 * Use ONLY SPACES, NO TABS, in source code.
144 * When indenting a code block, ALWAYS USE EXACT 4 SPACES,
145 * no more, no less. While this single anal rule seems
146 * excessive, in my experience it is the single most useful
147 * code formatting guideline one can impose, in terms of
148 * producing code written by many different developers that
149 * can be read and understood quickly by other developers
150 * using the same convention. If four spaces (rather than
151 * two or three) forces you to use more than 80 columns for
152 * nesting loops/etc, then your routine is too complex to
153 * be read by someone else anyway and it should be split
154 * into two or more routines.
155 * <p>
156 * <li>
157 * ALLCAPS ==> A "#define"d constant or a macro. Examples:
158 * <pre>
159 * "#define" VTRUE 1
160 * "#define" VFALSE 0
161 * "#define" VABS(x) ((x) >= 0 ? (x) : -(x))
162 * </pre>
163 * <li>
164 * UpperMixed ==> Class name, or class constructor or destructor.
165 * Examples:
166 * <p>
167 * <pre>
168 * C++: class Mesh { ... };
169 * Mesh(void) { ... }
170 * ~Mesh(void) { ... }
171 *
172 * Clean C: typedef struct Mesh { ... } Mesh;
173 * void Mesh_ctor(Mesh *thee) { ... }
174 * void Mesh_dtor(Mesh *thee) { ... }
175 * </pre>
176 * NOTE: The "this" pointer is implicitly used in C++. We
177 * simulate this coding style with the "thee" pointer
178 * in Clean C. By using a name different than "this",
179 * we continue to have a legal C++ program.
180 * <p>
181 * <li>
182 * lowerMixed ==> A class member function or generic function. Examples:
183 * <p>
184 * <pre>
185 * C++: Class Mesh {
186 * ...
187 * void print(void) { ... }
188 * ...
189 * }
190 * void Mesh::plot(void) { ... }
191 *
192 * Clean C: void Mesh_print(Mesh *thee) { ... }
193 * void Mesh_plot(Mesh *thee) { ... }
194 * </pre>
195 * <li>
196 * _private data ==> Pre-fixed with an underscore, such as: vint _dim.
197 * <p>
198 * I don't always adhere to this, but it helps make
199 * it clear when you are doing something unsafe with
200 * private data that you should have written an accessor
201 * member function to handle. (UPDATE: I no longer allow
202 * this practice in MALOC, because symbols beginning with
203 * an underscore often conflict with internal compiler
204 * symbols in GCC and other ANSI-C compilers.)
205 * <li>
206 * Datatypes ==> Use only standard or compatible datatypes.
207 * <p>
208 * Beyond the stuctures used to define classes, only standard
209 * datatypes are used as primitive types in MALOC, such as
210 * char, int, float, and double.
211 * <p>
212 * <li>
213 * Core structures ==> Refer to headers vel.h and ves.h in the GEM library
214 * for examples.
215 * <p>
216 * <li>
217 * Other comments ==> We basically adhere to the GNU coding conventions,
218 * except that Richard Stallman recommends (in his GNU
219 * Coding Standards paper) writing blocks as follows:
220 * <pre>
221 * if (cond)
222 * {
223 * }
224 * </pre>
225 * whereas I find the following usually more readable:
226 * <pre>
227 * if (cond) {
228 * }
229 * </pre>
230 * However, for complete routines I do follow
231 * Richard's approach:
232 * <pre>
233 * void func(void)
234 * {
235 * ...stuff...
236 * }
237 * </pre>
238 * If something is very simple then I break all rules:
239 * <pre>
240 * int myId(void) { return id; }
241 * </pre>
242 * </ul>
243 *
244 * @section api Application programming interface documentation
245 * <p>
246 * The API documentation for this code was generated by
247 * <a href="http://www.doxygen.org">doxygen</a>. You can either view the API
248 * documentation by using the links at the top of this page, or the slight
249 * re-worded/re-interpreted list below:
250 * <ul>
251 * <li> <a href="modules.html">Class overview</a>
252 * <li> <a href="annotated.html">Class declarations</a>
253 * <li> <a href="functions.html">Class members</a>
254 * <li> <a href="globals.html">Class methods</a>
255 * </ul>
256 *
257 * @section license License
258 *
259 @verbatim
260
261 MALOC = < Minimal Abstraction Layer for Object-oriented C >
262 Copyright (C) 1994-- Michael Holst
263
264 This library is free software; you can redistribute it and/or
265 modify it under the terms of the GNU Lesser General Public
266 License as published by the Free Software Foundation; either
267 version 2.1 of the License, or (at your option) any later version.
268
269 This library is distributed in the hope that it will be useful,
270 but WITHOUT ANY WARRANTY; without even the implied warranty of
271 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
272 Lesser General Public License for more details.
273
274 You should have received a copy of the GNU Lesser General Public
275 License along with this library; if not, write to the Free Software
276 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
277
278 @endverbatim
279 */