Newer
Older
Russell Taylor
committed
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/PropertyHistory.h"
Roman Tolchenov
committed
#include "MantidKernel/Property.h"
#include <sstream>
Russell Taylor
committed
namespace Mantid {
namespace Kernel {
Russell Taylor
committed
/// Constructor
PropertyHistory::PropertyHistory(const std::string &name,
const std::string &value,
const std::string &type, const bool isdefault,
const unsigned int direction)
: m_name(name), m_value(value), m_type(type), m_isDefault(isdefault),
m_direction(direction) {}
Russell Taylor
committed
PropertyHistory::PropertyHistory(Property const *const prop)
: // PropertyHistory::PropertyHistory(prop->name(), prop->value(),
// prop->type(), prop->isDefault(), prop->direction())
m_name(prop->name()),
m_value(prop->value()), m_type(prop->type()),
m_isDefault(prop->isDefault()), m_direction(prop->direction()) {}
Russell Taylor
committed
/// Destructor
PropertyHistory::~PropertyHistory() {}
Russell Taylor
committed
/**
* Standard Copy Constructor
Janik Zikovsky
committed
* @param A :: PropertyHistory Item to copy
Russell Taylor
committed
*/
PropertyHistory::PropertyHistory(const PropertyHistory &A)
: m_name(A.m_name), m_value(A.m_value), m_type(A.m_type),
m_isDefault(A.m_isDefault), m_direction(A.m_direction) {}
Russell Taylor
committed
/**
* Standard Assignment operator
Janik Zikovsky
committed
* @param A :: PropertyHistory Item to assign to 'this'
* @return pointer to this
Russell Taylor
committed
*/
PropertyHistory &PropertyHistory::operator=(const PropertyHistory &A) {
if (this != &A) {
m_name = A.m_name;
m_value = A.m_value;
m_type = A.m_type;
m_isDefault = A.m_isDefault;
m_direction = A.m_direction;
Russell Taylor
committed
}
return *this;
}
/** Prints a text representation of itself
Janik Zikovsky
committed
* @param os :: The ouput stream to write to
* @param indent :: an indentation value to make pretty printing of object and
* sub-objects
Russell Taylor
committed
*/
void PropertyHistory::printSelf(std::ostream &os, const int indent) const {
os << std::string(indent, ' ') << "Name: " << m_name;
os << ", Value: " << m_value;
os << ", Default?: " << (m_isDefault ? "Yes" : "No");
os << ", Direction: " << Kernel::Direction::asText(m_direction) << std::endl;
Russell Taylor
committed
}
/** Prints a text representation
Janik Zikovsky
committed
* @param os :: The ouput stream to write to
* @param AP :: The PropertyHistory to output
Russell Taylor
committed
* @returns The ouput stream
*/
std::ostream &operator<<(std::ostream &os, const PropertyHistory &AP) {
Russell Taylor
committed
AP.printSelf(os);
return os;
}
} // namespace Kernel
} // namespace Mantid