PSCF v1.3
Util::CArray2DParam< Type > Class Template Reference

A Parameter associated with a 2D built-in C array. More...

#include <CArray2DParam.h>

Inheritance diagram for Util::CArray2DParam< Type >:
Util::MatrixParam< Type > Util::Parameter Util::ParamComponent Util::Serializable Util::MpiFileIo

Public Member Functions

 CArray2DParam (const char *label, Type *ptr, int m, int n, int np, bool isRequired=true)
 Constructor.
void writeParam (std::ostream &out) const
 Write 2D C array to file.
std::string indent () const
 Return indent string for this object (string of spaces).
bool isActive () const
 Is this parameter active?
Public Member Functions inherited from Util::MatrixParam< Type >
 MatrixParam (const char *label, int m, int n, bool isRequired=true)
 Constructor.
virtual ~MatrixParam ()
 Destructor.
int m () const
 Get the logical array dimension.
int n () const
 Get the logical array dimension.
std::string indent () const
 Return indent string for this object (string of spaces).
virtual void readValue (std::istream &in)
 Read parameter value from an input stream.
virtual void load (Serializable::IArchive &ar)
 Load from an archive.
virtual void save (Serializable::OArchive &ar)
 Save to an archive.
std::string label () const
 Return label string.
bool isRequired () const
 Is this an optional parameter?
bool isActive () const
 Is this parameter active?
Public Member Functions inherited from Util::Parameter
 Parameter (const char *label, bool isRequired=true)
 Constructor.
virtual ~Parameter ()
 Destructor.
virtual void readParam (std::istream &in)
 Read a label and (if the label matches) a parameter value.
std::string label () const
 Return label string.
bool isRequired () const
 Is this an optional parameter?
bool isActive () const
 Is this parameter active?
Public Member Functions inherited from Util::ParamComponent
virtual ~ParamComponent ()
 Destructor.
virtual void resetParam ()
 Nontrivial implementation provided by ParamComposite subclass.
void setIndent (const ParamComponent &parent, bool next=true)
 Set indent level.
std::string indent () const
 Return indent string for this object (string of spaces).
template<class Archive>
void serialize (Archive &ar, const unsigned int version)
 Serialize this ParamComponent as a string.
Public Member Functions inherited from Util::Serializable
virtual ~Serializable ()
 Destructor.
Public Member Functions inherited from Util::MpiFileIo
 MpiFileIo ()
 Constructor.
 MpiFileIo (const MpiFileIo &other)
 Copy constructor.
bool isIoProcessor () const
 Can this processor do file I/O ?

Protected Member Functions

virtual void readValue (std::istream &in)
 Read 2D array parameter from an input stream.
virtual void loadValue (Serializable::IArchive &ar)
 Load 2D array from an archive.
virtual void saveValue (Serializable::OArchive &ar)
 Save 2D array to an archive.
Protected Member Functions inherited from Util::MatrixParam< Type >
virtual void readLabel (std::istream &in)
 Read parameter label from an input stream.
void readEndBracket (std::istream &in)
 Read the closing delimiter, if any.
void writeEndBracket (std::ostream &out) const
 Write the end bracket delimiter, if any.
bool hasBrackets () const
 Are brackets being used as delimiters?
void setBrackets (std::string lBracket, std::string rBracket)
 Set left and right bracket / delimiter strings.
Protected Member Functions inherited from Util::ParamComponent
 ParamComponent ()
 Constructor.
 ParamComponent (const ParamComponent &other)
 Copy constructor.

Additional Inherited Members

Public Types inherited from Util::Serializable
typedef BinaryFileOArchive OArchive
 Type of output archive used by save method.
typedef BinaryFileIArchive IArchive
 Type of input archive used by load method.
Static Public Member Functions inherited from Util::Parameter
template<class Type>
static void saveOptional (Serializable::OArchive &ar, Type &value, bool isActive)
 Save an optional parameter value to an output archive.
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.
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.
Static Public Member Functions inherited from Util::ParamComponent
static void initStatic ()
 Initialize static echo member to false.
