Class documentation of Concepts

Loading...
Searching...
No Matches
inputoutput.doxy
1
52bool subdivide false @endcode
53
54 The results from the program are stored in a similar structure. At
55 the end of a program, it is possible to write the input and output
56 data into one file. The output file has the same syntax and
57 structure as the input file and can therefore be used as an input
58 file to reproduce the results at a later time. See the <a
59 href="#Results">results section</a> for an example.
60
61 @dontinclude inputoutput.cc
62 @section commented Commented Program
63
64 The first few lines in a code for concepts are filled with the
65 include files. I put the system includes first here.
66 @until unistd.h
67 Then, there are the Concepts includes:
68 <ul>
69 <li>basics.hh for the exception handling code and other things.
70 <li>toolbox.hh for the toolbox, including the intput file parser
71 and the handling of input and output data.
72 </ul>
73 Since there are no real computations in the code, no more include files
74 from Concepts are needed.
75 @until toolbox.hh
76 @skip main
77 All code in this example is in one large routine, the main program.
78 @until main
79 @skip uint
80 Some default values for the parameters used. \c l and \c p are just two
81 variables. If \c debug is set to true, more information is printed to
82 screen.
83 @until debug
84 A big try block to catch exceptions. More and more runtime errors
85 in Concepts are reported by throwing an exception.
86 @skip try
87 @until try
88 First, set up the input parameter class: some parameters
89 are set up with a default value.
91 @until parameterout
92 The variable outputParameter is for easier access to the output
93 area. There, the results of the computations can be stored and
94 eventually written to disk if necessary.
95 @skip input
96 @until input
97 Prepare an array for values computed later. This array is then
98 added to \c table which is able to nicely format the content of
99 the different arrays (e.g. for later processing with Gnuplot).
100 @skip error
101 @until inputfile
102
103 @subsection parsing Command Line Parsing
104 Here, we start with the command line parsing. See the man page
105 for \c getopt for more information.
106
107 In the second line of the following code fragement, the string
108 defines what command line arguments are allowed and if they take a
109 parameter (:) or not. The \c switch statement has an entry
110 for every command line argument listed in the string. There, the
111 parameter is available as \c optarg. The \c default
112 target of the \c switch clause prints some
113 usage information (ie. help for the command line arguments).
114
115 The parameters are processed in the order they appear on the
116 command line. When first specifying an input file with \c -f, the
117 values in the file can be overridden with additional command line
118 arguments after \c -f.
119 @until }
120 Print the parameters to show the user what is going on.
121 @skip std::cout
122 @until --
123 @until --
124 Next, the parameters from the command line or the input file are
125 stored in the respective variables. This is only used for
126 abbrevation.
127 @skip l
128 @until polynomial
129
130 @subsection comp Computations
131 Here are some dummy computations to fill the output area with
132 content.
133 @skip outputParameters.addInt
134 @until error
135
136 @section output Output
137 Finally, the input and output data are written to disk with some more
138 information about the user and the system in the header of the
139 file.
140 @skip std::cout
141 @until delete
142 This prints the table and its content to the screen and also
143 stores it with high precision in a file suitable for later
144 processing with Gnuplot.
145 @skip table
146 @until }
147 Here, all exceptions derived from the base exception class
148 (concepts::ExceptionBase) in Concepts are catched and printed. You
149 can test this out by not giving the name of the input file on the
150 command line. Then the parameter \c parameterout does not exist
151 and the library will throw and exception which is caught here.
152 @until }
153 @until }
154
155 @section Results
156 The output of the program called without parameters: @code
157[inputoutput]
158--
159Parameters:
160 input file =
161string author "(empty)"
162string comment "(empty)"
163string parameterout "inputoutput.out"
164string title "(empty)"
165int level 0
166int polynomial 1
167bool debug false
168--
169--
170Writing gathered data to disk: inputoutput.out
171ResultsTable(
172error error
1730 1
1741 0.5
1752 0.25
1763 0.125
1774 0.0625
1785 0.03125
1796 0.015625
1807 0.0078125
1818 0.00390625
1829 0.00195312
183) @endcode
184
185 The program creates the following output files:
186 - \c inputoutput.out: @code
187/* program: inputoutput
188 * command: inputoutput
189 * input file:
190 */
191string author "(empty)"
192string comment "(empty)"
193string parameterout "inputoutput.out"
194string title "(empty)"
195int level 0
196int polynomial 1
197bool debug false
198end
199// output starts here
200int nelm 10
201array double error {
202 0 1
203 1 0.5
204 2 0.25
205 3 0.125
206 4 0.0625
207 5 0.03125
208 6 0.015625
209 7 0.0078125
210 8 0.00390625
211 9 0.00195312
212} @endcode
213 - \c inputoutput.gnuplot: @code
214# error error
2150 1
2161 0.5
2172 0.25
2183 0.125
2194 0.0625
2205 0.03125
2216 0.015625
2227 0.0078125
2238 0.00390625
2249 0.001953125 @endcode
225
226 Note the \c end keyword at the end of the input
227 part and right before the output part. When reading in this file as
228 input file, the parsing stops right there, ie. the previous output
229 data is not read in.
230
231 @section complete Complete Source Code
232 @author Philipp Frauenfelder, 2004
233*/