X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FParameters.h;h=ef8e3b31f08a2f4bb8793e494db861d1ed8f3077;hb=55743f4ff8867c0075518dcc6b76745722ce60ed;hp=65bf2a86253c56115e79bfba8ab7dd289cd26d31;hpb=1c9f0e4788ee1b1f924f369ddadb7be7c8921f8c;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Parameters.h b/lib/cpPlugins/Interface/Parameters.h index 65bf2a8..ef8e3b3 100644 --- a/lib/cpPlugins/Interface/Parameters.h +++ b/lib/cpPlugins/Interface/Parameters.h @@ -1,37 +1,41 @@ #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__H__ #define __CPPLUGINS__INTERFACE__PARAMETERS__H__ +#include + #include +#include #include #include +#include +#include + 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 }; @@ -41,86 +45,166 @@ namespace cpPlugins 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 ProcessObject* GetProcessObject( ); + 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, ... ); - - void AddValueToStringList( const TString& name, const TString& v ); - void AddValueToBoolList( const TString& name, const TBool& v ); - void AddValueToIntList( const TString& name, const TInt& v ); - void AddValueToUintList( const TString& name, const TUint& v ); - void AddValueToRealList( const TString& name, const TReal& v ); - void AddValueToIndexList( const TString& name, const TUint& n, ... ); - void AddValueToPointList( const TString& name, const TUint& n, ... ); - 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 ); - - std::vector< TString > GetParameters( ) const; - Self::Type GetParameterType( const TString& name ) const; - const TString& GetRawValue( 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; + 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 > - 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; - - void GetValueAsStringList( + 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 + ); + + // 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; + ProcessObject* m_Process; }; } // ecapseman