| [ee50c1] | 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * FormatParser_Parameters.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: Sep 30, 2011
|
|---|
| 12 | * Author: heber
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 21 |
|
|---|
| 22 | #include <string>
|
|---|
| 23 |
|
|---|
| 24 | #include "Parameters/Parameter.hpp"
|
|---|
| 25 | #include "FormatParser_Parameters.hpp"
|
|---|
| 26 |
|
|---|
| 27 | /** Constructor of class FormatParser_Parameters.
|
|---|
| 28 | *
|
|---|
| 29 | * \note we make sure that storage is always present
|
|---|
| 30 | *
|
|---|
| 31 | */
|
|---|
| 32 | FormatParser_Parameters::FormatParser_Parameters() :
|
|---|
| 33 | storage(new ParameterStorage)
|
|---|
| 34 | {}
|
|---|
| 35 |
|
|---|
| 36 | /** Copy constructor of class FormatParser_Parameters.
|
|---|
| 37 | *
|
|---|
| 38 | * @param _parameters instance to copy from
|
|---|
| 39 | */
|
|---|
| 40 | FormatParser_Parameters::FormatParser_Parameters(const FormatParser_Parameters &_parameters) :
|
|---|
| 41 | storage(new ParameterStorage(*_parameters.storage))
|
|---|
| 42 | {}
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | /** Destructor of class FormatParser_Parameters.
|
|---|
| 46 | *
|
|---|
| 47 | */
|
|---|
| 48 | FormatParser_Parameters::~FormatParser_Parameters()
|
|---|
| 49 | {
|
|---|
| 50 | delete storage;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | /** Implements the Parameter::clone() function.
|
|---|
| 54 | *
|
|---|
| 55 | * @return another instance with an identical copy of each parameter in \a storage
|
|---|
| 56 | */
|
|---|
| 57 | FormatParser_Parameters* FormatParser_Parameters::clone() const
|
|---|
| 58 | {
|
|---|
| 59 | return (new FormatParser_Parameters(*this));
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | /** This makes this instance a clone of \a _instance.
|
|---|
| 63 | *
|
|---|
| 64 | * \note This is basically the other way round to clone().
|
|---|
| 65 | *
|
|---|
| 66 | * @param _instance instance to clone from
|
|---|
| 67 | */
|
|---|
| 68 | void FormatParser_Parameters::makeClone(const FormatParser_Parameters &_instance)
|
|---|
| 69 | {
|
|---|
| 70 | // we simply remove storage
|
|---|
| 71 | delete storage;
|
|---|
| 72 | // and clone the one from _instance
|
|---|
| 73 | storage = new ParameterStorage(*_instance.storage);
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | /** Adds a parameter to \a storage.
|
|---|
| 77 | *
|
|---|
| 78 | * This just eases use, saves some typing and is more clear as to what is done.
|
|---|
| 79 | *
|
|---|
| 80 | * @param instance parameter to add
|
|---|
| 81 | */
|
|---|
| 82 | void FormatParser_Parameters::appendParameter(Parameter *instance)
|
|---|
| 83 | {
|
|---|
| 84 | storage->registerInstance(instance);
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | /** Checks for presence of a parameter in \a storage.
|
|---|
| 88 | *
|
|---|
| 89 | * This just eases use, saves some typing and is more clear as to what is done.
|
|---|
| 90 | *
|
|---|
| 91 | * @return true - parameter by this \a _name is present in storage, false - else
|
|---|
| 92 | */
|
|---|
| 93 | bool FormatParser_Parameters::haveParameter(const std::string &_name) const
|
|---|
| 94 | {
|
|---|
| 95 | return storage->isPresentByName(_name);
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | /** Gets a parameter from \a storage.
|
|---|
| 99 | *
|
|---|
| 100 | * This just eases use, saves some typing and is more clear as to what is done.
|
|---|
| 101 | *
|
|---|
| 102 | * @return pointer to instance with this \a _name
|
|---|
| 103 | */
|
|---|
| 104 | Parameter *FormatParser_Parameters::getParameter(const std::string &_name) const
|
|---|
| 105 | {
|
|---|
| 106 | return storage->getByName(_name);
|
|---|
| 107 | }
|
|---|