|
FreePOOMA
2.4.1
|
PrintField is a utility program for ConstField and Field object, used to print (nicely) the contents of an field to a provided stream. More...
#include <PrintField.h>
Public Member Functions | |
| PrintField (int domainWidth=3, int dataWidth=10, int dataPrecision=4, int carReturn=-1, bool scientific=false, int spacing=1) | |
| PrintField (const PrintField &a) | |
| ~PrintField () | |
| template<class S , class A > | |
| void | print (S &s, const A &a) const |
| int | domainWidth () const |
| void | setDomainWidth (int val) |
| int | dataWidth () const |
| void | setDataWidth (int val) |
| int | dataPrecision () const |
| void | setDataPrecision (int val) |
| int | carReturn () const |
| void | setCarReturn (int val) |
| bool | scientific () const |
| void | setScientific (bool val) |
| int | spacing () const |
| void | setSpacing (int val) |
PrintField is a utility program for ConstField and Field object, used to print (nicely) the contents of an field to a provided stream.
All the data in the field will be printed in ascii format; if you want to display just a portion of an field, take a view of the field and give that to the print() method.
CONSTRUCTING A PrintField: -------------------------- When you construct a PrintField, you can give it several format parameters to control how to display the field. These parameters are, in the order they are given in the constructor (all have default values):
domain width: the number of spaces that will be used to print out domain numbers. If it is 3, say, then domains will be printed like [003:008]
data width: the number of spaces, total, used to print out data values.
data precision: the number of digits past the decimal point displayed when data values are printed
carriage return: if this value is < 0, then for each row of values from the field, no carriage return is printed until the end of the row. If this number is > 0, it represents the maximum number of values that will be printed before a return. Only the first set of numbers for a row of the field will have a domain prefix included.
scientific notation: a boolean flag, if true numbers are printed using scientific notation, e.g. 10e-14
data spacing: the number of spaces to print between values
PRINTING FIELD OBJECTS WITH A PrintField: ----------------------------------------- PrintField is not templated, so that you can reuse the same formatter for different fields. It has one templated member function 'print':
template<class S, class A> void print(S &s, const A &a) const
where 'S' must be an object with an ostream-like interface (such as cout, or an Inform object), and 'A' must be an object with a Field interface. 'print' will take data from A and print it to the stream using the current format settings.
1-D fields just have the one row printed, perhaps on multiple lines if carReturn is > 0. 2-D fields are printed as a table, with each line prefixed by the domain it includes. For example:
[00:02][00] = 0 0 0 [00:02][01] = 0 0 0
prints the values for [0:2][0:1] of a 2D field. 3-D and higher arrays have a sequence of 2-D slices printed for them, each slice separated by a line indicating which slice it is, and a separator. Example:
[0:2:1][0:3:1][2]: ---------------------------------------------------- [00:02][00][02] = 0 0 0 [00:02][01][02] = 0 0 0 [00:02][02][02] = 0 0 0 [00:02][03][02] = 0 0 0
| PrintField::PrintField | ( | int | domainWidth = 3, |
| int | dataWidth = 10, |
||
| int | dataPrecision = 4, |
||
| int | carReturn = -1, |
||
| bool | scientific = false, |
||
| int | spacing = 1 |
||
| ) | [inline] |
References PAssert.
| PrintField::PrintField | ( | const PrintField & | a | ) | [inline] |
| PrintField::~PrintField | ( | ) | [inline] |
| void PrintField::print | ( | S & | s, |
| const A & | a | ||
| ) | const [inline] |
References Pooma::blockAndEvaluate(), and forEach().
Referenced by operator<<().
| int PrintField::domainWidth | ( | ) | const [inline] |
Referenced by PerformPrintField< Dim >::print(), and PerformPrintField< 1 >::print().
| void PrintField::setDomainWidth | ( | int | val | ) | [inline] |
References PAssert.
| int PrintField::dataWidth | ( | ) | const [inline] |
Referenced by PerformPrintField< Dim >::print(), and PerformPrintField< 1 >::print().
| void PrintField::setDataWidth | ( | int | val | ) | [inline] |
References PAssert.
| int PrintField::dataPrecision | ( | ) | const [inline] |
Referenced by PerformPrintField< Dim >::print(), and PerformPrintField< 1 >::print().
| void PrintField::setDataPrecision | ( | int | val | ) | [inline] |
References PAssert.
| int PrintField::carReturn | ( | ) | const [inline] |
Referenced by PerformPrintField< Dim >::print(), and PerformPrintField< 1 >::print().
| void PrintField::setCarReturn | ( | int | val | ) | [inline] |
| bool PrintField::scientific | ( | ) | const [inline] |
Referenced by PerformPrintField< Dim >::print(), and PerformPrintField< 1 >::print().
| void PrintField::setScientific | ( | bool | val | ) | [inline] |
| int PrintField::spacing | ( | ) | const [inline] |
Referenced by PerformPrintField< Dim >::print(), and PerformPrintField< 1 >::print().
| void PrintField::setSpacing | ( | int | val | ) | [inline] |
References PAssert.
1.7.6.1