]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Parameters.h
7a7578a951258e269984f8ae6d24017085145e98
[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 Configure( const Self::Type& type, const TString& name );
52       void SetValueAsString( const TString& name, const TString& v );
53       void SetValueAsInt( const TString& name, const TInt& v );
54       void SetValueAsUint( const TString& name, const TUint& v );
55       void SetValueAsReal( const TString& name, const TReal& v );
56       void SetValueAsIndex( const TString& name, const TUint& n, ... );
57       void SetValueAsPoint( const TString& name, const TUint& n, ... );
58
59       template< class I >
60       void SetValueAsStringList(
61         const TString& name, const I& b, const I& e
62         );
63
64       template< class I >
65       void SetValueAsIntList(
66         const TString& name, const I& b, const I& e
67         );
68
69       template< class I >
70       void SetValueAsUintList(
71         const TString& name, const I& b, const I& e
72         );
73
74       template< class I >
75       void SetValueAsRealList(
76         const TString& name, const I& b, const I& e
77         );
78
79       template< class I >
80       void SetValueAsIndexList(
81         const TString& name, const I& b, const I& e
82         );
83
84       template< class I >
85       void SetValueAsPointList(
86         const TString& name, const I& b, const I& e
87         );
88
89       std::vector< TString > GetParameters( ) const;
90       Self::Type GetParameterType( const TString& name ) const;
91       const TString& GetValueAsString( const TString& name ) const;
92       TInt GetValueAsInt( const TString& name ) const;
93       TUint GetValueAsUint( const TString& name ) const;
94       TReal GetValueAsReal( const TString& name ) const;
95
96       template< class I >
97       I GetValueAsIndex( const TString& name ) const;
98
99       template< class P >
100       P GetValueAsPoint( const TString& name ) const;
101
102       void GetValueAsStringList(
103         std::vector< TString >& lst, const TString& name
104         ) const;
105       void GetValueAsIntList(
106         std::vector< TInt >& lst, const TString& name
107         ) const;
108       void GetValueAsUintList(
109         std::vector< TUint >& lst, const TString& name
110         ) const;
111       void GetValueAsRealList(
112         std::vector< TReal >& lst, const TString& name
113         ) const;
114
115       template< class I >
116       void GetValueAsIndexList(
117         std::vector< I >& lst, const TString& name
118         ) const;
119
120       template< class P >
121       void GetValueAsPointList(
122         std::vector< P >& lst, const TString& name
123         ) const;
124
125
126     protected:
127       TParameters m_Parameters;
128     };
129
130   } // ecapseman
131
132 } // ecapseman
133
134 #include <cpPlugins/Interface/Parameters.hxx>
135
136 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__H__
137
138 // eof - $RCSfile$