Newer
Older
namespace Mantid
{
namespace Kernel
{
/** Constructor
* @param name The name of the property
* @param type The type of the property
*/
Roman Tolchenov
committed
Property::Property( const std::string &name, const std::type_info &type, const unsigned int direction ) :
m_isDefault( true ),
m_name( name ),
m_documentation( "" ),
Roman Tolchenov
committed
m_typeinfo( &type ),
m_direction( direction )
Roman Tolchenov
committed
// Make sure a random int hasn't been passed in for the direction
// Property & PropertyWithValue destructors will be called in this case
if (m_direction > 2) throw std::out_of_range("direction should be a member of the Direction enum");
}
/// Copy constructor
Property::Property( const Property& right ) :
m_isDefault( right.m_isDefault ),
m_name( right.m_name ),
m_documentation( right.m_documentation ),
Roman Tolchenov
committed
m_typeinfo( right.m_typeinfo ),
m_direction( right.m_direction )
{
}
/// Virtual destructor
Property::~Property()
{
}
/** Copy assignment operator. Does nothing.
* @param right The right hand side value
*/
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Property& Property::operator=( const Property& right )
{
return *this;
}
/** Get the property's name
* @return The name of the property
*/
const std::string& Property::name() const
{
return m_name;
}
/** Get the property's documentation string
* @return The documentation string
*/
const std::string& Property::documentation() const
{
return m_documentation;
}
/** Get the property type_info
* @return The type of the property
*/
const std::type_info* Property::type_info() const
{
return m_typeinfo;
}
/** Returns the type of the property as a string.
* Note that this is implementation dependent.
* @return The property type
*/
const std::string Property::type() const
{
return m_typeinfo->name();
}
/** Checks whether the property has a valid value.
* Note: always returns true unless overridden
* @return True if the property's value is a valid one
*/
const bool Property::isValid() const
{
// Always true at present
return true;
}
Matt Clarke
committed
/** Returns the type of the validator as a string
* \returns Returns ""
*/
const std::string Property::getValidatorType() const
{
return "";
}
/** Returns true if the property has not been changed since initialisation
* @return True if the property still has its default value
*/
const bool Property::isDefault() const
{
return m_isDefault;
}
/** Sets the property's (optional) documentation string
* @param documentation The string containing the descriptive comment
*/
void Property::setDocumentation( const std::string& documentation )
{
m_documentation = documentation;
}
Russell Taylor
committed
/** Returns the set of valid values for this property, if such a set exists.
* If not, it returns an empty set.
*/
const std::vector<std::string> Property::allowedValues() const
Russell Taylor
committed
{
return std::vector<std::string>();
Russell Taylor
committed
}
Russell Taylor
committed
/// Create a PropertyHistory object representing the current state of the Property.
Russell Taylor
committed
const PropertyHistory Property::createHistory() const
{
Roman Tolchenov
committed
return PropertyHistory(this->name(),this->value(),this->type(),this->isDefault(),this->direction());
Russell Taylor
committed
}
} // namespace Kernel
} // namespace Mantid