/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * StringParameter.cpp * * Created on: Sep 30, 2011 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include #include "CodePatterns/Assert.hpp" #include "StringParameter.hpp" /** Constructor for class StringParameter. * * @param _name name of this parameter */ StringParameter::StringParameter(const std::string &_name) : Parameter(_name), ValueSet(false) {} /** Constructor for class StringParameter. * * @param _name name of this parameter * @param _value value of this parameter */ StringParameter::StringParameter(const std::string &_name, const std::string &_value) : Parameter(_name), ValueSet(true), value(_value) {} /** Destructor of class StringParameter. * */ StringParameter::~StringParameter() {} /** Compare function for class StringParameter. * * @param _instance instance to compare to * @return true - both have the same \a StringParameter::value, false - else */ bool StringParameter::operator==(const StringParameter &_instance) const { bool status = true; status = status && (ValueSet == _instance.ValueSet); if (ValueSet && _instance.ValueSet) status = status && (value == _instance.value); status = status && (Parameter::getName() == _instance.Parameter::getName()); return status; } /** Implementation of clone function. * * @return copy of this instance with same value */ Parameter* StringParameter::clone() const { StringParameter *instance = new StringParameter(Parameter::getName(), get()); return instance; } /** ValueInterface function implementation whether value is valid. * * \note we always return true as there is no invalid string * * @param _value value to test * @return true */ bool StringParameter::isValid(const std::string _value) const { return true; } /** Getter for \a value. * * @return value */ const std::string StringParameter::get() const { ASSERT(ValueSet, ""); return value; } /** Setter for \a value. * * @param _value value to set to */ void StringParameter::set(const std::string _value) { value = _value; ValueSet = true; }