]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Parameters.hxx
Simplified parameters
[cpPlugins.git] / lib / cpPlugins / Interface / Parameters.hxx
1 #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
2 #define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
3
4 #include <sstream>
5
6 // -------------------------------------------------------------------------
7 template< class I >
8 void cpPlugins::Interface::Parameters::
9 SetValueAsStringList( const std::string& name, const I& b, const I& e )
10 {
11   TParameters::iterator pIt = this->m_Parameters.find( name );
12   if( pIt == this->m_Parameters.end( ) )
13     return;
14   if( pIt->second.first != Self::StringList )
15     return;
16
17   std::stringstream ss;
18   for( I i = b; i != e; ++i )
19     ss << *i << ":";
20   pIt->second = ss.str( );
21 }
22
23 // -------------------------------------------------------------------------
24 template< class I >
25 void cpPlugins::Interface::Parameters::
26 SetValueAsIntList( const std::string& name, const I& b, const I& e )
27 {
28   TParameters::iterator pIt = this->m_Parameters.find( name );
29   if( pIt == this->m_Parameters.end( ) )
30     return;
31   if( pIt->second.first != Self::IntList )
32     return;
33
34   std::stringstream ss;
35   for( I i = b; i != e; ++i )
36     ss << *i << ":";
37   pIt->second = ss.str( );
38 }
39
40 // -------------------------------------------------------------------------
41 template< class I >
42 void cpPlugins::Interface::Parameters::
43 SetValueAsUintList( const std::string& name, const I& b, const I& e )
44 {
45   TParameters::iterator pIt = this->m_Parameters.find( name );
46   if( pIt == this->m_Parameters.end( ) )
47     return;
48   if( pIt->second.first != Self::UintList )
49     return;
50
51   std::stringstream ss;
52   for( I i = b; i != e; ++i )
53     ss << *i << ":";
54   pIt->second = ss.str( );
55 }
56
57 // -------------------------------------------------------------------------
58 template< class I >
59 void cpPlugins::Interface::Parameters::
60 SetValueAsRealList( const std::string& name, const I& b, const I& e )
61 {
62   TParameters::iterator pIt = this->m_Parameters.find( name );
63   if( pIt == this->m_Parameters.end( ) )
64     return;
65   if( pIt->second.first != Self::RealList )
66     return;
67
68   std::stringstream ss;
69   for( I i = b; i != e; ++i )
70     ss << *i << ":";
71   pIt->second = ss.str( );
72 }
73
74 // -------------------------------------------------------------------------
75 template< class I >
76 void cpPlugins::Interface::Parameters::
77 SetValueAsIndexList( const std::string& name, const I& b, const I& e )
78 {
79   // TODO
80 }
81
82 // -------------------------------------------------------------------------
83 template< class I >
84 void cpPlugins::Interface::Parameters::
85 SetValueAsPointList( const std::string& name, const I& b, const I& e )
86 {
87   // TODO
88 }
89
90 // -------------------------------------------------------------------------
91 template< class I >
92 I cpPlugins::Interface::Parameters::
93 GetValueAsIndex( const std::string& name ) const
94 {
95   TParameters::iterator pIt = this->m_Parameters.find( name );
96   if( pIt == this->m_Parameters.end( ) )
97     return( I( ) );
98   if( pIt->second.first != Self::Index )
99     return( I( ) );
100
101   // TODO:
102   return( I( ) );
103 }
104
105 // -------------------------------------------------------------------------
106 template< class P >
107 P cpPlugins::Interface::Parameters::
108 GetValueAsPoint( const std::string& name ) const
109 {
110   TParameters::iterator pIt = this->m_Parameters.find( name );
111   if( pIt == this->m_Parameters.end( ) )
112     return( P( ) );
113   if( pIt->second.first != Self::Point )
114     return( P( ) );
115
116   // TODO:
117   return( P( ) );
118 }
119
120 // -------------------------------------------------------------------------
121 template< class I >
122 void cpPlugins::Interface::Parameters::
123 GetValueAsIndexList( std::vector< I >& lst, const std::string& name ) const
124 {
125   lst.clear( );
126   TParameters::iterator pIt = this->m_Parameters.find( name );
127   if( pIt == this->m_Parameters.end( ) )
128     return;
129   if( pIt->second.first != Self::IndexList )
130     return;
131
132   // TODO:
133 }
134
135 // -------------------------------------------------------------------------
136 template< class P >
137 void cpPlugins::Interface::Parameters::
138 GetValueAsPointList( std::vector< P >& lst, const std::string& name ) const
139 {
140   lst.clear( );
141   TParameters::iterator pIt = this->m_Parameters.find( name );
142   if( pIt == this->m_Parameters.end( ) )
143     return;
144   if( pIt->second.first != Self::PointList )
145     return;
146
147   // TODO:
148 }
149
150 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
151
152 // eof - $RCSfile$