"Code/Mantid/git@code.ornl.gov:mantidproject/mantid.git" did not exist on "019f1d3483a6e0fd03eab087b8718220a010fe1c"
Newer
Older
Gigg, Martyn Anthony
committed
#ifndef MANTID_API_RUN_H_
#define MANTID_API_RUN_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/PropertyManager.h"
Janik Zikovsky
committed
#include "MantidKernel/TimeSplitter.h"
Gigg, Martyn Anthony
committed
#include <vector>
Gigg, Martyn Anthony
committed
namespace Mantid
{
namespace API
{
/**
This class stores information regarding an experimental run as a series
of log entries
@author Martyn Gigg, Tessella plc
Gigg, Martyn Anthony
committed
@date 22/07/2010
Gigg, Martyn Anthony
committed
Copyright © 2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Gigg, Martyn Anthony
committed
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/>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
Gigg, Martyn Anthony
committed
class DLLExport Run
Gigg, Martyn Anthony
committed
{
public:
/// Default constructor
Run();
/// Virtual destructor
virtual ~Run();
Gigg, Martyn Anthony
committed
/// Copy constructor
Run(const Run& copy);
/// Assignment operator
const Run& operator=(const Run& rhs);
Janik Zikovsky
committed
/// Addition
Run& operator+=(const Run& rhs);
Janik Zikovsky
committed
void filterByTime(const Kernel::DateAndTime start, const Kernel::DateAndTime stop);
Janik Zikovsky
committed
void splitByTime(Kernel::TimeSplitterType& splitter, std::vector< Run * > outputs) const;
Janik Zikovsky
committed
size_t getMemorySize() const;
Gigg, Martyn Anthony
committed
/// Add data to the object in the form of a property
Gigg, Martyn Anthony
committed
void addProperty(Kernel::Property *prop, bool overwrite = false);
Gigg, Martyn Anthony
committed
/// Add a property of given type
template<class TYPE>
void addProperty(const std::string & name, const TYPE & value, bool overwrite = false);
Janik Zikovsky
committed
template<class TYPE>
void addProperty(const std::string & name, const TYPE & value, const std::string & units,
bool overwrite = false);
Janik Zikovsky
committed
Gigg, Martyn Anthony
committed
/// Does the property exist on the object
Gigg, Martyn Anthony
committed
bool hasProperty(const std::string & name) const { return m_manager.existsProperty(name); }
Gigg, Martyn Anthony
committed
// Expose some of the PropertyManager publicly
Gigg, Martyn Anthony
committed
/**
* Remove a named property
*/
void removeProperty(const std::string &name) { m_manager.removeProperty(name); }
/**
* Return all of the current properties
* @returns A vector of the current list of properties
*/
const std::vector<Kernel::Property*>& getProperties() const { return m_manager.getProperties(); }
/**
* Returns the named property
Janik Zikovsky
committed
* @param name :: The name of the property
Gigg, Martyn Anthony
committed
* @returns The named property
*/
Kernel::Property * getProperty(const std::string & name) const
{
Janik Zikovsky
committed
Kernel::Property *p = m_manager.getProperty(name);
return p;
Gigg, Martyn Anthony
committed
}
Gigg, Martyn Anthony
committed
/** @name Legacy functions */
//@{
/// Set the proton charge
void setProtonCharge( const double charge);
/// Get the proton charge
double getProtonCharge() const;
Janik Zikovsky
committed
Janik Zikovsky
committed
double integrateProtonCharge();
Gigg, Martyn Anthony
committed
/**
* Add a log entry
Janik Zikovsky
committed
* @param p :: A pointer to the property containing the log entry
Gigg, Martyn Anthony
committed
*/
void addLogData( Kernel::Property *p ) { addProperty(p); }
Janik Zikovsky
committed
Gigg, Martyn Anthony
committed
/**
* Access a single log entry
Janik Zikovsky
committed
* @param name :: The name of the log entry to retrieve
Gigg, Martyn Anthony
committed
* @returns A pointer to a property containing the log entry
*/
Gigg, Martyn Anthony
committed
Kernel::Property* getLogData(const std::string &name) const { return getProperty(name); }
Janik Zikovsky
committed
Gigg, Martyn Anthony
committed
/**
* Access all log entries
* @returns A list of all of the log entries
*/
const std::vector< Kernel::Property* >& getLogData() const {return getProperties(); }
/**
* Remove a named log entry
Janik Zikovsky
committed
* @param name :: The name of the entry to remove
Gigg, Martyn Anthony
committed
*/
void removeLogData(const std::string &name) { return removeProperty(name); }
Gigg, Martyn Anthony
committed
//@}
private:
/// The number of properties that are summed when two workspaces are summed
Steve Williams
committed
static const int ADDABLES;
/// The names of the properties to summ when two workspaces are summed
Steve Williams
committed
static const std::string ADDABLE[];
Gigg, Martyn Anthony
committed
/// A pointer to a property manager
Kernel::PropertyManager m_manager;
Gigg, Martyn Anthony
committed
/// The name of the proton charge property
Janik Zikovsky
committed
std::string m_protonChargeName;
Steve Williams
committed
/// Adds all the time series in from one property manager into another
void mergeMergables(Mantid::Kernel::PropertyManager & sum, const Mantid::Kernel::PropertyManager & toAdd);
Gigg, Martyn Anthony
committed
};
Gigg, Martyn Anthony
committed
/**
* Add a property of a specified type (Simply creates a Kernel::Property of that type
Janik Zikovsky
committed
* @param name :: The name of the type
* @param value :: The value of the property
* @param overwrite :: If true, a current value is overwritten. (Default: False)
Gigg, Martyn Anthony
committed
*/
template<class TYPE>
Gigg, Martyn Anthony
committed
void Run::addProperty(const std::string & name, const TYPE & value, bool overwrite)
Gigg, Martyn Anthony
committed
{
Gigg, Martyn Anthony
committed
addProperty(new Kernel::PropertyWithValue<TYPE>(name, value), overwrite);
Gigg, Martyn Anthony
committed
}
Janik Zikovsky
committed
/**
* Add a property of a specified type (Simply creates a Kernel::Property of that type)
* and set its units.
Janik Zikovsky
committed
* @param name :: The name of the type
* @param value :: The value of the property
* @param units :: a string giving the units of the property.
* @param overwrite :: If true, a current value is overwritten. (Default: False)
Janik Zikovsky
committed
*/
template<class TYPE>
Gigg, Martyn Anthony
committed
void Run::addProperty(const std::string & name, const TYPE & value, const std::string& units, bool overwrite)
Janik Zikovsky
committed
{
Kernel::Property * newProp = new Kernel::PropertyWithValue<TYPE>(name, value);
newProp->setUnits(units);
Gigg, Martyn Anthony
committed
addProperty(newProp, overwrite);
Janik Zikovsky
committed
}
Gigg, Martyn Anthony
committed
}
}
#endif //MANTIDAPI_RUN_H_