11#include <util/param/ParamComposite.h>
12#include <util/param/Factory.h>
37 template <
typename Data>
136 void append(Data& data,
const std::string& name);
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>
424 if (hasIoCommunicator()) {
425 bcast<int>(ioCommunicator(),
size, 0);
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) {
527 template <
typename Data>
532 createdFactory_ =
true;
540 template <
typename Data>
543 UTIL_THROW(
"Call of un-implemented Manager<Data>::newDefaultFactory");
Beginning line of a composite parameter block.
bool isActive() const
Is this an active element (has it been read from file)?
End bracket of a ParamComposite parameter block.
virtual void writeParam(std::ostream &out) const
Write the closing bracket.
static std::ostream & file()
Get log ostream by reference.
Factory< Data > * factoryPtr_
Pointer to an associated Factory<Data> object.
void setFactory(Factory< Data > &factory)
Associate a Factory with this Manager.
virtual void readParam(std::istream &in)
Read and create a set of objects.
Factory< Analyzer< D > > & factory()
virtual void initFactory()
Create factory if necessary.
Data * findFirst(std::string const &className)
Return pointer to first object with specified class name.
virtual Factory< Data > * newDefaultFactory() const
Create an instance of the default Factory<Data> class.
virtual ~Manager()
Destructor.
bool hasFactory() const
Return true if this Manager has a Factory, false otherwise.
virtual void readParameters(std::istream &in)
Read child blocks, return when closing bracket encountered.
virtual void loadParameters(Serializable::IArchive &ar)
Load a set of objects to an output archive.
virtual void save(Serializable::OArchive &ar)
Save a set of objects to an output archive.
void beginReadManager(std::istream &in)
Read (or attempt to read) opening line: "ManagerName{".
virtual void readParamOptional(std::istream &in)
Optionally read and create a set of objects.
Data & operator[](int i) const
Mimic C array subscripting.
void addSubfactory(Factory< Data > &subfactory)
Set a SubFactory for this Manager.
int size() const
Get logical size.
void append(Data &data, const std::string &name)
Append a Data object to the end of the sequence.
void endReadManager()
Add closing bracket to output format.
std::string className(int i) const
Get the subclass name for object number i.
Manager(bool uniqueNames=false)
Constructor.
bool isIoProcessor() const
Can this processor do file I/O ?
static bool echo()
Get echo parameter.
Begin & readBegin(std::istream &in, const char *label, bool isRequired=true)
Add and read a class label and opening bracket.
void setIsRequired(bool isRequired)
Set or unset the isActive flag.
void setIsActive(bool isActive)
Set or unset the isActive flag.
Blank & addBlank()
Create and add a new Blank object, representing a blank line.
bool isActive() const
Is this parameter active?
End & addEnd()
Add a closing bracket.
ParamComposite()
Constructor.
std::string className() const
Get class name string.
Blank & readBlank(std::istream &in)
Add and read a new Blank object, representing a blank line.
bool isRequired() const
Is this ParamComposite required in the input file?
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.