1#ifndef UTIL_D_ARRAY_PARAM_H
2#define UTIL_D_ARRAY_PARAM_H
11#include <util/param/ArrayParam.h>
12#include <util/containers/DArray.h>
25 template <
typename Type>
57 {
return (*arrayPtr_)[i]; }
63 {
return (*arrayPtr_)[i]; }
90 virtual void bcastValue();
105 template <
class Type>
116 template <
class Type>
120 if (!(arrayPtr_->isAllocated())) {
121 UTIL_THROW(
"Cannot write unallocated DArray");
123 if (arrayPtr_->capacity() !=
n()) {
124 UTIL_THROW(
"Error: DArray capacity != n in writeParam");
133 template <
class Type>
136 if (!(arrayPtr_->isAllocated())) {
139 if (arrayPtr_->capacity() !=
n()) {
148 template <
class Type>
151 if (!(arrayPtr_->isAllocated())) {
152 arrayPtr_->allocate(
n());
155 if (arrayPtr_->capacity() <
n()) {
163 template <
class Type>
166 if (!(arrayPtr_->isAllocated())) {
169 if (arrayPtr_->capacity() !=
n()) {
179 template <
class Type>
181 { bcast<Type>(ioCommunicator(), *arrayPtr_, n(), 0); }
An array-valued parameter in a parameter file.
int n() const
Get the logical array dimension.
ArrayParam(const char *label, int n, bool isRequired=true)
Constructor.
std::string label() const
Return label string.
void writeParam(std::ostream &out) const
Write an array-valued parameter to stream.
virtual void readValue(std::istream &in)
Read array of element values from an input stream.
bool isRequired() const
Is this an optional parameter?
A Parameter associated with a DArray container.
Type & element(int i)
Return a reference to one element of the array.
virtual void loadValue(Serializable::IArchive &ar)
Load bare parameter value from an archive.
void writeParam(std::ostream &out) const
Write parameter to stream.
virtual void saveValue(Serializable::OArchive &ar)
Save parameter value to an archive.
Type const & element(int i) const
Return a reference to one element of the array.
DArrayParam(const char *label, DArray< Type > &array, int n, bool isRequired=true)
Constructor.
virtual void readValue(std::istream &in)
Read parameter value from an input stream.
Dynamically allocatable contiguous array template.
virtual void readParam(std::istream &in)
Read a label and (if the label matches) a parameter value.
bool isActive() const
Is this parameter active?
BinaryFileIArchive IArchive
Type of input archive used by load method.
BinaryFileOArchive OArchive
Type of output archive used by save method.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.