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