]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Parameters.h
bbf9dfcb47b12bf0ee89b741a257bbfb6867ca35
[cpPlugins.git] / lib / cpPlugins / Interface / Parameters.h
1 #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__H__
2 #define __CPPLUGINS__INTERFACE__PARAMETERS__H__
3
4 #include <map>
5 #include <string>
6 #include <vector>
7
8 namespace cpPlugins
9 {
10   namespace Interface
11   {
12     /**
13      */
14     class Parameters
15     {
16     public:
17       typedef Parameters Self;
18
19       enum Type
20       {
21         String = 0,
22         Bool,
23         Int,
24         Uint,
25         Real,
26         Index,
27         Point,
28         StringList,
29         BoolList,
30         IntList,
31         UintList,
32         RealList,
33         IndexList,
34         PointList,
35         NoType
36       };
37
38       typedef bool          TBool;
39       typedef long          TInt;
40       typedef unsigned long TUint;
41       typedef double        TReal;
42       typedef std::string   TString;
43
44       typedef std::pair< Self::Type, TString > TParameter;
45       typedef std::map< TString, TParameter >  TParameters;
46
47     public:
48       Parameters( );
49       Parameters( const Self& other );
50       virtual ~Parameters( );
51
52       Self& operator=( const Self& other );
53
54       void Clear( );
55       void Configure( const Self::Type& type, const TString& name );
56       void SetValueAsString( const TString& name, const TString& v );
57       void SetValueAsBool( const TString& name, const TBool& v );
58       void SetValueAsInt( const TString& name, const TInt& v );
59       void SetValueAsUint( const TString& name, const TUint& v );
60       void SetValueAsReal( const TString& name, const TReal& v );
61       void SetValueAsIndex( const TString& name, const TUint& n, ... );
62       void SetValueAsPoint( const TString& name, const TUint& n, ... );
63
64       template< class I >
65       void SetValueAsStringList(
66         const TString& name, const I& b, const I& e
67         );
68
69       template< class I >
70       void SetValueAsBoolList(
71         const TString& name, const I& b, const I& e
72         );
73
74       template< class I >
75       void SetValueAsIntList(
76         const TString& name, const I& b, const I& e
77         );
78
79       template< class I >
80       void SetValueAsUintList(
81         const TString& name, const I& b, const I& e
82         );
83
84       template< class I >
85       void SetValueAsRealList(
86         const TString& name, const I& b, const I& e
87         );
88
89       template< class I >
90       void SetValueAsIndexList(
91         const TString& name, const I& b, const I& e
92         );
93
94       template< class I >
95       void SetValueAsPointList(
96         const TString& name, const I& b, const I& e
97         );
98
99       std::vector< TString > GetParameters( ) const;
100       Self::Type GetParameterType( const TString& name ) const;
101       const TString& GetValueAsString( const TString& name ) const;
102       TBool GetValueAsBool( const TString& name ) const;
103       TInt GetValueAsInt( const TString& name ) const;
104       TUint GetValueAsUint( const TString& name ) const;
105       TReal GetValueAsReal( const TString& name ) const;
106
107       template< class I >
108       I GetValueAsIndex( const TString& name ) const;
109
110       template< class P >
111       P GetValueAsPoint( const TString& name ) const;
112
113       void GetValueAsStringList(
114         std::vector< TString >& lst, const TString& name
115         ) const;
116       void GetValueAsBoolList(
117         std::vector< TBool >& lst, const TString& name
118         ) const;
119       void GetValueAsIntList(
120         std::vector< TInt >& lst, const TString& name
121         ) const;
122       void GetValueAsUintList(
123         std::vector< TUint >& lst, const TString& name
124         ) const;
125       void GetValueAsRealList(
126         std::vector< TReal >& lst, const TString& name
127         ) const;
128
129       template< class I >
130       void GetValueAsIndexList(
131         std::vector< I >& lst, const TString& name
132         ) const;
133
134       template< class P >
135       void GetValueAsPointList(
136         std::vector< P >& lst, const TString& name
137         ) const;
138
139
140     protected:
141       TParameters m_Parameters;
142     };
143
144   } // ecapseman
145
146 } // ecapseman
147
148 #include <cpPlugins/Interface/Parameters.hxx>
149
150 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__H__
151
152 // eof - $RCSfile$