--- /dev/null
+#ifndef __cpPlugins__Pipeline__Parameters__h__
+#define __cpPlugins__Pipeline__Parameters__h__
+
+#include <cpPlugins/Config.h>
+
+#include <map>
+#include <ostream>
+#include <sstream>
+#include <typeinfo>
+#include <vector>
+#include <itkTimeStamp.h>
+
+// Some forward declarations
+namespace tinyxml2
+{
+ class XMLElement;
+ class XMLDocument;
+}
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Pipeline_Parameters_Configure( Y ) \
+ void ConfigureAs##Y( const std::string& name, const T##Y& init ); \
+ bool Has##Y( const std::string& name ) const
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Pipeline_Parameters_ConfigureList( Y ) \
+ void ConfigureAs##Y##List( const std::string& name ); \
+ bool Has##Y##List( const std::string& name ) const
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Pipeline_Parameters_GetSet( Y ) \
+ T##Y Get##Y( const std::string& name ) const; \
+ void Set##Y( const std::string& name, const T##Y& v )
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Pipeline_Parameters_GetSetList( Y ) \
+ std::vector< T##Y > Get##Y##List( const std::string& name ) const; \
+ void AddTo##Y##List( const std::string& name, const T##Y& v ); \
+ void Clear##Y##List( const std::string& name )
+
+// -------------------------------------------------------------------------
+namespace cpPlugins
+{
+ namespace QT { class ParametersDialog; }
+
+ namespace Pipeline
+ {
+ class ProcessObject;
+
+ /**
+ */
+ class cpPlugins_EXPORT Parameters
+ {
+ // Frienship with forward declaration to improve Qt dialog execution
+ friend class cpPlugins::QT::ParametersDialog;
+ friend std::ostream& operator<<( std::ostream& o, const Parameters& p )
+ {
+ for(
+ auto i = p.m_Parameters.begin( );
+ i != p.m_Parameters.end( );
+ ++i
+ )
+ o << i->first << ": ("
+ << i->second.first << " | "
+ << i->second.second << ")"
+ << std::endl;
+ return( o );
+ }
+
+ public:
+ typedef Parameters Self;
+
+ enum Type
+ {
+ String , Bool , Int ,
+ Uint , Real , OpenFileName ,
+ SaveFileName , PathName , StringList ,
+ BoolList , IntList , UintList ,
+ RealList , OpenFileNameList , SaveFileNameList ,
+ PathNameList , Choices , NoType
+ };
+
+ typedef bool TBool;
+ typedef long TInt;
+ typedef unsigned long TUint;
+ typedef double TReal;
+ typedef std::string TString;
+ typedef std::string TOpenFileName;
+ typedef std::string TSaveFileName;
+ typedef std::string TPathName;
+
+ typedef std::pair< Self::Type, std::string > TParameter;
+ typedef std::map< std::string, TParameter > TParameters;
+
+ public:
+ cpPlugins_Pipeline_Parameters_Configure( String );
+ cpPlugins_Pipeline_Parameters_Configure( Bool );
+ cpPlugins_Pipeline_Parameters_Configure( Int );
+ cpPlugins_Pipeline_Parameters_Configure( Uint );
+ cpPlugins_Pipeline_Parameters_Configure( Real );
+ cpPlugins_Pipeline_Parameters_Configure( OpenFileName );
+ cpPlugins_Pipeline_Parameters_Configure( SaveFileName );
+ cpPlugins_Pipeline_Parameters_Configure( PathName );
+
+ cpPlugins_Pipeline_Parameters_ConfigureList( String );
+ cpPlugins_Pipeline_Parameters_ConfigureList( Bool );
+ cpPlugins_Pipeline_Parameters_ConfigureList( Int );
+ cpPlugins_Pipeline_Parameters_ConfigureList( Uint );
+ cpPlugins_Pipeline_Parameters_ConfigureList( Real );
+ cpPlugins_Pipeline_Parameters_ConfigureList( OpenFileName );
+ cpPlugins_Pipeline_Parameters_ConfigureList( SaveFileName );
+ cpPlugins_Pipeline_Parameters_ConfigureList( PathName );
+
+ cpPlugins_Pipeline_Parameters_GetSet( Bool );
+ cpPlugins_Pipeline_Parameters_GetSet( Int );
+ cpPlugins_Pipeline_Parameters_GetSet( Uint );
+ cpPlugins_Pipeline_Parameters_GetSet( Real );
+ cpPlugins_Pipeline_Parameters_GetSet( OpenFileName );
+ cpPlugins_Pipeline_Parameters_GetSet( SaveFileName );
+ cpPlugins_Pipeline_Parameters_GetSet( PathName );
+
+ cpPlugins_Pipeline_Parameters_GetSetList( String );
+ cpPlugins_Pipeline_Parameters_GetSetList( Bool );
+ cpPlugins_Pipeline_Parameters_GetSetList( Int );
+ cpPlugins_Pipeline_Parameters_GetSetList( Uint );
+ cpPlugins_Pipeline_Parameters_GetSetList( Real );
+ cpPlugins_Pipeline_Parameters_GetSetList( OpenFileName );
+ cpPlugins_Pipeline_Parameters_GetSetList( SaveFileName );
+ cpPlugins_Pipeline_Parameters_GetSetList( PathName );
+
+ public:
+ Parameters( );
+ virtual ~Parameters( );
+
+ ProcessObject* GetProcessObject( );
+ const ProcessObject* GetProcessObject( ) const;
+ void SetProcessObject( ProcessObject* po );
+ virtual void Modified( ) const;
+
+ // Parameters container configuration
+ void Clear( );
+
+ // Get methods
+ void GetNames( std::vector< std::string >& container ) const;
+ Type GetType( const std::string& name ) const;
+ std::string GetTypeAsString( const std::string& name ) const;
+ static Type GetTypeFromString( const std::string& t );
+
+ // Base string methods
+ std::string GetString(
+ const std::string& name, bool force = true
+ ) const;
+ void SetString(
+ const std::string& name, const std::string& v, bool force = true
+ );
+
+ void ConfigureAsChoices(
+ const std::string& name, const std::vector< std::string >& choices
+ );
+ void ConfigureAsRealTypesChoices( const std::string& name );
+ void ConfigureAsIntTypesChoices( const std::string& name );
+ void ConfigureAsScalarTypesChoices( const std::string& name );
+ std::vector< std::string > GetChoices( const std::string& name ) const;
+ std::string GetSelectedChoice( const std::string& name ) const;
+ bool SetSelectedChoice(
+ const std::string& name, const std::string& choice
+ );
+
+ std::string GetAcceptedFileExtensions( const std::string& name ) const;
+ void SetAcceptedFileExtensions(
+ const std::string& name, const std::string& extensions
+ );
+
+ // XML "streaming"
+ bool ToXML(
+ tinyxml2::XMLDocument* doc,
+ tinyxml2::XMLElement* parent_elem
+ ) const;
+ bool FromXML( const tinyxml2::XMLElement* filter_elem );
+
+ protected:
+ TParameters& GetRawParameters( );
+ const TParameters& GetRawParameters( ) const;
+
+ template< unsigned int _Enum >
+ inline void _Configure( const std::string& name );
+
+ template< unsigned int _Enum >
+ inline bool _Has( const std::string& name ) const;
+
+ template< class _Type, unsigned int _Enum >
+ inline _Type _Get( const std::string& name ) const;
+
+ template< class _Type, unsigned int _Enum >
+ inline void _Set( const std::string& name, const _Type& v );
+
+ template< class _Type, unsigned int _Enum >
+ inline std::vector< _Type > _GetList( const std::string& name ) const;
+
+ template< class _Type, unsigned int _Enum >
+ inline void _AddToList( const std::string& name, const _Type& v );
+
+ template< unsigned int _Enum >
+ inline void _ClearList( const std::string& name );
+
+ private:
+ // Purposely not implemented
+ Parameters( const Self& other );
+ Self& operator=( const Self& other );
+
+ protected:
+ ProcessObject* m_ProcessObject;
+ TParameters m_Parameters;
+ std::map< std::string, std::string > m_AcceptedFileExtensions;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __cpPlugins__Pipeline__Parameters__h__
+
+// eof - $RCSfile$