X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcpPlugins%2FInterface%2FParameters.h;h=858a90b577970f890c379f54cc5e1404db786112;hb=8e5fd31fd4d280781d8bc27a799361bf9c30b1d4;hp=0e54f0f7fdfae594e9fd9a55cb7042fde4a22a10;hpb=e18f55af541dba9026284beb6f12ef06b12e6f47;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Parameters.h b/lib/cpPlugins/Interface/Parameters.h index 0e54f0f..858a90b 100644 --- a/lib/cpPlugins/Interface/Parameters.h +++ b/lib/cpPlugins/Interface/Parameters.h @@ -1,41 +1,33 @@ #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__H__ #define __CPPLUGINS__INTERFACE__PARAMETERS__H__ +#include + #include #include #include #include -#include + +#include +#include namespace cpPlugins { namespace Interface { + // Some forward declarations + class ProcessObject; + /** */ class cpPlugins_Interface_EXPORT Parameters + : public itk::Object { - // ------------------------------------------------------------------- - friend std::ostream& operator<<( - std::ostream& os, const Parameters& p - ) - { - Parameters::TParameters::const_iterator pIt = - p.m_Parameters.begin( ); - for( ; pIt != p.m_Parameters.end( ); ++pIt ) - { - os - << pIt->first << ": (" - << pIt->second.first << ", " - << pIt->second.second << ")" - << std::endl; - - } // rof - return( os ); - } - public: - typedef Parameters Self; + typedef Parameters Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; enum Type { @@ -43,7 +35,8 @@ namespace cpPlugins Uint , Real , Index , Point , StringList , BoolList , IntList , UintList , RealList , - IndexList , PointList , NoType + IndexList , PointList , Choices , + NoType }; typedef bool TBool; @@ -52,100 +45,165 @@ 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 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 ); - bool HasStringValue( const TString& name ) const; - bool HasBoolValue( const TString& name ) const; - bool HasIntValue( const TString& name ) const; - bool HasUintValue( const TString& name ) const; - bool HasRealValue( const TString& name ) const; - bool HasIndexValue( const TString& name ) const; - bool HasPointValue( const TString& name ) const; - bool HasStringListValue( const TString& name ) const; - bool HasBoolListValue( const TString& name ) const; - bool HasIntListValue( const TString& name ) const; - bool HasUintListValue( const TString& name ) const; - bool HasRealListValue( const TString& name ) const; - bool HasIndexListValue( const TString& name ) const; - bool HasPointListValue( const TString& name ) const; + 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