]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Parameters.h
Parameters finished
[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       void AddValueToStringList( const TString& name, const TString& v );
65       void AddValueToBoolList( const TString& name, const TBool& v );
66       void AddValueToIntList( const TString& name, const TInt& v );
67       void AddValueToUintList( const TString& name, const TUint& v );
68       void AddValueToRealList( const TString& name, const TReal& v );
69       void AddValueToIndexList( const TString& name, const TUint& n, ... );
70       void AddValueToPointList( const TString& name, const TUint& n, ... );
71
72       void ClearStringList( const TString& name );
73       void ClearBoolList( const TString& name );
74       void ClearIntList( const TString& name );
75       void ClearUintList( const TString& name );
76       void ClearRealList( const TString& name );
77       void ClearIndexList( const TString& name );
78       void ClearPointList( const TString& name );
79       
80       std::vector< TString > GetParameters( ) const;
81       Self::Type GetParameterType( const TString& name ) const;
82       const TString& GetRawValue( const TString& name ) const;
83       const TString& GetValueAsString( const TString& name ) const;
84       TBool GetValueAsBool( const TString& name ) const;
85       TInt GetValueAsInt( const TString& name ) const;
86       TUint GetValueAsUint( const TString& name ) const;
87       TReal GetValueAsReal( const TString& name ) const;
88
89       template< class I >
90       I GetValueAsIndex( const TString& name ) const;
91
92       template< class P >
93       P GetValueAsPoint( const TString& name ) const;
94
95       void GetValueAsStringList(
96         std::vector< TString >& lst, const TString& name
97         ) const;
98       void GetValueAsBoolList(
99         std::vector< TBool >& lst, const TString& name
100         ) const;
101       void GetValueAsIntList(
102         std::vector< TInt >& lst, const TString& name
103         ) const;
104       void GetValueAsUintList(
105         std::vector< TUint >& lst, const TString& name
106         ) const;
107       void GetValueAsRealList(
108         std::vector< TReal >& lst, const TString& name
109         ) const;
110
111       template< class I >
112       void GetValueAsIndexList(
113         std::vector< I >& lst, const TString& name
114         ) const;
115
116       template< class P >
117       void GetValueAsPointList(
118         std::vector< P >& lst, const TString& name
119         ) const;
120
121
122     protected:
123       TParameters m_Parameters;
124     };
125
126   } // ecapseman
127
128 } // ecapseman
129
130 #include <cpPlugins/Interface/Parameters.hxx>
131
132 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__H__
133
134 // eof - $RCSfile$