8 #include "ParamComposite.h" 28 className_(
"ParamComposite"),
41 className_(
"ParamComposite"),
46 UTIL_THROW(
"Attempt to reserve capacity <= 0");
48 list_.reserve(capacity);
49 isLeaf_.reserve(capacity);
60 className_(other.className_),
71 for (
int i=0; i < size_; ++i) {
90 assert(className_.size() > 0);
103 assert(className_.size() > 0);
106 Begin* beginPtr = &
readBegin(in, className_.c_str(), isRequired_);
122 for (
int i=0; i < size_; ++i) {
123 list_[i]->writeParam(out);
133 assert(className_.size() > 0);
167 UTIL_THROW(
"Error: not isIoProcessor and not hasIoCommunicator");
170 UTIL_THROW(
"Error: not isIoProcessor and no MPI");
190 for (
int i=0; i < size_; ++i) {
211 for (
int i=0; i < size_; ++i) {
215 list_[i]->resetParam();
239 list_.push_back(¶m);
240 isLeaf_.push_back(isLeaf);
396 if (isRequired_ && !isActive) {
397 UTIL_THROW(
"Error: cannot be required but not active");
virtual void loadOptional(Serializable::IArchive &ar)
Load an optional ParamComposite.
End bracket of a ParamComposite parameter block.
ParamComposite()
Constructor.
An empty line within a parameter file.
bool isRequired() const
Is this ParamComposite required in the input file?
void setIoCommunicator(MPI::Intracomm &communicator)
Set the communicator.
void resetParam()
Resets ParamComposite to its empty state.
virtual void readParamOptional(std::istream &in)
Read optional parameter file block.
virtual void readParam(std::istream &in)
Read a blank line.
void setParent(ParamComponent ¶m, bool next=true)
Set this to the parent of a child component.
void loadParamComposite(Serializable::IArchive &ar, ParamComposite &child, bool next=true)
Add and load a required child ParamComposite.
End & readEnd(std::istream &in)
Add and read the closing bracket.
void saveOptional(Serializable::OArchive &ar)
Saves isActive flag, and then calls save() iff isActive is true.
File containing preprocessor macros for error handling.
void setIsActive(bool isActive)
Set or unset the isActive flag.
Blank & readBlank(std::istream &in)
Add and read a new Blank object, representing a blank line.
void bcast< bool >(MPI::Intracomm &comm, bool &data, int root)
Explicit specialization of bcast for bool data.
End & addEnd()
Add a closing bracket.
bool isActive() const
Is this parameter active?
Saving / output archive for binary ostream.
void addComponent(ParamComponent ¶m, bool isLeaf=true)
Add a new ParamComponent object to the format array.
void loadParamCompositeOptional(Serializable::IArchive &ar, ParamComposite &child, bool next=true)
Add and load an optional child ParamComposite if isActive.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
std::string className() const
Get class name string.
MPI::Intracomm & ioCommunicator() const
Get the MPI communicator by reference.
virtual void writeParam(std::ostream &out)
Write all parameters to an output stream.
virtual void save(Serializable::OArchive &ar)
Saves all parameters to an archive.
virtual ~ParamComposite()
Virtual destructor.
Utility classes for scientific computation.
static bool echo()
Get echo parameter.
Begin & addBegin(const char *label)
Add a Begin object representing a class name and bracket.
virtual void writeParam(std::ostream &out)
Write the opening line.
bool isIoProcessor() const
Can this processor do file I/O ?
virtual void readParameters(std::istream &in)
Read the body of parameter block, without begin and end lines.
virtual void writeParam(std::ostream &out)
Write the closing bracket.
Abstract base class for classes that input and ouput parameters to file.
virtual void loadParameters(Serializable::IArchive &ar)
Load state from archive, without adding Begin and End lines.
void setIndent(const ParamComponent &parent, bool next=true)
Set indent level.
void readParamCompositeOptional(std::istream &in, ParamComposite &child, bool next=true)
Add and attempt to read an optional child ParamComposite.
static std::ostream & file()
Get log ostream by reference.
bool hasIoCommunicator() const
Does this object have an associated MPI communicator?
virtual void load(Serializable::IArchive &ar)
Load all parameters from an input archive.
Saving archive for binary istream.
virtual void readParam(std::istream &in)
Read the parameter file block.
virtual void readParam(std::istream &in)
Read the closing bracket.
void addParamComposite(ParamComposite &child, bool next=true)
Add a child ParamComposite object to the format array.
bool isActive() const
Is this an active element (has it been read from file)?
void setClassName(const char *className)
Set class name string.
void readParamComposite(std::istream &in, ParamComposite &child, bool next=true)
Add and read a required child ParamComposite.
Begin & readBegin(std::istream &in, const char *label, bool isRequired=true)
Add and read a class label and opening bracket.
virtual void readParam(std::istream &in)
Read the opening line.
An object that can read multiple parameters from file.
Blank & addBlank()
Create and add a new Blank object, representing a blank line.
std::string indent() const
Return indent string for this object (string of spaces).
void setIsRequired(bool isRequired)
Set or unset the isActive flag.
Beginning line of a composite parameter block.