X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcpPlugins%2FInterface%2FParameters.h;h=ef8e3b31f08a2f4bb8793e494db861d1ed8f3077;hb=55743f4ff8867c0075518dcc6b76745722ce60ed;hp=7a7578a951258e269984f8ae6d24017085145e98;hpb=d33ff8f25fd903eca28c2f088adc8f68e7738135;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Parameters.h b/lib/cpPlugins/Interface/Parameters.h index 7a7578a..ef8e3b3 100644 --- a/lib/cpPlugins/Interface/Parameters.h +++ b/lib/cpPlugins/Interface/Parameters.h @@ -1,130 +1,210 @@ #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, - Int, - Uint, - Real, - Index, - Point, - StringList, - IntList, - UintList, - RealList, - IndexList, - PointList, + String , Bool , Int , + Uint , Real , Index , + Point , StringList , BoolList , + IntList , UintList , RealList , + IndexList , PointList , Choices , NoType }; + typedef bool TBool; typedef long TInt; typedef unsigned long TUint; 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; - void Configure( const Self::Type& type, const TString& name ); - void SetValueAsString( const TString& name, const TString& 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, ... ); + // Parameters container configuration + void Clear( ); - 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 SetValueAsIntList( - const TString& name, const I& b, const I& e + inline void ConfigureAsIndex( + const TString& name, const TUint& dim, const I& v + ); + template< class P > + 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 ); - template< class I > - void SetValueAsUintList( - const TString& name, const I& b, const I& e - ); + // 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 GetBoolList( + std::vector< TBool >& lst, const TString& name + ) const; + void GetIntList( + std::vector< TInt >& lst, const TString& name + ) const; + void GetUintList( + std::vector< TUint >& lst, const TString& name + ) const; + void GetRealList( + std::vector< TReal >& lst, const TString& name + ) const; - template< class I > - void SetValueAsRealList( - const TString& name, const I& b, const I& e - ); + void GetChoices( + std::vector< TString >& choices, const TString& name + ) const; + TString GetSelectedChoice( const TString& name ) const; template< class I > - void SetValueAsIndexList( - const TString& name, const I& b, const I& e - ); + inline I GetIndex( const TString& name, const TUint& dim ) const; + template< class P > + inline P GetPoint( const TString& name, const TUint& dim ) const; template< class I > - void SetValueAsPointList( - const TString& name, const I& b, const I& e - ); + 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; - std::vector< TString > GetParameters( ) const; - Self::Type GetParameterType( const TString& name ) const; - const TString& GetValueAsString( const TString& name ) const; - TInt GetValueAsInt( const TString& name ) const; - TUint GetValueAsUint( const TString& name ) const; - TReal GetValueAsReal( const TString& name ) 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 > - I GetValueAsIndex( const TString& name ) const; - + inline void SetIndex( + const TString& name, const TUint& dim, const I& v + ); template< class P > - P GetValueAsPoint( const TString& name ) const; + inline void SetPoint( + const TString& name, const TUint& dim, const P& v + ); - void GetValueAsStringList( - std::vector< TString >& lst, const TString& name - ) const; - void GetValueAsIntList( - std::vector< TInt >& lst, const TString& name - ) const; - void GetValueAsUintList( - std::vector< TUint >& lst, const TString& name - ) const; - void GetValueAsRealList( - std::vector< TReal >& lst, const TString& name - ) const; + 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 > - void GetValueAsIndexList( - std::vector< I >& lst, const TString& name - ) const; - + inline void AddToIndexList( + const TString& name, const TUint& dim, const I& v + ); template< class P > - void GetValueAsPointList( - std::vector< P >& lst, const TString& name - ) const; + 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