PSCF v1.1
|
An object that can read multiple parameters from file. More...
#include <ParamComposite.h>
Public Member Functions | |
ParamComposite () | |
Constructor. More... | |
ParamComposite (const ParamComposite &other) | |
Copy constructor. More... | |
ParamComposite (int capacity) | |
Constructor. More... | |
virtual | ~ParamComposite () |
Virtual destructor. More... | |
void | resetParam () |
Resets ParamComposite to its empty state. More... | |
Read and write functions for the composite | |
virtual void | readParam (std::istream &in) |
Read the parameter file block. More... | |
virtual void | readParamOptional (std::istream &in) |
Read optional parameter file block. More... | |
virtual void | readParameters (std::istream &in) |
Read the body of parameter block, without begin and end lines. More... | |
virtual void | writeParam (std::ostream &out) const |
Write all parameters to an output stream. More... | |
Serialization: Load and save functions for this composite | |
virtual void | load (Serializable::IArchive &ar) |
Load all parameters from an input archive. More... | |
virtual void | loadOptional (Serializable::IArchive &ar) |
Load an optional ParamComposite. More... | |
virtual void | loadParameters (Serializable::IArchive &ar) |
Load state from archive, without adding Begin and End lines. More... | |
virtual void | save (Serializable::OArchive &ar) |
Saves all parameters to an archive. More... | |
void | saveOptional (Serializable::OArchive &ar) |
Saves isActive flag, and then calls save() iff isActive is true. More... | |
read* functions for child components | |
Each of these functions creates a new instance of a particular subclass of ParamComponent, invokes the readParam() function of the new object to read the associated line or block of a parameter file, and adds the object to the format. | |
void | readParamComposite (std::istream &in, ParamComposite &child, bool next=true) |
Add and read a required child ParamComposite. More... | |
void | readParamCompositeOptional (std::istream &in, ParamComposite &child, bool next=true) |
Add and attempt to read an optional child ParamComposite. More... | |
template<typename Type > | |
ScalarParam< Type > & | read (std::istream &in, const char *label, Type &value) |
Add and read a new required ScalarParam < Type > object. More... | |
template<typename Type > | |
ScalarParam< Type > & | readOptional (std::istream &in, const char *label, Type &value) |
Add and read a new optional ScalarParam < Type > object. More... | |
template<typename Type > | |
CArrayParam< Type > & | readCArray (std::istream &in, const char *label, Type *value, int n) |
Add and read a required C array parameter. More... | |
template<typename Type > | |
CArrayParam< Type > & | readOptionalCArray (std::istream &in, const char *label, Type *value, int n) |
Add and read an optional C array parameter. More... | |
template<typename Type > | |
DArrayParam< Type > & | readDArray (std::istream &in, const char *label, DArray< Type > &array, int n) |
Add and read a required DArray < Type > parameter. More... | |
template<typename Type > | |
DArrayParam< Type > & | readOptionalDArray (std::istream &in, const char *label, DArray< Type > &array, int n) |
Add and read an optional DArray < Type > parameter. More... | |
template<typename Type , int N> | |
FArrayParam< Type, N > & | readFArray (std::istream &in, const char *label, FArray< Type, N > &array) |
Add and read a required FArray < Type, N > array parameter. More... | |
template<typename Type , int N> | |
FArrayParam< Type, N > & | readOptionalFArray (std::istream &in, const char *label, FArray< Type, N > &array) |
Add and read an optional FArray < Type, N > array parameter. More... | |
template<typename Type , int N> | |
FSArrayParam< Type, N > & | readFSArray (std::istream &in, const char *label, FSArray< Type, N > &array, int size) |
Add and read a required FSArray < Type, N > array parameter. More... | |
template<typename Type , int N> | |
FSArrayParam< Type, N > & | readOptionalFSArray (std::istream &in, const char *label, FSArray< Type, N > &array, int size) |
Add and read an optional FSArray < Type, N > array parameter. More... | |
template<typename Type > | |
CArray2DParam< Type > & | readCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np) |
Add and read a required CArray2DParam < Type > 2D C-array. More... | |
template<typename Type > | |
CArray2DParam< Type > & | readOptionalCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np) |
Add and read an optional CArray2DParam < Type > 2D C-array parameter. More... | |
template<typename Type > | |
DMatrixParam< Type > & | readDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n) |
Add and read a required DMatrix < Type > matrix parameter. More... | |
template<typename Type > | |
DMatrixParam< Type > & | readOptionalDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n) |
Add and read an optional DMatrix < Type > matrix parameter. More... | |
template<typename Type > | |
DSymmMatrixParam< Type > & | readDSymmMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int n) |
Add and read a required symmetrix DMatrix. More... | |
template<typename Type > | |
DSymmMatrixParam< Type > & | readOptionalDSymmMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int n) |
Add and read an optional DMatrix matrix parameter. More... | |
Begin & | readBegin (std::istream &in, const char *label, bool isRequired=true) |
Add and read a class label and opening bracket. More... | |
End & | readEnd (std::istream &in) |
Add and read the closing bracket. More... | |
Blank & | readBlank (std::istream &in) |
Add and read a new Blank object, representing a blank line. More... | |
load* functions for child components | |
Load parameters from an Archive, for restarting. Each of these functions creates a new instance of a subclass of ParamComponent, and invokes the load() function of that new object to load the associated parameter value, and adds the ParamComponent to the format list. These functions are used to load parameters when a program is restarted from a checkpoint file. | |
void | loadParamComposite (Serializable::IArchive &ar, ParamComposite &child, bool next=true) |
Add and load a required child ParamComposite. More... | |
void | loadParamCompositeOptional (Serializable::IArchive &ar, ParamComposite &child, bool next=true) |
Add and load an optional child ParamComposite if isActive. More... | |
template<typename Type > | |
ScalarParam< Type > & | loadParameter (Serializable::IArchive &ar, const char *label, Type &value, bool isRequired) |
Add and load a new ScalarParam < Type > object. More... | |
template<typename Type > | |
ScalarParam< Type > & | loadParameter (Serializable::IArchive &ar, const char *label, Type &value) |
Add and load new required ScalarParam < Type > object. More... | |
template<typename Type > | |
CArrayParam< Type > & | loadCArray (Serializable::IArchive &ar, const char *label, Type *value, int n, bool isRequired) |
Add a C array parameter and load its elements. More... | |
template<typename Type > | |
CArrayParam< Type > & | loadCArray (Serializable::IArchive &ar, const char *label, Type *value, int n) |
Add and load a required CArrayParam< Type > array parameter. More... | |
template<typename Type > | |
DArrayParam< Type > & | loadDArray (Serializable::IArchive &ar, const char *label, DArray< Type > &array, int n, bool isRequired) |
Add an load a DArray < Type > array parameter. More... | |
template<typename Type > | |
DArrayParam< Type > & | loadDArray (Serializable::IArchive &ar, const char *label, DArray< Type > &array, int n) |
Add and load a required DArray< Type > array parameter. More... | |
template<typename Type , int N> | |
FArrayParam< Type, N > & | loadFArray (Serializable::IArchive &ar, const char *label, FArray< Type, N > &array, bool isRequired) |
Add and load an FArray < Type, N > fixed-size array parameter. More... | |
template<typename Type , int N> | |
FArrayParam< Type, N > & | loadFArray (Serializable::IArchive &ar, const char *label, FArray< Type, N > &array) |
Add and load a required FArray < Type > array parameter. More... | |
template<typename Type , int N> | |
FSArrayParam< Type, N > & | loadFSArray (Serializable::IArchive &ar, const char *label, FSArray< Type, N > &array, int size, bool isRequired) |
Add and load an FSArray < Type, N > array parameter. More... | |
template<typename Type , int N> | |
FSArrayParam< Type, N > & | loadFSArray (Serializable::IArchive &ar, const char *label, FSArray< Type, N > &array, int size) |
Add and load a required FSArray < Type > array parameter. More... | |
template<typename Type > | |
CArray2DParam< Type > & | loadCArray2D (Serializable::IArchive &ar, const char *label, Type *value, int m, int n, int np, bool isRequired) |
Add and load a CArray2DParam < Type > C 2D array parameter. More... | |
template<typename Type > | |
CArray2DParam< Type > & | loadCArray2D (Serializable::IArchive &ar, const char *label, Type *value, int m, int n, int np) |
Add and load a required < Type > matrix parameter. More... | |
template<typename Type > | |
DMatrixParam< Type > & | loadDMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int m, int n, bool isRequired) |
Add and load a DMatrixParam < Type > matrix parameter. More... | |
template<typename Type > | |
DMatrixParam< Type > & | loadDMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int m, int n) |
Add and load a required DMatrixParam < Type > matrix parameter. More... | |
template<typename Type > | |
DSymmMatrixParam< Type > & | loadDSymmMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int n, bool isRequired) |
Add and load a symmetric DSymmMatrixParam < Type > matrix parameter. More... | |
template<typename Type > | |
DSymmMatrixParam< Type > & | loadDSymmMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int n) |
Add and load a required DSymmMatrixParam < Type > matrix parameter. More... | |
add* functions for child components | |
These functions add a ParamComponent to the format array, but do not read data. | |
void | addParamComposite (ParamComposite &child, bool next=true) |
Add a child ParamComposite object to the format array. More... | |
Begin & | addBegin (const char *label) |
Add a Begin object representing a class name and bracket. More... | |
End & | addEnd () |
Add a closing bracket. More... | |
Blank & | addBlank () |
Create and add a new Blank object, representing a blank line. 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... | |
Accessors | |
std::string | className () const |
Get class name string. More... | |
bool | isRequired () const |
Is this ParamComposite required in the input file? More... | |
bool | isActive () const |
Is this parameter active? More... | |
void | setClassName (const char *className) |
Set class name string. More... | |
void | setIsRequired (bool isRequired) |
Set or unset the isActive flag. More... | |
void | setIsActive (bool isActive) |
Set or unset the isActive flag. More... | |
void | setParent (ParamComponent ¶m, bool next=true) |
Set this to the parent of a child component. More... | |
void | addComponent (ParamComponent ¶m, bool isLeaf=true) |
Add a new ParamComponent object to the format array. More... | |
template<typename Type > | |
ScalarParam< Type > & | add (std::istream &in, const char *label, Type &value, bool isRequired=true) |
Add a new required ScalarParam < Type > object. More... | |
template<typename Type > | |
CArrayParam< Type > & | addCArray (std::istream &in, const char *label, Type *value, int n, bool isRequired=true) |
Add (but do not read) a required C array parameter. More... | |
template<typename Type > | |
DArrayParam< Type > & | addDArray (std::istream &in, const char *label, DArray< Type > &array, int n, bool isRequired=true) |
Add (but do not read) a DArray < Type > parameter. More... | |
template<typename Type , int N> | |
FArrayParam< Type, N > & | addFArray (std::istream &in, const char *label, FArray< Type, N > &array, bool isRequired=true) |
Add (but do not read) a FArray < Type, N > array parameter. More... | |
template<typename Type , int N> | |
FSArrayParam< Type, N > & | addFSArray (std::istream &in, const char *label, FSArray< Type, N > &array, int size, bool isRequired=true) |
Add (but do not read) a FSArray < Type, N > array parameter. More... | |
template<typename Type > | |
CArray2DParam< Type > & | addCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np, bool isRequired=true) |
Add (but do not read) a CArray2DParam < Type > 2D C-array. More... | |
template<typename Type > | |
DMatrixParam< Type > & | addDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n, bool isRequired=true) |
Add and read a required DMatrix < Type > matrix parameter. 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... | |
![]() | |
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... | |
![]() | |
ParamComponent () | |
Constructor. More... | |
ParamComponent (const ParamComponent &other) | |
Copy constructor. More... | |
An object that can read multiple parameters from file.
Any class that reads a block of parameters from a parameter file must be derived from ParamComposite. Each such class must implement either the readParameters() function or the readParam() function, but not both. The readParameters(), if reimplemented, should read the body of the associated parameter file block, without opening or closing lines. The readParam() function reads the the entire block, including opening line and closing lines. The default implementation of readParam() reads the opening line of the block, calls readParameters() to read the body of the block, and then reads the closing line. Most subclasses of ParamComposite re-implement the readParameters() function, and rely on the default implementation of readParam() to add the Begin and End lines.
The writeParam() function, if called after readParam(), writes the associated parameter block using the same file format as that used to read the data in the earlier call to readParam().
After parameter file block is read from file, the file format is stored as a private array of ParaComponent* pointers. We will refer to this in what follows as the format_ array. Each pointer in this array may point to a Parameter, ParamComposite, Begin, End, or Blank object. Pointers to these objects are added to the format array as the associated objects are read from file, and are stored in the same order as they appear in the parameter file. The default implementation of the writeParam() function simply calls the writeParam() function of each child ParamComponent.
The readParameters() function of each subclass of ParamComposite should be implemented using protected member functions of ParamComposite with names that begin with "read". The read<T>() function template can be used to read an individual parameter, while readParamComposite reads the nested subblock associated with a child ParamComposite. There are also more specialized methods (e.g., readDArray<T>to read different types of arrays and matrices of parameters, and to read optional parameters. See the users manual for further details.
The setClassName() and className() functions may be used to set and get a std::string containing the subclass name. The setClassName() function should be called in the constructor of each subclass of ParamComposite. The class name set in the constructor of a subclass will replace any name set by a base class, because of the order in which constructors are called. The default implementation of ParamComposite::readParam() checks if the class name that appears in the opening line of a parameter block agrees with the class name returned by the className() function, and throws an exception if it does not.
Definition at line 90 of file ParamComposite.h.
Util::ParamComposite::ParamComposite | ( | ) |
Constructor.
Definition at line 23 of file ParamComposite.cpp.
Util::ParamComposite::ParamComposite | ( | const ParamComposite & | other | ) |
Copy constructor.
Definition at line 55 of file ParamComposite.cpp.
Util::ParamComposite::ParamComposite | ( | int | capacity | ) |
Constructor.
Reserve space for capacity elements in the format array.
capacity | maximum length of parameter list |
Definition at line 36 of file ParamComposite.cpp.
References UTIL_THROW.
|
virtual |
Virtual destructor.
Definition at line 68 of file ParamComposite.cpp.
|
virtual |
Resets ParamComposite to its empty state.
This function deletes Parameter, Begin, End, and Blank objects in the format array (i.e., all "leaf" objects in the format tree), invokes the resetParam() function of any child ParamComposite in the format array, and clears the format array.
Reimplemented from Util::ParamComponent.
Definition at line 209 of file ParamComposite.cpp.
|
virtual |
Read the parameter file block.
Inherited from ParamComponent. This function reads the entire parameter block for this ParamComposite, including an opening line, which is of the form "ClassName{", and the closing line, which contains only a closing bracket, "}". The default implementation reads the opening line (a Begin object), calls the virtual readParameters function to read the body of the block, and reads the closing line (an End object).
Throws | if the string in the opening line does not match the string returned by the classname() function. |
in | input stream for reading |
Implements Util::ParamComponent.
Reimplemented in Pscf::Fd1d::System, Pscf::Pspc::System< D >, Pscf::Pspg::System< D >, and Util::Manager< Data >.
Definition at line 88 of file ParamComposite.cpp.
References readBegin(), readEnd(), and readParameters().
Referenced by readParamComposite().
|
virtual |
Read optional parameter file block.
Read an optional ParamComposite. This function must use a Label() object to read the opening "ClassName{" line, and then continues to read the rest of the block if and only if the class name in the opening line matches the string returned by the classname() function.
If the first line matches, the default implementation calls the readParameters() member function to read the body of the block, and then reads the ending line.
in | input stream for reading |
Reimplemented in Util::Manager< Data >.
Definition at line 101 of file ParamComposite.cpp.
References Util::Begin::isActive(), readBegin(), readEnd(), and readParameters().
Referenced by readParamCompositeOptional().
|
inlinevirtual |
Read the body of parameter block, without begin and end lines.
Most subclasses of ParamComposite should re-implement this function, which has an empty default implementation. Every subclass of Paramcomposite must either: (1) Re-implement this function and rely on the default implementation of readParam(), which calls this function. (2) Re-implement readParam() itself. Option (1) is far more common. Option (2) is required only for classes that require a non-standard treatment of the beginning and ending lines (e.g., the Manager class template).
in | input stream for reading |
Reimplemented in Pscf::Fd1d::Domain, Pscf::Fd1d::BinaryRelaxIterator, Pscf::Fd1d::NrIterator, Pscf::Fd1d::Mixture, Pscf::Fd1d::LinearSweep, Pscf::Fd1d::Sweep, Pscf::Fd1d::System, Pscf::SolventDescriptor, Pscf::Homogeneous::Mixture, Pscf::Homogeneous::Molecule, Pscf::Interaction, Pscf::MixtureTmpl< TP, TS >, Pscf::MixtureTmpl< Polymer, Solvent >, Pscf::MixtureTmpl< Polymer< D >, Solvent< D > >, Pscf::PolymerTmpl< Block >, Pscf::PolymerTmpl< Block< D > >, Pscf::SweepTmpl< State >, Pscf::SweepTmpl< DArray< System::WField > >, Pscf::SweepTmpl< BasisFieldState< D > >, Pscf::Pspc::Domain< D >, Pscf::Pspc::FilmIteratorBase< D, IteratorType >, Pscf::Pspc::FilmIteratorBase< 1, IteratorType >, Pscf::Pspc::FilmIteratorBase< 2, IteratorType >, Pscf::Pspc::FilmIteratorBase< 3, IteratorType >, Pscf::Pspc::Mixture< D >, Pscf::Pspc::LinearSweep< D >, Pscf::Pspc::Sweep< D >, Pscf::Pspc::System< D >, Pscf::Pspg::Domain< D >, Pscf::Pspg::Mixture< D >, Pscf::Pspg::LinearSweep< D >, Pscf::Pspg::Sweep< D >, Pscf::Pspg::System< D >, Util::AutoCorr< Data, Product >, Util::AutoCorrArray< Data, Product >, Util::AutoCorrelation< Data, Product >, Util::Average, Util::Distribution, Util::IntDistribution, Util::MeanSqDispArray< Data >, Util::RadialDistribution, Util::SymmTensorAverage, Util::TensorAverage, Util::FileMaster, Util::Manager< Data >, and Util::Random.
Definition at line 181 of file ParamComposite.h.
Referenced by readParam(), and readParamOptional().
|
virtual |
Write all parameters to an output stream.
The default implementation iterates through the format array, and calls the readParam() member function of each ParamComponent in the array. This is sufficient for most subclasses.
out | output stream for reading |
Implements Util::ParamComponent.
Definition at line 119 of file ParamComposite.cpp.
Referenced by Pscf::Fd1d::Sweep::outputSolution(), Pscf::Fd1d::System::readCommands(), and Pscf::Fd1d::System::writeParamNoSweep().
|
virtual |
Load all parameters from an input archive.
This function is inherited from Serializable. The default implementation of ParamComposite::load() calls loadParameters, and adds Begin and End lines to the format array.. All subclasses of ParamComposite should overload the virtual loadParameters member function.
ar | input/loading archive. |
Reimplemented from Util::ParamComponent.
Reimplemented in Util::AutoCorrelation< Data, Product >.
Definition at line 131 of file ParamComposite.cpp.
References addBegin(), addEnd(), Util::ParamComponent::echo(), Util::Log::file(), Util::MpiFileIo::isIoProcessor(), loadParameters(), Util::Begin::writeParam(), and Util::End::writeParam().
Referenced by loadOptional(), and loadParamComposite().
|
virtual |
Load an optional ParamComposite.
Loads isActive, and calls load(ar) if active.
ar | input/loading archive. |
Definition at line 152 of file ParamComposite.cpp.
References Util::bcast< bool >(), className(), Util::ParamComponent::echo(), Util::Log::file(), Util::MpiFileIo::hasIoCommunicator(), Util::ParamComponent::indent(), Util::MpiFileIo::ioCommunicator(), Util::MpiFileIo::isIoProcessor(), load(), and UTIL_THROW.
Referenced by loadParamCompositeOptional().
|
inlinevirtual |
Load state from archive, without adding Begin and End lines.
This function should be re-implemented by all subclasses that have an internal state that should be saved in a restart file. The default implementation is empty. Subclass implementations should load the entire internal state from the archive, including parameters that appear in the parameter file and any persistent private member variables that do not appear in the parameter file.
ar | input/loading archive. |
Reimplemented in Util::AutoCorr< Data, Product >, Util::AutoCorrArray< Data, Product >, Util::Average, Util::Distribution, Util::IntDistribution, Util::MeanSqDispArray< Data >, Util::RadialDistribution, Util::SymmTensorAverage, Util::TensorAverage, Util::FileMaster, Util::Manager< Data >, and Util::Random.
Definition at line 234 of file ParamComposite.h.
Referenced by load().
|
virtual |
Saves all parameters to an archive.
The default implementation simply calls the save function for all items in the parameter file format array. This is often not sufficient. Specifically, it is not sufficient for classes that contain any persistent member variables that do not appear in the parameter file format.
If a class also defines a serialize function template, which allows instances to be serialized to any type of archive, then the save function can often be implemented as follows:
ar | output/saving archive. |
Reimplemented from Util::ParamComponent.
Reimplemented in Util::AutoCorr< Data, Product >, Util::AutoCorrArray< Data, Product >, Util::AutoCorrelation< Data, Product >, Util::Average, Util::Distribution, Util::IntDistribution, Util::MeanSqDispArray< Data >, Util::RadialDistribution, Util::SymmTensorAverage, Util::TensorAverage, Util::FileMaster, Util::Manager< Data >, and Util::Random.
Definition at line 188 of file ParamComposite.cpp.
Referenced by saveOptional().
void Util::ParamComposite::saveOptional | ( | Serializable::OArchive & | ar | ) |
Saves isActive flag, and then calls save() iff isActive is true.
ar | output/saving archive. |
Definition at line 198 of file ParamComposite.cpp.
References save().
void Util::ParamComposite::readParamComposite | ( | std::istream & | in, |
ParamComposite & | child, | ||
bool | next = true |
||
) |
Add and read a required child ParamComposite.
in | input stream for reading |
child | child ParamComposite object |
next | true if the indent level is one higher than parent. |
Definition at line 260 of file ParamComposite.cpp.
References addParamComposite(), and readParam().
Referenced by Pscf::Fd1d::System::readParameters(), and Pscf::Homogeneous::Mixture::readParameters().
void Util::ParamComposite::readParamCompositeOptional | ( | std::istream & | in, |
ParamComposite & | child, | ||
bool | next = true |
||
) |
Add and attempt to read an optional child ParamComposite.
in | input stream for reading |
child | child ParamComposite object |
next | true if the indent level is one higher than parent. |
Definition at line 271 of file ParamComposite.cpp.
References addParamComposite(), and readParamOptional().
ScalarParam< Type > & Util::ParamComposite::read | ( | std::istream & | in, |
const char * | label, | ||
Type & | value | ||
) |
Add and read a new required ScalarParam < Type > object.
This is equivalent to ScalarParam<Type>(in, label, value, true).
in | input stream for reading |
label | Label string |
value | reference to new ScalarParam< Type > |
Definition at line 1248 of file ParamComposite.h.
Referenced by pscfpp.param.Composite::__init__(), pscfpp.field.Field::__init__(), pscfpp.command.Script::__init__(), pscfpp.output.Thermo::__init__(), pscfpp.param.Matrix::__init__(), pscfpp.param.Array::__init__(), Pscf::Fd1d::Domain::readParameters(), Pscf::Fd1d::BinaryRelaxIterator::readParameters(), Pscf::Fd1d::NrIterator::readParameters(), Pscf::Fd1d::LinearSweep::readParameters(), and Pscf::SolventDescriptor::readParameters().
|
inline |
Add and read a new optional ScalarParam < Type > object.
This is equivalent to ScalarParam<Type>(in, label, value, false).
in | input stream for reading |
label | Label string |
value | reference to new ScalarParam< Type > |
Definition at line 1256 of file ParamComposite.h.
Referenced by Pscf::Fd1d::Domain::readParameters(), Pscf::Fd1d::NrIterator::readParameters(), and Pscf::SolventDescriptor::readParameters().
|
inline |
Add and read a required C array parameter.
in | input stream for reading |
label | Label string for new array |
value | pointer to array |
n | number of elements |
Definition at line 1323 of file ParamComposite.h.
|
inline |
Add and read an optional C array parameter.
in | input stream for reading |
label | Label string for new array |
value | pointer to array |
n | number of elements |
Definition at line 1332 of file ParamComposite.h.
|
inline |
Add and read a required DArray < Type > parameter.
in | input stream for reading |
label | Label string for new array |
array | DArray object |
n | number of elements |
Definition at line 1400 of file ParamComposite.h.
|
inline |
Add and read an optional DArray < Type > parameter.
in | input stream for reading |
label | Label string for new array |
array | DArray object |
n | number of elements |
Definition at line 1410 of file ParamComposite.h.
|
inline |
Add and read a required FArray < Type, N > array parameter.
Definition at line 1480 of file ParamComposite.h.
|
inline |
Add and read an optional FArray < Type, N > array parameter.
Definition at line 1490 of file ParamComposite.h.
|
inline |
Add and read a required FSArray < Type, N > array parameter.
in | input stream for reading |
label | Label string for new array |
array | FSArray object |
size | logical size of array |
Definition at line 1551 of file ParamComposite.h.
|
inline |
Add and read an optional FSArray < Type, N > array parameter.
in | input stream for reading |
label | Label string for new array |
array | FSArray object |
size | logical size of array |
Definition at line 1561 of file ParamComposite.h.
|
inline |
Add and read a required CArray2DParam < Type > 2D C-array.
in | input stream for reading |
label | Label string for new array |
value | pointer to array |
m | number of rows (1st dimension) |
n | logical number of columns (2nd dimension) |
np | physical number of columns (elements allocated per row) |
Definition at line 1625 of file ParamComposite.h.
|
inline |
Add and read an optional CArray2DParam < Type > 2D C-array parameter.
in | input stream for reading |
label | Label string for new array |
value | pointer to array |
m | number of rows (1st dimension) |
n | logical number of columns (2nd dimension) |
np | physical number of columns (elements allocated per row) |
Definition at line 1634 of file ParamComposite.h.
|
inline |
Add and read a required DMatrix < Type > matrix parameter.
in | input stream for reading |
label | Label string for new array |
matrix | DMatrix object |
m | number of rows (1st dimension) |
n | number of columns (2nd dimension) |
Definition at line 1707 of file ParamComposite.h.
|
inline |
Add and read an optional DMatrix < Type > matrix parameter.
in | input stream for reading |
label | Label string for new array |
matrix | DMatrix object |
m | number of rows (1st dimension) |
n | number of columns (2nd dimension) |
Definition at line 1716 of file ParamComposite.h.
|
inline |
Add and read a required symmetrix DMatrix.
in | input stream for reading |
label | Label string for new array |
matrix | DMatrix object |
n | number of rows or columns |
Definition at line 1772 of file ParamComposite.h.
Referenced by Pscf::Interaction::readParameters().
|
inline |
Add and read an optional DMatrix matrix parameter.
in | input stream for reading |
label | Label string for new array |
matrix | DMatrix object |
n | number of rows or columns |
Definition at line 1783 of file ParamComposite.h.
Begin & Util::ParamComposite::readBegin | ( | std::istream & | in, |
const char * | label, | ||
bool | isRequired = true |
||
) |
Add and read a class label and opening bracket.
in | input stream for reading |
label | class name string, without trailing bracket |
isRequired | Is this the beginning of a required element? |
Definition at line 316 of file ParamComposite.cpp.
References addComponent(), Util::Begin::isActive(), isRequired(), Util::Begin::readParam(), and setParent().
Referenced by Pscf::Fd1d::System::readParam(), readParam(), and readParamOptional().
End & Util::ParamComposite::readEnd | ( | std::istream & | in | ) |
Add and read the closing bracket.
in | input stream for reading |
Definition at line 344 of file ParamComposite.cpp.
References addEnd(), and Util::End::readParam().
Referenced by Pscf::Fd1d::System::readParam(), readParam(), and readParamOptional().
Blank & Util::ParamComposite::readBlank | ( | std::istream & | in | ) |
Add and read a new Blank object, representing a blank line.
in | input stream for reading |
Definition at line 367 of file ParamComposite.cpp.
References addBlank(), and Util::Blank::readParam().
void Util::ParamComposite::loadParamComposite | ( | Serializable::IArchive & | ar, |
ParamComposite & | child, | ||
bool | next = true |
||
) |
Add and load a required child ParamComposite.
ar | input archive for loading |
child | child ParamComposite object |
next | true if the indent level is one higher than parent. |
Definition at line 282 of file ParamComposite.cpp.
References addParamComposite(), and load().
Referenced by Util::Factory< Data >::loadObject().
void Util::ParamComposite::loadParamCompositeOptional | ( | Serializable::IArchive & | ar, |
ParamComposite & | child, | ||
bool | next = true |
||
) |
Add and load an optional child ParamComposite if isActive.
This functional loads the isActive flag, and then calls the load function of the child iff isActive is true.
ar | input archive for loading |
child | child ParamComposite object |
next | true if the indent level is one higher than parent. |
Definition at line 293 of file ParamComposite.cpp.
References addParamComposite(), and loadOptional().
ScalarParam< Type > & Util::ParamComposite::loadParameter | ( | Serializable::IArchive & | ar, |
const char * | label, | ||
Type & | value, | ||
bool | isRequired | ||
) |
Add and load a new ScalarParam < Type > object.
An optional parameter is indicated by setting isRequired = false. Optional parameters must be saved using the Parameter::saveOptional() static member function.
ar | archive for loading |
label | Label string |
value | reference to the Type variable |
isRequired | Is this a required parameter? |
Definition at line 1265 of file ParamComposite.h.
References addComponent(), isRequired(), Util::Parameter::load(), and setParent().
|
inline |
Add and load new required ScalarParam < Type > object.
Equivalent to loadParameter < Type > (ar, label, value, true).
ar | archive for loading |
label | label string |
value | reference to the Type variable |
Definition at line 1281 of file ParamComposite.h.
CArrayParam< Type > & Util::ParamComposite::loadCArray | ( | Serializable::IArchive & | ar, |
const char * | label, | ||
Type * | value, | ||
int | n, | ||
bool | isRequired | ||
) |
Add a C array parameter and load its elements.
ar | archive for loading |
label | label string for new array |
value | pointer to array |
n | number of elements |
isRequired | Is this a required parameter? |
Definition at line 1341 of file ParamComposite.h.
References addComponent(), isRequired(), Util::ArrayParam< Type >::load(), and setParent().
|
inline |
Add and load a required CArrayParam< Type > array parameter.
Equivalent to loadCArray < Type > (ar, label, value, n, true).
ar | archive for loading |
label | label string for new array |
value | pointer to array |
n | number of elements |
Definition at line 1357 of file ParamComposite.h.
DArrayParam< Type > & Util::ParamComposite::loadDArray | ( | Serializable::IArchive & | ar, |
const char * | label, | ||
DArray< Type > & | array, | ||
int | n, | ||
bool | isRequired | ||
) |
Add an load a DArray < Type > array parameter.
ar | archive for loading |
label | Label string for new array |
array | DArray object |
n | number of elements (logical size) |
isRequired | Is this a required parameter? |
Definition at line 1419 of file ParamComposite.h.
References addComponent(), isRequired(), Util::ArrayParam< Type >::load(), and setParent().
|
inline |
Add and load a required DArray< Type > array parameter.
Equivalent to loadDArrayParam < Type > (ar, label, array, n, true).
ar | archive for loading |
label | Label string for new array |
array | DArray object |
n | number of elements (logical size) |
Definition at line 1435 of file ParamComposite.h.
FArrayParam< Type, N > & Util::ParamComposite::loadFArray | ( | Serializable::IArchive & | ar, |
const char * | label, | ||
FArray< Type, N > & | array, | ||
bool | isRequired | ||
) |
Add and load an FArray < Type, N > fixed-size array parameter.
ar | archive for loading |
label | label string for new array |
array | FArray object |
isRequired | Is this a required parameter? |
Definition at line 1499 of file ParamComposite.h.
References addComponent(), isRequired(), Util::ArrayParam< Type >::load(), and setParent().
|
inline |
Add and load a required FArray < Type > array parameter.
Equivalent to loadFArrayParam < Type > (ar, label, array, true).
ar | archive for loading |
label | label string for new array |
array | FArray object |
Definition at line 704 of file ParamComposite.h.
FSArrayParam< Type, N > & Util::ParamComposite::loadFSArray | ( | Serializable::IArchive & | ar, |
const char * | label, | ||
FSArray< Type, N > & | array, | ||
int | size, | ||
bool | isRequired | ||
) |
Add and load an FSArray < Type, N > array parameter.
ar | archive for loading |
label | label string for new array |
array | FSArray object |
size | logical size of array (number of elements) |
isRequired | Is this a required parameter? |
Definition at line 1572 of file ParamComposite.h.
References addComponent(), isRequired(), Util::ArrayParam< Type >::load(), and setParent().
|
inline |
Add and load a required FSArray < Type > array parameter.
Equivalent to loadFSArrayParam < Type > (ar, label, array, size, true).
ar | archive for loading |
label | label string for new array |
array | FSArray object |
size | logical size of array (number of elements) |
Definition at line 736 of file ParamComposite.h.
CArray2DParam< Type > & Util::ParamComposite::loadCArray2D | ( | Serializable::IArchive & | ar, |
const char * | label, | ||
Type * | value, | ||
int | m, | ||
int | n, | ||
int | np, | ||
bool | isRequired | ||
) |
Add and load a CArray2DParam < Type > C 2D array parameter.
ar | archive for loading |
label | Label string for new array |
value | pointer to array |
m | number of rows (1st dimension) |
n | logical number of columns (2nd dimension) |
np | physical number of columns (elements allocated per row) |
isRequired | Is this a required parameter? |
Definition at line 1644 of file ParamComposite.h.
References addComponent(), isRequired(), Util::MatrixParam< Type >::load(), and setParent().
CArray2DParam< Type > & Util::ParamComposite::loadCArray2D | ( | Serializable::IArchive & | ar, |
const char * | label, | ||
Type * | value, | ||
int | m, | ||
int | n, | ||
int | np | ||
) |
Add and load a required < Type > matrix parameter.
Equivalent to loadCArray2DParam < Type > (ar, label, value, m, n, np, true).
ar | archive for loading |
label | Label string for new array |
value | pointer to array |
m | number of rows (1st dimension) |
n | logical number of columns (2nd dimension) |
np | physical number of columns (elements allocated per row) |
Definition at line 1662 of file ParamComposite.h.
DMatrixParam< Type > & Util::ParamComposite::loadDMatrix | ( | Serializable::IArchive & | ar, |
const char * | label, | ||
DMatrix< Type > & | matrix, | ||
int | m, | ||
int | n, | ||
bool | isRequired | ||
) |
Add and load a DMatrixParam < Type > matrix parameter.
ar | archive for loading |
label | Label string for new array |
matrix | DMatrix object |
m | number of rows (1st dimension) |
n | number of columns (2nd dimension) |
isRequired | Is this a required parameter? |
Definition at line 1725 of file ParamComposite.h.
References addComponent(), isRequired(), Util::MatrixParam< Type >::load(), and setParent().
|
inline |
Add and load a required DMatrixParam < Type > matrix parameter.
ar | archive for loading |
label | Label string for new array |
matrix | DMatrix object |
m | number of rows (1st dimension) |
n | number of columns (2nd dimension) |
Definition at line 1742 of file ParamComposite.h.
DSymmMatrixParam< Type > & Util::ParamComposite::loadDSymmMatrix | ( | Serializable::IArchive & | ar, |
const char * | label, | ||
DMatrix< Type > & | matrix, | ||
int | n, | ||
bool | isRequired | ||
) |
Add and load a symmetric DSymmMatrixParam < Type > matrix parameter.
ar | archive for loading |
label | Label string for new array |
matrix | DMatrix object |
n | number of rows or columns |
isRequired | Is this a required parameter? |
Definition at line 1794 of file ParamComposite.h.
References addComponent(), isRequired(), Util::MatrixParam< Type >::load(), and setParent().
|
inline |
Add and load a required DSymmMatrixParam < Type > matrix parameter.
ar | archive for loading |
label | Label string for new array |
matrix | DMatrix object |
n | number of rows or columns |
Definition at line 1813 of file ParamComposite.h.
void Util::ParamComposite::addParamComposite | ( | ParamComposite & | child, |
bool | next = true |
||
) |
Add a child ParamComposite object to the format array.
child | child ParamComposite object |
next | true if the indent level is one higher than parent. |
Definition at line 249 of file ParamComposite.cpp.
References addComponent(), and setParent().
Referenced by loadParamComposite(), loadParamCompositeOptional(), Util::Factory< Data >::readObject(), readParamComposite(), and readParamCompositeOptional().
Begin & Util::ParamComposite::addBegin | ( | const char * | label | ) |
Add a Begin object representing a class name and bracket.
label | class name string, without trailing bracket |
Definition at line 305 of file ParamComposite.cpp.
References addComponent(), and setParent().
Referenced by load().
End & Util::ParamComposite::addEnd | ( | ) |
Add a closing bracket.
Definition at line 333 of file ParamComposite.cpp.
References addComponent(), and setParent().
Blank & Util::ParamComposite::addBlank | ( | ) |
Create and add a new Blank object, representing a blank line.
Definition at line 356 of file ParamComposite.cpp.
References addComponent(), and setParent().
Referenced by readBlank().
|
inline |
Get class name string.
Definition at line 1195 of file ParamComposite.h.
Referenced by Util::Manager< Data >::beginReadManager(), Pscf::Pspc::FilmIterator< 1, IteratorType >::FilmIterator(), Pscf::Pspc::FilmIterator< 2, IteratorType >::FilmIterator(), Pscf::Pspc::FilmIterator< 3, IteratorType >::FilmIterator(), loadOptional(), Pscf::Fd1d::System::readParam(), Pscf::Fd1d::System::readParameters(), and setClassName().
|
inline |
Is this ParamComposite required in the input file?
Definition at line 1201 of file ParamComposite.h.
Referenced by add(), addCArray(), addCArray2D(), addDArray(), addDMatrix(), addFArray(), addFSArray(), loadCArray(), loadCArray2D(), loadDArray(), loadDMatrix(), loadDSymmMatrix(), loadFArray(), loadFSArray(), loadParameter(), readBegin(), and setIsRequired().
|
inline |
Is this parameter active?
Definition at line 1207 of file ParamComposite.h.
Referenced by setIsActive().
|
protected |
Set class name string.
Should be set in subclass constructor.
Definition at line 377 of file ParamComposite.cpp.
References className().
Referenced by Util::AutoCorr< Data, Product >::AutoCorr(), Util::AutoCorrArray< Data, Product >::AutoCorrArray(), Util::Average::Average(), Pscf::Fd1d::BinaryRelaxIterator::BinaryRelaxIterator(), Util::Distribution::Distribution(), Pscf::Fd1d::Domain::Domain(), Pscf::Pspc::Domain< D >::Domain(), Pscf::Pspg::Domain< D >::Domain(), Util::FileMaster::FileMaster(), Pscf::Pspc::FilmIterator< 1, IteratorType >::FilmIterator(), Pscf::Pspc::FilmIterator< 2, IteratorType >::FilmIterator(), Pscf::Pspc::FilmIterator< 3, IteratorType >::FilmIterator(), Pscf::Pspc::FilmIteratorBase< D, IteratorType >::FilmIteratorBase(), Util::IntDistribution::IntDistribution(), Pscf::Interaction::Interaction(), Pscf::Fd1d::Iterator::Iterator(), Pscf::Pspc::Iterator< D >::Iterator(), Pscf::Pspg::Iterator< D >::Iterator(), Pscf::Fd1d::Mixture::Mixture(), Pscf::Homogeneous::Mixture::Mixture(), Pscf::Pspc::Mixture< D >::Mixture(), Pscf::Pspg::Mixture< D >::Mixture(), Pscf::Homogeneous::Molecule::Molecule(), Pscf::Fd1d::NrIterator::NrIterator(), Pscf::Fd1d::Polymer::Polymer(), Pscf::PolymerTmpl< Block >::PolymerTmpl(), Util::RadialDistribution::RadialDistribution(), Util::Random::Random(), Pscf::Fd1d::Solvent::Solvent(), Pscf::Pspc::Solvent< D >::Solvent(), Pscf::SolventDescriptor::SolventDescriptor(), Pscf::Fd1d::Sweep::Sweep(), Pscf::SweepTmpl< State >::SweepTmpl(), Util::SymmTensorAverage::SymmTensorAverage(), Pscf::Fd1d::System::System(), Pscf::Pspc::System< D >::System(), Pscf::Pspg::System< D >::System(), and Util::TensorAverage::TensorAverage().
|
protected |
Set or unset the isActive flag.
Required to re-implement readParam[Optional].
isRequired | flag to set true or false. |
Definition at line 383 of file ParamComposite.cpp.
References isRequired().
|
protected |
Set or unset the isActive flag.
Required to re-implement readParam[Optional].
isActive | flag to set true or false. |
Definition at line 394 of file ParamComposite.cpp.
References isActive(), and UTIL_THROW.
|
protected |
Set this to the parent of a child component.
This function sets the indent and (ifdef UTIL_MPI) the ioCommunicator of the child component.
param | child ParamComponent |
next | if true, set indent level one higher than for parent. |
Definition at line 224 of file ParamComposite.cpp.
References Util::MpiFileIo::hasIoCommunicator(), Util::MpiFileIo::ioCommunicator(), Util::ParamComponent::setIndent(), and Util::MpiFileIo::setIoCommunicator().
Referenced by add(), addBegin(), addBlank(), addCArray(), addCArray2D(), addDArray(), addDMatrix(), addEnd(), addFArray(), addFSArray(), addParamComposite(), loadCArray(), loadCArray2D(), loadDArray(), loadDMatrix(), loadDSymmMatrix(), loadFArray(), loadFSArray(), loadParameter(), and readBegin().
|
protected |
Add a new ParamComponent object to the format array.
param | Parameter object |
isLeaf | Is this a leaf or a ParamComposite node? |
Definition at line 237 of file ParamComposite.cpp.
Referenced by add(), addBegin(), addBlank(), addCArray(), addCArray2D(), addDArray(), addDMatrix(), addEnd(), addFArray(), addFSArray(), addParamComposite(), loadCArray(), loadCArray2D(), loadDArray(), loadDMatrix(), loadDSymmMatrix(), loadFArray(), loadFSArray(), loadParameter(), and readBegin().
|
protected |
Add a new required ScalarParam < Type > object.
in | input stream for reading |
label | Label string |
value | reference to new ScalarParam< Type > |
isRequired | Is this a required parameter? |
Definition at line 1233 of file ParamComposite.h.
References addComponent(), isRequired(), and setParent().
|
protected |
Add (but do not read) a required C array parameter.
in | input stream for reading |
label | Label string for new array |
value | pointer to array |
n | number of elements |
isRequired | Is this a required parameter? |
Definition at line 1308 of file ParamComposite.h.
References addComponent(), isRequired(), and setParent().
|
protected |
Add (but do not read) a DArray < Type > parameter.
in | input stream for reading |
label | Label string for new array |
array | DArray object |
n | number of elements |
isRequired | Is this a required parameter? |
Definition at line 1384 of file ParamComposite.h.
References addComponent(), isRequired(), and setParent().
|
protected |
Add (but do not read) a FArray < Type, N > array parameter.
in | input stream for reading |
label | Label string for new array |
array | FArray object |
isRequired | Is this a required parameter? |
Definition at line 1464 of file ParamComposite.h.
References addComponent(), isRequired(), and setParent().
|
protected |
Add (but do not read) a FSArray < Type, N > array parameter.
in | input stream for reading |
label | Label string for new array |
array | FSArray object |
size | logical size (number of elements) |
isRequired | Is this a required parameter? |
Definition at line 1534 of file ParamComposite.h.
References addComponent(), isRequired(), and setParent().
|
protected |
Add (but do not read) a CArray2DParam < Type > 2D C-array.
in | input stream for reading |
label | Label string for new array |
value | pointer to array |
m | number of rows (1st dimension) |
n | logical number of columns (2nd dimension) |
np | physical number of columns (elements allocated per row) |
isRequired | Is this a required parameter? |
Definition at line 1609 of file ParamComposite.h.
References addComponent(), isRequired(), and setParent().
|
protected |
Add and read a required DMatrix < Type > matrix parameter.
in | input stream for reading |
label | Label string for new array |
matrix | DMatrix object |
m | number of rows (1st dimension) |
n | number of columns (2nd dimension) |
isRequired | Is this a required parameter? |
Definition at line 1691 of file ParamComposite.h.
References addComponent(), isRequired(), and setParent().