#ifndef __CPPLUGINS__INTERFACE__PARAMETERS__H__
#define __CPPLUGINS__INTERFACE__PARAMETERS__H__
+#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+
#include <map>
+#include <ostream>
#include <string>
#include <vector>
+#include <itkObject.h>
+#include <itkObjectFactory.h>
+
namespace cpPlugins
{
namespace Interface
{
+ // Some forward declarations
+ class ProcessObject;
+
/**
*/
- class Parameters
+ class cpPlugins_Interface_EXPORT Parameters
+ : public itk::Object
{
public:
- typedef Parameters Self;
+ typedef Parameters Self;
+ typedef itk::Object Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
enum Type
{
- String = 0,
- Bool,
- Int,
- Uint,
- Real,
- Index,
- Point,
- StringList,
- BoolList,
- IntList,
- UintList,
- RealList,
- IndexList,
- PointList,
+ String , Bool , Int ,
+ Uint , Real , Index ,
+ Point , StringList , BoolList ,
+ IntList , UintList , RealList ,
+ IndexList , PointList , Choices ,
NoType
};
typedef double TReal;
typedef std::string TString;
- typedef std::pair< Self::Type, TString > TParameter;
+ // NOTE: std::pair< default, value >
+ typedef std::pair< TString, TString > TValues;
+ typedef std::pair< Self::Type, TValues > TParameter;
typedef std::map< TString, TParameter > TParameters;
public:
- Parameters( );
- Parameters( const Self& other );
- virtual ~Parameters( );
+ itkNewMacro( Self );
+ itkTypeMacro( cpPlugins::Interface::Parameters, itk::Object );
- Self& operator=( const Self& other );
+ public:
+ // To impact pipeline
+ virtual const ProcessObject* GetProcessObject( ) const;
+ virtual void SetProcessObject( ProcessObject* v );
+ virtual void Modified( ) const;
+ // Parameters container configuration
void Clear( );
- void Configure( const Self::Type& type, const TString& name );
- void SetValueAsString( const TString& name, const TString& v );
- void SetValueAsBool( const TString& name, const TBool& v );
- void SetValueAsInt( const TString& name, const TInt& v );
- void SetValueAsUint( const TString& name, const TUint& v );
- void SetValueAsReal( const TString& name, const TReal& v );
- void SetValueAsIndex( const TString& name, const TUint& n, ... );
- void SetValueAsPoint( const TString& name, const TUint& n, ... );
- template< class I >
- void SetValueAsStringList(
- const TString& name, const I& b, const I& e
- );
+ void ConfigureAsString( const TString& name, const TString& v );
+ void ConfigureAsBool( const TString& name, const TBool& v );
+ void ConfigureAsInt( const TString& name, const TInt& v );
+ void ConfigureAsUint( const TString& name, const TUint& v );
+ void ConfigureAsReal( const TString& name, const TReal& v );
template< class I >
- void SetValueAsBoolList(
- const TString& name, const I& b, const I& e
- );
-
- template< class I >
- void SetValueAsIntList(
- const TString& name, const I& b, const I& e
- );
-
- template< class I >
- void SetValueAsUintList(
- const TString& name, const I& b, const I& e
- );
-
- template< class I >
- void SetValueAsRealList(
- const TString& name, const I& b, const I& e
- );
-
- template< class I >
- void SetValueAsIndexList(
- const TString& name, const I& b, const I& e
- );
-
- template< class I >
- void SetValueAsPointList(
- const TString& name, const I& b, const I& e
- );
-
- std::vector< TString > GetParameters( ) const;
- Self::Type GetParameterType( const TString& name ) const;
- const TString& GetValueAsString( const TString& name ) const;
- TBool GetValueAsBool( const TString& name ) const;
- TInt GetValueAsInt( const TString& name ) const;
- TUint GetValueAsUint( const TString& name ) const;
- TReal GetValueAsReal( const TString& name ) const;
-
- template< class I >
- I GetValueAsIndex( const TString& name ) const;
-
+ inline void ConfigureAsIndex(
+ const TString& name, const TUint& dim, const I& v
+ );
template< class P >
- P GetValueAsPoint( const TString& name ) const;
+ inline void ConfigureAsPoint(
+ const TString& name, const TUint& dim, const P& v
+ );
+
+ void ConfigureAsStringList( const TString& name );
+ void ConfigureAsBoolList( const TString& name );
+ void ConfigureAsIntList( const TString& name );
+ void ConfigureAsUintList( const TString& name );
+ void ConfigureAsRealList( const TString& name );
+ void ConfigureAsIndexList( const TString& name );
+ void ConfigureAsPointList( const TString& name );
+ void ConfigureAsChoices(
+ const TString& name, const std::vector< TString >& choices
+ );
- void GetValueAsStringList(
+ // Get methods
+ void GetNames( std::vector< TString >& container ) const;
+ Type GetType( const TString& name ) const;
+
+ bool HasString( const TString& name ) const;
+ bool HasBool( const TString& name ) const;
+ bool HasInt( const TString& name ) const;
+ bool HasUint( const TString& name ) const;
+ bool HasReal( const TString& name ) const;
+ bool HasIndex( const TString& name ) const;
+ bool HasPoint( const TString& name ) const;
+ bool HasStringList( const TString& name ) const;
+ bool HasBoolList( const TString& name ) const;
+ bool HasIntList( const TString& name ) const;
+ bool HasUintList( const TString& name ) const;
+ bool HasRealList( const TString& name ) const;
+ bool HasIndexList( const TString& name ) const;
+ bool HasPointList( const TString& name ) const;
+ bool HasChoices( const TString& name ) const;
+
+ TString GetString( const TString& name ) const;
+ TBool GetBool( const TString& name ) const;
+ TInt GetInt( const TString& name ) const;
+ TUint GetUint( const TString& name ) const;
+ TReal GetReal( const TString& name ) const;
+
+ void GetStringList(
std::vector< TString >& lst, const TString& name
) const;
- void GetValueAsBoolList(
+ void GetBoolList(
std::vector< TBool >& lst, const TString& name
) const;
- void GetValueAsIntList(
+ void GetIntList(
std::vector< TInt >& lst, const TString& name
) const;
- void GetValueAsUintList(
+ void GetUintList(
std::vector< TUint >& lst, const TString& name
) const;
- void GetValueAsRealList(
+ void GetRealList(
std::vector< TReal >& lst, const TString& name
) const;
- template< class I >
- void GetValueAsIndexList(
- std::vector< I >& lst, const TString& name
+ void GetChoices(
+ std::vector< TString >& choices, const TString& name
) const;
+ TString GetSelectedChoice( const TString& name ) const;
+ template< class I >
+ inline I GetIndex( const TString& name, const TUint& dim ) const;
template< class P >
- void GetValueAsPointList(
- std::vector< P >& lst, const TString& name
- ) const;
+ inline P GetPoint( const TString& name, const TUint& dim ) const;
+
+ template< class I >
+ inline void GetIndexList(
+ std::vector< I >& lst, const TString& name, const TUint& dim
+ ) const;
+ template< class P >
+ inline void GetPointList(
+ std::vector< P >& lst, const TString& name, const TUint& dim
+ ) const;
+
+ // Set methods
+ void SetString( const TString& name, const TString& v );
+ void SetBool( const TString& name, const TBool& v );
+ void SetInt( const TString& name, const TInt& v );
+ void SetUint( const TString& name, const TUint& v );
+ void SetReal( const TString& name, const TReal& v );
+
+ template< class I >
+ inline void SetIndex(
+ const TString& name, const TUint& dim, const I& v
+ );
+ template< class P >
+ inline void SetPoint(
+ const TString& name, const TUint& dim, const P& v
+ );
+
+ void AddToStringList( const TString& name, const TString& v );
+ void AddToBoolList( const TString& name, const TBool& v );
+ void AddToIntList( const TString& name, const TInt& v );
+ void AddToUintList( const TString& name, const TUint& v );
+ void AddToRealList( const TString& name, const TReal& v );
+
+ template< class I >
+ inline void AddToIndexList(
+ const TString& name, const TUint& dim, const I& v
+ );
+ template< class P >
+ inline void AddToPointList(
+ const TString& name, const TUint& dim, const P& v
+ );
+
+ void ClearStringList( const TString& name );
+ void ClearBoolList( const TString& name );
+ void ClearIntList( const TString& name );
+ void ClearUintList( const TString& name );
+ void ClearRealList( const TString& name );
+ void ClearIndexList( const TString& name );
+ void ClearPointList( const TString& name );
+
+ bool SetSelectedChoice( const TString& name, const TString& choice );
+ protected:
+ Parameters( );
+ virtual ~Parameters( );
+ void PrintSelf( std::ostream& os, itk::Indent indent ) const;
+
+ private:
+ // Purposely not implemented
+ Parameters( const Self& other );
+ Self& operator=( const Self& other );
protected:
TParameters m_Parameters;
+ const ProcessObject* m_Process;
};
} // ecapseman