static void setEcho (bool echo=true)
 Enable or disable echoing for all subclasses of ParamComponent.
static bool echo ()
 Get echo parameter.
Static Public Attributes inherited from Util::Parameter
static const int Width = 20
 Width of output field for a scalar variable.
static const int Precision = 12
 Precision for io of floating point data field.
Protected Attributes inherited from Util::MatrixParam< Type >
Label label_
 Label object that contains parameter label string.
Protected Attributes inherited from Util::Parameter
Label label_
 Label object that contains parameter label string.
bool isActive_
 Is this parameter active (always true if isRequired).

Detailed Description

template<class Type>
class Util::CArray2DParam< Type >

A Parameter associated with a 2D built-in C array.

Definition at line 29 of file CArray2DParam.h.

Constructor & Destructor Documentation

◆ CArray2DParam()

template<class Type>
Util::CArray2DParam< Type >::CArray2DParam ( const char * label,
Type * ptr,
int m,
int n,
int np,
bool isRequired = true )

Constructor.

Example: A 2 X 2 matrix stored in an oversized 3 x 3 C array.

double matrix[3][3];
CArray2DParam<double> param("matrix", matrix[0], 2, 2, 3);
CArray2DParam(const char *label, Type *ptr, int m, int n, int np, bool isRequired=true)
Constructor.
Parameters
labelparameter label (usually a literal C-string)
ptrpointer to first element of first row of 2D array
mlogical number of rows
nlogical number of columns
npphysical number of columns (allocated elements per row).
isRequiredIs this a required parameter?

Definition at line 112 of file CArray2DParam.h.

References Util::MatrixParam< Type >::isRequired(), Util::MatrixParam< Type >::label(), Util::MatrixParam< Type >::m(), Util::MatrixParam< Type >::MatrixParam(), Util::MatrixParam< Type >::n(), and Util::MatrixParam< Type >::setBrackets().

Member Function Documentation

◆ writeParam()

template<class Type>
void Util::CArray2DParam< Type >::writeParam ( std::ostream & out) const
virtual

◆ readValue()

template<class Type>
void Util::CArray2DParam< Type >::readValue ( std::istream & in)
protectedvirtual

Read 2D array parameter from an input stream.

Parameters
ininput stream from which to read

Reimplemented from Util::Parameter.

Definition at line 127 of file CArray2DParam.h.

References Util::MatrixParam< Type >::m(), Util::MatrixParam< Type >::n(), and Util::MatrixParam< Type >::readEndBracket().

◆ loadValue()

template<class Type>
void Util::CArray2DParam< Type >::loadValue ( Serializable::IArchive & ar)
protectedvirtual

Load 2D array from an archive.

Parameters
arinput archive from which to load

Reimplemented from Util::Parameter.

Definition at line 142 of file CArray2DParam.h.

References Util::MatrixParam< Type >::m(), Util::MatrixParam< Type >::n(), and Util::BinaryFileIArchive::unpack().

◆ saveValue()

template<class Type>
void Util::CArray2DParam< Type >::saveValue ( Serializable::OArchive & ar)
protectedvirtual

Save 2D array to an archive.

Parameters
aroutput archive to which to save

Reimplemented from Util::Parameter.

Definition at line 149 of file CArray2DParam.h.

References Util::MatrixParam< Type >::m(), Util::MatrixParam< Type >::n(), and Util::BinaryFileOArchive::pack().

◆ indent()

template<class Type>
std::string Util::ParamComponent::indent ( ) const

Return indent string for this object (string of spaces).

Definition at line 96 of file ParamComponent.cpp.

Referenced by writeParam().

◆ isActive()

template<class Type>
bool Util::Parameter::isActive ( ) const

Is this parameter active?

Definition at line 180 of file Parameter.cpp.

Referenced by writeParam().


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