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