PSCF v1.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Util::ParamComponent Class Referenceabstract

Abstract base class for classes that input and ouput parameters to file. More...

#include <ParamComponent.h>

Inheritance diagram for Util::ParamComponent:
Util::Serializable Util::MpiFileIo Util::Begin Util::Blank Util::End Util::ParamComposite Util::Parameter Pscf::MixtureTmpl< Polymer, Solvent > Pscf::MixtureTmpl< Polymer< D >, Solvent< D > > Pscf::PolymerTmpl< Block< D > > Pscf::SweepTmpl< DArray< System::WField > > Pscf::SweepTmpl< BasisFieldState< D > > Pscf::Fd1d::Domain Pscf::Fd1d::Iterator Pscf::Fd1d::System Pscf::Homogeneous::Mixture Pscf::Homogeneous::Molecule Pscf::Interaction Pscf::MixtureTmpl< TP, TS > Pscf::PolymerTmpl< Block > Pscf::Pspc::Domain< D > Pscf::Pspc::Iterator< D > Pscf::Pspc::Mask< D > Pscf::Pspc::System< D > Pscf::Pspc::WFieldContainer< D > Pscf::Pspg::Domain< D > Pscf::Pspg::Iterator< D > Pscf::Pspg::System< D > Pscf::Pspg::WFieldContainer< D > Pscf::SolventDescriptor Pscf::SweepTmpl< State > Util::AutoCorr< Data, Product > Util::AutoCorrArray< Data, Product > Util::AutoCorrelation< Data, Product > Util::Average Util::Distribution Util::FileMaster Util::IntDistribution Util::Manager< Data > Util::MeanSqDispArray< Data > Util::Random Util::SymmTensorAverage Util::TensorAverage Util::ArrayParam< Type > Util::MatrixParam< Type > Util::ScalarParam< Type >

Public Member Functions

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...
 
- Public Member Functions inherited from Util::Serializable
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...
 
- Public Member Functions inherited from Util::MpiFileIo
 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...
 

Static Public Member Functions

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...
 

Protected Member Functions

 ParamComponent ()
 Constructor. More...
 
 ParamComponent (const ParamComponent &other)
 Copy constructor. More...
 

Additional Inherited Members

- Public Types inherited from Util::Serializable
typedef BinaryFileOArchive OArchive
 Type of output archive used by save method. More...
 
typedef BinaryFileIArchive IArchive
 Type of input archive used by load method. More...
 

Detailed Description

Abstract base class for classes that input and ouput parameters to file.

The readParam method reads a parameter or parameter list from iostream. The writeParam method writes a parameter or parameter list to an ostream. The same io format should be used by write and read methods.

Definition at line 31 of file ParamComponent.h.

Constructor & Destructor Documentation

◆ ~ParamComponent()

Util::ParamComponent::~ParamComponent ( )
virtual

Destructor.

Definition at line 36 of file ParamComponent.cpp.

◆ ParamComponent() [1/2]

Util::ParamComponent::ParamComponent ( )
protected

Constructor.

Protected to prevent instantiation of a conceptually abstract class.

On return the indent string is empty. If UTIL_MPI is defined, no communicator is set upon construction.

Definition at line 20 of file ParamComponent.cpp.

◆ ParamComponent() [2/2]

Util::ParamComponent::ParamComponent ( const ParamComponent other)
protected

Copy constructor.

Definition at line 28 of file ParamComponent.cpp.

Member Function Documentation

◆ readParam()

virtual void Util::ParamComponent::readParam ( std::istream &  in)
pure virtual

Read parameter(s) from file.

Parameters
ininput stream

Implemented in Pscf::Fd1d::System, Pscf::Pspc::System< D >, Pscf::Pspg::System< D >, Util::Begin, Util::Blank, Util::End, Util::Manager< Data >, Util::ParamComposite, and Util::Parameter.

Referenced by serialize().

◆ writeParam()

virtual void Util::ParamComponent::writeParam ( std::ostream &  out) const
pure virtual

◆ load()

virtual void Util::ParamComponent::load ( Serializable::IArchive ar)
inlinevirtual

Load internal state from an archive.

The default implementation is empty. This default is used by the Begin, End, and Blank subclasses.

Implements Util::Serializable.

Reimplemented in Util::AutoCorrelation< Data, Product >, Util::ArrayParam< Type >, Util::MatrixParam< Type >, Util::ParamComposite, and Util::Parameter.

Definition at line 61 of file ParamComponent.h.

◆ save()

virtual void Util::ParamComponent::save ( Serializable::OArchive ar)
inlinevirtual

◆ resetParam()

virtual void Util::ParamComponent::resetParam ( )
inlinevirtual

Nontrivial implementation provided by ParamComposite subclass.

The default implementation is empty. This default is used by all leaf nodes (all other than ParamComposite and subclasses).

Reimplemented in Util::Begin, Util::End, and Util::ParamComposite.

Definition at line 79 of file ParamComponent.h.

◆ setIndent()

void Util::ParamComponent::setIndent ( const ParamComponent parent,
bool  next = true 
)

Set indent level.

If next=true (default) set indent level one higher than that of parent. If next=false, set indent level the same as parent.

Parameters
parentparent ParamComponent object
nextIf true, set level one higher than for parent.

Definition at line 48 of file ParamComponent.cpp.

References indent().

Referenced by Util::Factory< Data >::readObject(), and Util::ParamComposite::setParent().

◆ indent()

std::string Util::ParamComponent::indent ( ) const

◆ serialize()

template<class Archive >
void Util::ParamComponent::serialize ( Archive &  ar,
const unsigned int  version 
)

Serialize this ParamComponent as a string.

Parameters
arsaving or loading archive
versionversion id for archive

Definition at line 177 of file ParamComponent.h.

References readParam(), and writeParam().

◆ initStatic()

void Util::ParamComponent::initStatic ( )
static

Initialize static echo member to false.

Definition at line 77 of file ParamComponent.cpp.

Referenced by Util::initStatic().

◆ setEcho()

void Util::ParamComponent::setEcho ( bool  echo = true)
static

Enable or disable echoing for all subclasses of ParamComponent.

When echoing is enabled, all parameters are echoed to a log file immediately after being read. This is useful as an aid to debugging the parameter file, by showing where the error occurred.

Parameters
echoset true to enable echoing, false to disable.

Definition at line 62 of file ParamComponent.cpp.

References echo().

Referenced by Pscf::Fd1d::System::setOptions(), Pscf::Pspc::System< D >::setOptions(), and Pscf::Pspg::System< D >::setOptions().

◆ echo()

bool Util::ParamComponent::echo ( )
static

The documentation for this class was generated from the following files: