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