1 #ifndef __cpPlugins__BaseObjects__Parameters__h__
2 #define __cpPlugins__BaseObjects__Parameters__h__
4 #include <cpPlugins/Config.h>
11 #include <itkTimeStamp.h>
13 // Some forward declarations
20 // -------------------------------------------------------------------------
21 #define cpPlugins_BaseObjects_Parameters_Configure( Y ) \
22 void ConfigureAs##Y( const std::string& name, const T##Y& init ); \
23 bool Has##Y( const std::string& name ) const
25 // -------------------------------------------------------------------------
26 #define cpPlugins_BaseObjects_Parameters_ConfigureList( Y ) \
27 void ConfigureAs##Y##List( const std::string& name ); \
28 bool Has##Y##List( const std::string& name ) const
30 // -------------------------------------------------------------------------
31 #define cpPlugins_BaseObjects_Parameters_GetSet( Y ) \
32 T##Y Get##Y( const std::string& name ) const; \
33 void Set##Y( const std::string& name, const T##Y& v )
35 // -------------------------------------------------------------------------
36 #define cpPlugins_BaseObjects_Parameters_GetSetList( Y ) \
37 std::vector< T##Y > Get##Y##List( const std::string& name ) const; \
38 void AddTo##Y##List( const std::string& name, const T##Y& v ); \
39 void Clear##Y##List( const std::string& name )
41 // -------------------------------------------------------------------------
44 namespace QT { class ParametersDialog; }
52 class cpPlugins_EXPORT Parameters
54 // Frienship with forward declaration to improve Qt dialog execution
55 friend class cpPlugins::QT::ParametersDialog;
56 friend std::ostream& operator<<( std::ostream& o, const Parameters& p )
59 auto i = p.m_Parameters.begin( );
60 i != p.m_Parameters.end( );
63 o << i->first << ": ("
64 << i->second.first << " | "
65 << i->second.second << ")"
71 typedef Parameters Self;
76 Uint , Real , OpenFileName ,
77 SaveFileName , PathName , StringList ,
78 BoolList , IntList , UintList ,
79 RealList , OpenFileNameList , SaveFileNameList ,
80 PathNameList , Choices , NoType
85 typedef unsigned long TUint;
87 typedef std::string TString;
88 typedef std::string TOpenFileName;
89 typedef std::string TSaveFileName;
90 typedef std::string TPathName;
92 typedef std::pair< Self::Type, std::string > TParameter;
93 typedef std::map< std::string, TParameter > TParameters;
96 cpPlugins_BaseObjects_Parameters_Configure( String );
97 cpPlugins_BaseObjects_Parameters_Configure( Bool );
98 cpPlugins_BaseObjects_Parameters_Configure( Int );
99 cpPlugins_BaseObjects_Parameters_Configure( Uint );
100 cpPlugins_BaseObjects_Parameters_Configure( Real );
101 cpPlugins_BaseObjects_Parameters_Configure( OpenFileName );
102 cpPlugins_BaseObjects_Parameters_Configure( SaveFileName );
103 cpPlugins_BaseObjects_Parameters_Configure( PathName );
105 cpPlugins_BaseObjects_Parameters_ConfigureList( String );
106 cpPlugins_BaseObjects_Parameters_ConfigureList( Bool );
107 cpPlugins_BaseObjects_Parameters_ConfigureList( Int );
108 cpPlugins_BaseObjects_Parameters_ConfigureList( Uint );
109 cpPlugins_BaseObjects_Parameters_ConfigureList( Real );
110 cpPlugins_BaseObjects_Parameters_ConfigureList( OpenFileName );
111 cpPlugins_BaseObjects_Parameters_ConfigureList( SaveFileName );
112 cpPlugins_BaseObjects_Parameters_ConfigureList( PathName );
114 cpPlugins_BaseObjects_Parameters_GetSet( Bool );
115 cpPlugins_BaseObjects_Parameters_GetSet( Int );
116 cpPlugins_BaseObjects_Parameters_GetSet( Uint );
117 cpPlugins_BaseObjects_Parameters_GetSet( Real );
118 cpPlugins_BaseObjects_Parameters_GetSet( OpenFileName );
119 cpPlugins_BaseObjects_Parameters_GetSet( SaveFileName );
120 cpPlugins_BaseObjects_Parameters_GetSet( PathName );
122 cpPlugins_BaseObjects_Parameters_GetSetList( String );
123 cpPlugins_BaseObjects_Parameters_GetSetList( Bool );
124 cpPlugins_BaseObjects_Parameters_GetSetList( Int );
125 cpPlugins_BaseObjects_Parameters_GetSetList( Uint );
126 cpPlugins_BaseObjects_Parameters_GetSetList( Real );
127 cpPlugins_BaseObjects_Parameters_GetSetList( OpenFileName );
128 cpPlugins_BaseObjects_Parameters_GetSetList( SaveFileName );
129 cpPlugins_BaseObjects_Parameters_GetSetList( PathName );
133 virtual ~Parameters( );
135 ProcessObject* GetProcessObject( );
136 const ProcessObject* GetProcessObject( ) const;
137 void SetProcessObject( ProcessObject* po );
138 virtual void Modified( ) const;
140 // Parameters container configuration
144 void GetNames( std::vector< std::string >& container ) const;
145 Type GetType( const std::string& name ) const;
146 std::string GetTypeAsString( const std::string& name ) const;
147 static Type GetTypeFromString( const std::string& t );
149 // Base string methods
150 std::string GetString(
151 const std::string& name, bool force = true
154 const std::string& name, const std::string& v, bool force = true
157 void ConfigureAsChoices(
158 const std::string& name, const std::vector< std::string >& choices
160 void ConfigureAsRealTypesChoices( const std::string& name );
161 void ConfigureAsIntTypesChoices( const std::string& name );
162 void ConfigureAsScalarTypesChoices( const std::string& name );
163 std::vector< std::string > GetChoices( const std::string& name ) const;
164 std::string GetSelectedChoice( const std::string& name ) const;
165 bool SetSelectedChoice(
166 const std::string& name, const std::string& choice
169 std::string GetAcceptedFileExtensions( const std::string& name ) const;
170 void SetAcceptedFileExtensions(
171 const std::string& name, const std::string& extensions
176 tinyxml2::XMLDocument* doc,
177 tinyxml2::XMLElement* parent_elem
179 bool FromXML( const tinyxml2::XMLElement* filter_elem );
182 TParameters& GetRawParameters( );
183 const TParameters& GetRawParameters( ) const;
185 template< unsigned int _Enum >
186 inline void _Configure( const std::string& name );
188 template< unsigned int _Enum >
189 inline bool _Has( const std::string& name ) const;
191 template< class _Type, unsigned int _Enum >
192 inline _Type _Get( const std::string& name ) const;
194 template< class _Type, unsigned int _Enum >
195 inline void _Set( const std::string& name, const _Type& v );
197 template< class _Type, unsigned int _Enum >
198 inline std::vector< _Type > _GetList( const std::string& name ) const;
200 template< class _Type, unsigned int _Enum >
201 inline void _AddToList( const std::string& name, const _Type& v );
203 template< unsigned int _Enum >
204 inline void _ClearList( const std::string& name );
207 // Purposely not implemented
208 Parameters( const Self& other );
209 Self& operator=( const Self& other );
212 ProcessObject* m_ProcessObject;
213 TParameters m_Parameters;
214 std::map< std::string, std::string > m_AcceptedFileExtensions;
221 #endif // __cpPlugins__BaseObjects__Parameters__h__