PSCF v1.1
|
An array-valued parameter in a parameter file. More...
#include <MatrixParam.h>
Public Member Functions | |
MatrixParam (const char *label, int m, int n, bool isRequired=true) | |
Constructor. More... | |
virtual | ~MatrixParam () |
Destructor. More... | |
int | m () const |
Get the logical array dimension. More... | |
int | n () const |
Get the logical array dimension. More... | |
std::string | indent () const |
Return indent string for this object (string of spaces). More... | |
virtual void | readValue (std::istream &in) |
Read parameter value from an input stream. More... | |
virtual void | load (Serializable::IArchive &ar) |
Load from an archive. More... | |
virtual void | save (Serializable::OArchive &ar) |
Save to an archive. More... | |
std::string | label () const |
Return label string. More... | |
bool | isRequired () const |
Is this an optional parameter? More... | |
bool | isActive () const |
Is this parameter active? More... | |
![]() | |
Parameter (const char *label, bool isRequired=true) | |
Constructor. More... | |
virtual | ~Parameter () |
Destructor. More... | |
virtual void | readParam (std::istream &in) |
Read a label and (if the label matches) a parameter value. More... | |
virtual void | load (Serializable::IArchive &ar) |
Load from an archive. More... | |
virtual void | save (Serializable::OArchive &ar) |
Save to an archive. More... | |
std::string | label () const |
Return label string. More... | |
bool | isRequired () const |
Is this an optional parameter? More... | |
bool | isActive () const |
Is this parameter active? More... | |
![]() | |
virtual | ~ParamComponent () |
Destructor. More... | |
virtual void | readParam (std::istream &in)=0 |
Read parameter(s) from file. More... | |
virtual void | writeParam (std::ostream &out) const =0 |
Read parameter(s) to file. More... | |
virtual void | load (Serializable::IArchive &ar) |
Load internal state from an archive. More... | |
virtual void | save (Serializable::OArchive &ar) |
Save internal state to an archive. More... | |
virtual void | resetParam () |
Nontrivial implementation provided by ParamComposite subclass. More... | |
void | setIndent (const ParamComponent &parent, bool next=true) |
Set indent level. More... | |
std::string | indent () const |
Return indent string for this object (string of spaces). More... | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize this ParamComponent as a string. More... | |
![]() | |
virtual | ~Serializable () |
Destructor. More... | |
virtual void | save (OArchive &ar)=0 |
Save to an archive. More... | |
virtual void | load (IArchive &ar)=0 |
Load from an archive. More... | |
![]() | |
MpiFileIo () | |
Constructor. More... | |
MpiFileIo (const MpiFileIo &other) | |
Copy constructor. More... | |
bool | isIoProcessor () const |
Can this processor do file I/O ? More... | |
void | setIoCommunicator (MPI::Intracomm &communicator) |
Set the communicator. More... | |
void | clearCommunicator () |
Clear (nullify) the communicator. More... | |
bool | hasIoCommunicator () const |
Does this object have an associated MPI communicator? More... | |
MPI::Intracomm & | ioCommunicator () const |
Get the MPI communicator by reference. More... | |
Protected Member Functions | |
virtual void | readLabel (std::istream &in) |
Read parameter label from an input stream. More... | |
void | readEndBracket (std::istream &in) |
Read the closing delimiter, if any. More... | |
void | writeEndBracket (std::ostream &out) const |
Write the end bracket delimiter, if any. More... | |
bool | hasBrackets () const |
Are brackets being used as delimiters? More... | |
void | setBrackets (std::string lBracket, std::string rBracket) |
Set left and right bracket / delimiter strings. More... | |
![]() | |
virtual void | readLabel (std::istream &in) |
Read and attempt to match label string. More... | |
virtual void | readValue (std::istream &in) |
Read parameter value from an input stream. More... | |
virtual void | loadValue (Serializable::IArchive &ar) |
Load bare parameter value from an archive. More... | |
virtual void | saveValue (Serializable::OArchive &ar) |
Save parameter value to an archive. More... | |
virtual void | bcastValue () |
Broadcast parameter value within the ioCommunicator. More... | |
![]() | |
ParamComponent () | |
Constructor. More... | |
ParamComponent (const ParamComponent &other) | |
Copy constructor. More... | |
Protected Attributes | |
Label | label_ |
Label object that contains parameter label string. More... | |
![]() | |
Label | label_ |
Label object that contains parameter label string. More... | |
bool | isActive_ |
Is this parameter active (always true if isRequired). More... | |
Additional Inherited Members | |
![]() | |
typedef BinaryFileOArchive | OArchive |
Type of output archive used by save method. More... | |
typedef BinaryFileIArchive | IArchive |
Type of input archive used by load method. More... | |
![]() | |
template<class Type > | |
static void | saveOptional (Serializable::OArchive &ar, Type &value, bool isActive) |
Save an optional parameter value to an output archive. More... | |
template<class Type > | |
static void | saveOptionalCArray (Serializable::OArchive &ar, Type *ptr, int n, bool isActive) |
Save an optional C-array of n values to an output archive. More... | |
template<class Type > | |
static void | saveOptionalCArray2D (Serializable::OArchive &ar, Type *ptr, int m, int n, int np, bool isActive) |
Save an optional two-dimensional C array to an output archive. More... | |
![]() | |
static void | initStatic () |
Initialize static echo member to false. More... | |
static void | setEcho (bool echo=true) |
Enable or disable echoing for all subclasses of ParamComponent. More... | |
static bool | echo () |
Get echo parameter. More... | |
![]() | |
static const int | Width = 20 |
Width of output field for a scalar variable. More... | |
static const int | Precision = 12 |
Precision for io of floating point data field. More... | |
An array-valued parameter in a parameter file.
MatrixParam is a base class for objects that read and write the value of an matrix or 2D array containing a list of parameters of the same
type.
Matrices can be read and written in either of two formats:
Different subclasses may use different formats for the data lines, and different choices of delmiting brackets (e.g., square brackets or parentheses). Two different conventions are in use:
Either row or element data format may be input and output in either bracketed or bracket-free format. The choice of whether to use bracketed or bracket-free format is determined by the global bracket policy returned by the function Util::BracketPolicy::get().
Definition at line 61 of file MatrixParam.h.
Util::MatrixParam< Type >::MatrixParam | ( | const char * | label, |
int | m, | ||
int | n, | ||
bool | isRequired = true |
||
) |
Constructor.
label | label string (without any opening bracket) |
m | number of rows |
n | number of columns |
isRequired | Is this a required parameter? |
Definition at line 24 of file MatrixParam.tpp.
References Util::BracketPolicy::get(), Util::MatrixParam< Type >::label_, and Util::Label::setString().
|
virtual |
Destructor.
Definition at line 47 of file MatrixParam.tpp.
|
inline |
Get the logical array dimension.
Definition at line 84 of file MatrixParam.h.
|
inline |
Get the logical array dimension.
Definition at line 90 of file MatrixParam.h.
|
protectedvirtual |
Read parameter label from an input stream.
in | input stream from which to read |
Reimplemented from Util::Parameter.
Definition at line 76 of file MatrixParam.tpp.
References Util::BracketPolicy::get(), and Util::Label::isMatched().
|
protected |
Read the closing delimiter, if any.
Attempts to read closing bracket iff hasBrackets is true. Throws an exception if hasBrackets is true but the expected delimiter is not found.
in | input stream from which to read |
Definition at line 126 of file MatrixParam.tpp.
References Util::BracketPolicy::get(), and UTIL_CHECK.
Referenced by Util::CArray2DParam< Type >::readValue(), and Util::DMatrixParam< Type >::readValue().
|
protected |
Write the end bracket delimiter, if any.
out | output stream to which to write |
Definition at line 150 of file MatrixParam.tpp.
Referenced by Util::CArray2DParam< Type >::writeParam(), and Util::DMatrixParam< Type >::writeParam().
|
inlineprotected |
Are brackets being used as delimiters?
Definition at line 131 of file MatrixParam.h.
|
protected |
Set left and right bracket / delimiter strings.
lBracket | left bracket string |
rBracket | right bracket string |
Definition at line 54 of file MatrixParam.tpp.
References Util::BracketPolicy::get().
Referenced by Util::CArray2DParam< Type >::CArray2DParam(), Util::DMatrixParam< Type >::DMatrixParam(), and Util::DSymmMatrixParam< Type >::DSymmMatrixParam().
std::string Util::ParamComponent::indent | ( | ) | const |
Return indent string for this object (string of spaces).
Definition at line 96 of file ParamComponent.cpp.
|
inlinevirtual |
Read parameter value from an input stream.
in | input stream from which to read |
Reimplemented from Util::Parameter.
Definition at line 202 of file Parameter.h.
|
virtual |
Load from an archive.
An optional Parameter loads the value of an isActive flag, and then loads the parameter value only if the isActive is true. A required Parameter simply loads the parameter value. The variable associated with an optional Parameter must be set to its default value before attempting to load the parameter. Optional parameters should be saved either using the save() method of an associated Parameter object or using the appropriate overloaded Parameter::saveOptional() static member function, which both use the required format.
ar | input archive from which to load |
Reimplemented from Util::Parameter.
Definition at line 150 of file Parameter.cpp.
Referenced by Util::ParamComposite::loadCArray2D(), Util::ParamComposite::loadDMatrix(), and Util::ParamComposite::loadDSymmMatrix().
|
virtual |
Save to an archive.
An optional Parameter saves the value of the isActive flag, and then saves a parameter value only if the isActive is true. A required Parameter simply saves its value. The label string is not saved to the archive.
The overloaded static saveOptional functions can also be used to save optional parameter values in this format.
ar | output archive to which to save |
Reimplemented from Util::Parameter.
Definition at line 165 of file Parameter.cpp.
std::string Util::Parameter::label | ( | ) | const |
Return label string.
Definition at line 170 of file Parameter.cpp.
Referenced by pscfpp.param.Composite::__init__(), pscfpp.param.Matrix::__init__(), pscfpp.param.Array::__init__(), pscfpp.param.Parameter::__init__(), pscfpp.command.Command::__init__(), pscfpp.param.Composite::getString(), pscfpp.param.Array::getString(), and pscfpp.param.Matrix::getString().
bool Util::Parameter::isRequired | ( | ) | const |
Is this an optional parameter?
Definition at line 175 of file Parameter.cpp.
bool Util::Parameter::isActive | ( | ) | const |
Is this parameter active?
Definition at line 180 of file Parameter.cpp.
|
protected |
Label object that contains parameter label string.
Definition at line 185 of file Parameter.h.
Referenced by Util::MatrixParam< Type >::MatrixParam().