1 /* =========================================================================
2 * @author ??? (???@javeriana.edu.co)
3 * @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
4 * =========================================================================
6 #ifndef __cpPlugins__Pipeline__Parameters__h__
7 #define __cpPlugins__Pipeline__Parameters__h__
9 #include <cpPlugins/Config.h>
15 // -------------------------------------------------------------------------
16 #define cpPlugins_Pipeline_Parameters_Configure( Y ) \
17 void ConfigureAs##Y( const std::string& name, const T##Y& init ); \
18 bool Has##Y( const std::string& name ) const
20 // -------------------------------------------------------------------------
21 #define cpPlugins_Pipeline_Parameters_ConfigureList( Y ) \
22 void ConfigureAs##Y##List( const std::string& name ); \
23 bool Has##Y##List( const std::string& name ) const
25 // -------------------------------------------------------------------------
26 #define cpPlugins_Pipeline_Parameters_GetSet( Y ) \
27 T##Y Get##Y( const std::string& name ) const; \
28 void Set##Y( const std::string& name, const T##Y& v )
30 // -------------------------------------------------------------------------
31 #define cpPlugins_Pipeline_Parameters_GetSetList( Y ) \
32 std::vector< T##Y > Get##Y##List( const std::string& name ) const; \
33 void AddTo##Y##List( const std::string& name, const T##Y& v ); \
34 void Clear##Y##List( const std::string& name )
36 // -------------------------------------------------------------------------
45 class CPPLUGINS_EXPORT Parameters
47 friend std::ostream& operator<<( std::ostream& o, const Parameters& p )
50 auto i = p.m_Parameters.begin( );
51 i != p.m_Parameters.end( );
54 o << i->first << ": ("
55 << i->second.first << " | "
56 << i->second.second << ")"
62 typedef Parameters Self;
67 Uint , Real , OpenFileName ,
68 SaveFileName , PathName , StringList ,
69 BoolList , IntList , UintList ,
70 RealList , OpenFileNameList , SaveFileNameList ,
71 PathNameList , Choices , NoType
76 typedef unsigned long TUint;
78 typedef std::string TString;
79 typedef std::string TOpenFileName;
80 typedef std::string TSaveFileName;
81 typedef std::string TPathName;
83 typedef std::pair< Self::Type, std::string > TParameter;
84 typedef std::map< std::string, TParameter > TParameters;
87 cpPlugins_Pipeline_Parameters_Configure( String );
88 cpPlugins_Pipeline_Parameters_Configure( Bool );
89 cpPlugins_Pipeline_Parameters_Configure( Int );
90 cpPlugins_Pipeline_Parameters_Configure( Uint );
91 cpPlugins_Pipeline_Parameters_Configure( Real );
92 cpPlugins_Pipeline_Parameters_Configure( OpenFileName );
93 cpPlugins_Pipeline_Parameters_Configure( SaveFileName );
94 cpPlugins_Pipeline_Parameters_Configure( PathName );
96 cpPlugins_Pipeline_Parameters_ConfigureList( String );
97 cpPlugins_Pipeline_Parameters_ConfigureList( Bool );
98 cpPlugins_Pipeline_Parameters_ConfigureList( Int );
99 cpPlugins_Pipeline_Parameters_ConfigureList( Uint );
100 cpPlugins_Pipeline_Parameters_ConfigureList( Real );
101 cpPlugins_Pipeline_Parameters_ConfigureList( OpenFileName );
102 cpPlugins_Pipeline_Parameters_ConfigureList( SaveFileName );
103 cpPlugins_Pipeline_Parameters_ConfigureList( PathName );
105 cpPlugins_Pipeline_Parameters_GetSet( Bool );
106 cpPlugins_Pipeline_Parameters_GetSet( Int );
107 cpPlugins_Pipeline_Parameters_GetSet( Uint );
108 cpPlugins_Pipeline_Parameters_GetSet( Real );
109 cpPlugins_Pipeline_Parameters_GetSet( OpenFileName );
110 cpPlugins_Pipeline_Parameters_GetSet( SaveFileName );
111 cpPlugins_Pipeline_Parameters_GetSet( PathName );
113 cpPlugins_Pipeline_Parameters_GetSetList( String );
114 cpPlugins_Pipeline_Parameters_GetSetList( Bool );
115 cpPlugins_Pipeline_Parameters_GetSetList( Int );
116 cpPlugins_Pipeline_Parameters_GetSetList( Uint );
117 cpPlugins_Pipeline_Parameters_GetSetList( Real );
118 cpPlugins_Pipeline_Parameters_GetSetList( OpenFileName );
119 cpPlugins_Pipeline_Parameters_GetSetList( SaveFileName );
120 cpPlugins_Pipeline_Parameters_GetSetList( PathName );
124 virtual ~Parameters( );
126 ProcessObject* GetProcessObject( );
127 const ProcessObject* GetProcessObject( ) const;
128 void SetProcessObject( ProcessObject* po );
129 virtual void Modified( ) const;
131 // Parameters container configuration
135 void GetNames( std::vector< std::string >& container ) const;
136 Type GetType( const std::string& name ) const;
137 std::string GetTypeAsString( const std::string& name ) const;
138 static Type GetTypeFromString( const std::string& t );
140 // Base string methods
141 std::string GetString(
142 const std::string& name, bool force = true
145 const std::string& name, const std::string& v, bool force = true
148 void ConfigureAsChoices(
149 const std::string& name, const std::vector< std::string >& choices
151 void ConfigureAsRealTypesChoices( const std::string& name );
152 void ConfigureAsIntTypesChoices( const std::string& name );
153 void ConfigureAsScalarTypesChoices( const std::string& name );
154 std::vector< std::string > GetChoices( const std::string& name ) const;
155 std::string GetSelectedChoice( const std::string& name ) const;
156 bool SetSelectedChoice(
157 const std::string& name, const std::string& choice
160 std::string GetAcceptedFileExtensions( const std::string& name ) const;
161 void SetAcceptedFileExtensions(
162 const std::string& name, const std::string& extensions
166 TParameters& GetRawParameters( );
167 const TParameters& GetRawParameters( ) const;
169 template< unsigned int _Enum >
170 inline void _Configure( const std::string& name );
172 template< unsigned int _Enum >
173 inline bool _Has( const std::string& name ) const;
175 template< class _Type, unsigned int _Enum >
176 inline _Type _Get( const std::string& name ) const;
178 template< class _Type, unsigned int _Enum >
179 inline void _Set( const std::string& name, const _Type& v );
181 template< class _Type, unsigned int _Enum >
182 inline std::vector< _Type > _GetList( const std::string& name ) const;
184 template< class _Type, unsigned int _Enum >
185 inline void _AddToList( const std::string& name, const _Type& v );
187 template< unsigned int _Enum >
188 inline void _ClearList( const std::string& name );
191 // Purposely not implemented
192 Parameters( const Self& other );
193 Self& operator=( const Self& other );
196 ProcessObject* m_ProcessObject;
197 TParameters m_Parameters;
198 std::map< std::string, std::string > m_AcceptedFileExtensions;
205 #endif // __cpPlugins__Pipeline__Parameters__h__