Skip to content
Snippets Groups Projects
Commit d72f5eda authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Adding use of boost::any to handle parameters access

parent 922a1db7
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,22 @@ public:
m_Value = m_DefaultValue;
}
/** Set any value */
virtual SetAnyValue(boost::any v)
{
// Perform any cast
m_Value=boost::any_cast<T>(v);
// Call Modified();
this->Modified();
}
/** Return any value */
virtual boost::any GetAnyValue()
{
return boost::any(m_Value);
}
/** Set the value */
itkSetMacro(Value,ScalarType);
......
......@@ -20,6 +20,7 @@
#include "otbMacro.h"
#include "itkLightObject.h"
#include "boost/any.hpp"
namespace otb
{
......@@ -106,6 +107,23 @@ public:
*/
virtual void Reset();
/** Return the parameter value as a boost:any. Should be
* reimplemented in each relevant sub-class (default implementation
* raise exception) */
virtual boost::any GetAnyValue()
{
itkExceptionMacro(<<"GetAnyValue() method must be re-implemented by sub-classes.");
}
/** Set the parameter value as a boost:any. Should be
* reimplemented in each relevant sub-class (default implementation
* raise exception) */
virtual void SetAnyValue(boost::any)
{
itkExceptionMacro(<<"SetAnyValue() method must be re-implemented by sub-classes.");
}
protected:
/** Constructor */
Parameter() : m_Name(""),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment