Newer
Older
#ifndef MANTID_KERNEL_PROPERTYMANAGER_H_
#define MANTID_KERNEL_PROPERTYMANAGER_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
Russell Taylor
committed
#include <vector>
#include "MantidKernel/IPropertyManager.h"
Janik Zikovsky
committed
#include "MantidKernel/TimeSplitter.h"
namespace Mantid
{
namespace Kernel
{
Russell Taylor
committed
//----------------------------------------------------------------------
// Forward Declaration
//----------------------------------------------------------------------
class Logger;
Russell Taylor
committed
Russell Taylor
committed
/**
Property manager helper class.
This class is used by algorithms and services for helping to manage their own set of properties.
Russell Taylor
committed
N.B. ONCE YOU HAVE DECLARED A PROPERTY TO THE MANAGER IT IS OWNED BY THIS CLASS (I.E. DON'T DELETE IT!)
Russell Taylor
committed
Property values of any type except std::string can be extracted using getProperty().
For assignment of string properties it is necessary to use getPropertyValue().
@author Russell Taylor, Tessella Support Services plc
@author Based on the Gaudi class PropertyMgr (see http://proj-gaudi.web.cern.ch/proj-gaudi/)
@date 20/11/2007
Russell Taylor
committed
Copyright © 2007-2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Russell Taylor
committed
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport PropertyManager: virtual public IPropertyManager
PropertyManager();
Russell Taylor
committed
PropertyManager(const PropertyManager&);
PropertyManager& operator=(const PropertyManager&);
Janik Zikovsky
committed
PropertyManager& operator+=(const PropertyManager& rhs);
Janik Zikovsky
committed
void filterByTime(const Kernel::DateAndTime start, const Kernel::DateAndTime stop);
Janik Zikovsky
committed
void splitByTime(Kernel::TimeSplitterType& splitter, std::vector< PropertyManager * > outputs) const;
virtual ~PropertyManager();
// Function to declare properties (i.e. store them)
Steve Williams
committed
void declareProperty( Property *p, const std::string &doc="" );
Russell Taylor
committed
// Sets all the declared properties from
void setProperties(const std::string &propertiesArray);
void setPropertyValue(const std::string &name, const std::string &value);
void setPropertyOrdinal(const int &index, const std::string &value);
bool existsProperty(const std::string &name) const;
bool validateProperties() const;
Gigg, Martyn Anthony
committed
size_t propertyCount() const;
std::string getPropertyValue(const std::string &name) const;
const std::vector< Property*>& getProperties() const;
/// removes the property from properties map
void removeProperty(const std::string &name);
Gigg, Martyn Anthony
committed
/// Clears the whole property map
void clear();
/// Get the value of a property
TypedValue getProperty(const std::string &name) const;
Gigg, Martyn Anthony
committed
/// Return the property manager serialized as a string.
Gigg, Martyn Anthony
committed
virtual std::string toString(bool withDefaultValues = false) const;
Russell Taylor
committed
Russell Taylor
committed
protected:
using IPropertyManager::declareProperty;
Russell Taylor
committed
friend class PropertyManagerOwner;
Russell Taylor
committed
Property* getPointerToProperty(const std::string &name) const;
Property* getPointerToPropertyOrdinal(const int &index) const;
Janik Zikovsky
committed
Property* getPointerToPropertyOrNull( const std::string &name ) const;
Sofia Antony
committed
/// typedef for the map holding the properties
typedef std::map<std::string, Property*> PropertyMap;
/// The properties under management
PropertyMap m_properties;
Janik Zikovsky
committed
/// Stores the order in which the properties were declared.
std::vector<Property*> m_orderedProperties;
Russell Taylor
committed
/// Static reference to the logger class
static Logger& g_log;
};
} // namespace Kernel
} // namespace Mantid
#endif /*MANTID_KERNEL_PROPERTYMANAGER_H_*/