11 #include <util/param/ParamComposite.h> 12 #include <util/param/Factory.h> 37 template <
typename Data>
48 Manager(
bool uniqueNames =
false);
136 void append(Data& data,
const std::string& name);
177 Data*
findFirst(std::string
const & className);
209 std::vector<Data*> ptrs_;
212 std::vector<std::string> names_;
224 bool createdFactory_;
231 template <
typename Data>
238 uniqueNames_(uniqueNames),
239 createdFactory_(false)
245 template <
typename Data>
249 for (
int i=0; i < size_; ++i) {
264 template <
typename Data>
274 template <
typename Data>
277 factory().addSubfactory(subfactory);
283 template <
typename Data>
288 createdFactory_ =
false;
296 template <
typename Data>
301 createdFactory_ =
false;
309 template <
typename Data>
322 template <
typename Data>
337 template <
typename Data>
355 template <
typename Data>
372 typePtr =
factoryPtr_->readObject(in, *
this, name, isEnd);
379 std::string msg(
"Non-unique subclass name: ");
386 std::string msg(
"Unknown subclass name: ");
398 template <
typename Data>
410 template <
typename Data>
429 for (
int i = 0; i <
size; ++i) {
432 typePtr =
factoryPtr_->loadObject(ar, *
this, name);
436 std::string msg(
"Unknown subclass name: ");
447 template <
typename Data>
450 int size = ptrs_.size();
452 for (
int i = 0; i <
size; ++i) {
454 (ptrs_[i])->
save(ar);
461 template <
typename Data>
464 ptrs_.push_back(&data);
465 names_.push_back(name);
472 template <
typename Data>
484 template <
typename Data>
493 template <
typename Data>
500 template <
typename Data>
511 template <
typename Data>
514 for (
int i = 0; i < size_; ++i) {
515 if (names_[i] == className) {
527 template <
typename Data>
532 createdFactory_ =
true;
540 template <
typename Data>
543 UTIL_THROW(
"Call of un-implemented Manager<Data>::newDefaultFactory");
virtual void loadParameters(Serializable::IArchive &ar)
Load a set of objects to an output archive.
Manager(bool uniqueNames=false)
Constructor.
End bracket of a ParamComposite parameter block.
virtual void save(Serializable::OArchive &ar)
Save a set of objects to an output archive.
void append(Data &data, const std::string &name)
Append a Data object to the end of the sequence.
virtual ~Manager()
Destructor.
bool isRequired() const
Is this ParamComposite required in the input file?
virtual void initFactory()
Create factory if necessary.
Factory< Data > * factoryPtr_
Pointer to an associated Factory<Data> object.
void beginReadManager(std::istream &in)
Read (or attempt to read) opening line: "ManagerName{".
Factory< Data > & factory()
Return a reference to the factory.
Data & operator[](int i) const
Mimic C array subscripting.
virtual void readParamOptional(std::istream &in)
Optionally read and create a set of objects.
File containing preprocessor macros for error handling.
void endReadManager()
Add closing bracket to output format.
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.
virtual void readParam(std::istream &in)
Read and create a set of objects.
End & addEnd()
Add a closing bracket.
bool isActive() const
Is this parameter active?
Saving / output archive for binary ostream.
virtual Factory< Data > * newDefaultFactory() const
Create an instance of the default Factory<Data> class.
#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.
Template container for pointers to objects with a common base class.
Data * findFirst(std::string const &className)
Return pointer to first object with specified class name.
Utility classes for scientific computation.
static bool echo()
Get echo parameter.
bool isIoProcessor() const
Can this processor do file I/O ?
virtual void writeParam(std::ostream &out)
Write the closing bracket.
virtual void readParameters(std::istream &in)
Read child blocks, return when closing bracket encountered.
static std::ostream & file()
Get log ostream by reference.
bool hasIoCommunicator() const
Does this object have an associated MPI communicator?
Saving archive for binary istream.
void addSubfactory(Factory< Data > &subfactory)
Set a SubFactory for this Manager.
bool isActive() const
Is this an active element (has it been read from file)?
Begin & readBegin(std::istream &in, const char *label, bool isRequired=true)
Add and read a class label and opening bracket.
bool hasFactory() const
Return true if this Manager has a Factory, false otherwise.
int size() const
Get logical size.
An object that can read multiple parameters from file.
Blank & addBlank()
Create and add a new Blank object, representing a blank line.
void setIsRequired(bool isRequired)
Set or unset the isActive flag.
Beginning line of a composite parameter block.
void setFactory(Factory< Data > &factory)
Associate a Factory with this Manager.