]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Parameters.h.d
Moved to version 1.0
[cpPlugins.git] / lib / cpPlugins / Parameters.h.d
1 // =========================================================================
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __cpPlugins__Parameters__h__
5 #define __cpPlugins__Parameters__h__
6
7 $include "Value.e"
8
9 #include <cpPlugins/Value.h>
10 #include <deque>
11 #include <map>
12 #include <set>
13 #include <utility>
14
15 namespace cpPlugins
16 {
17   /*! \brief Class to represent simple scalar values set, to be used as
18    *         a base to ProcessObject's
19    */
20   class CPPLUGINS_EXPORT Parameters
21   {
22     //! Output streaming operator overload
23     friend std::ostream& operator<<( std::ostream& o, const Parameters& p )
24       {
25         p.Print( o );
26         return( o );
27       }
28
29   public:
30     //! Output streaming operator overload
31     typedef Parameters Self;
32
33     /*! @defgroup ScalarTypes
34      * Types that describe all base scalar values
35      * @{
36      */
37     typedef Value            TValue;
38     typedef TValue::TBool    TBool;
39     typedef TValue::TComplex TComplex;
40     typedef TValue::TInteger TInteger;
41     typedef TValue::TNatural TNatural;
42     typedef TValue::TReal    TReal;
43     typedef TValue::TString  TString;
44     //! @}
45
46     /*! @defgroup Containers
47      * Types that define possible containers: Sets or Sequences.
48      * @{
49      */
50     typedef std::shared_ptr< TValue > TValuePtr;
51     typedef std::set< TValuePtr >     TSet;
52     typedef std::deque< TValuePtr >   TSequence;
53
54     typedef std::pair< TValue, TValuePtr > TValuePair;
55     typedef std::pair< TValue, TSet >      TSetPair;
56     typedef std::pair< TValue, TSequence > TSequencePair;
57     typedef std::map< TString, T$a$Pair >  T$a$Params;
58     //! @}
59
60     /*! @defgroup Choices
61      * Types that define choices to the user.
62      * @{
63      */
64     typedef std::pair< TSetPair, TSet::const_iterator > TChoicePair;
65     typedef std::map< TString, TChoicePair >            TChoiceParams;
66     //! @}
67
68   public:
69     Parameters( );
70     virtual ~Parameters( );
71     void Print( std::ostream& o ) const;
72
73       {{#t}}{{#a}}
74     //! Configure a {{t}} {{a}} parameter from a template.
75     void Configure{{t}}{{a}}( const TString& name, const TValue& templ );
76       {{/a}}{{/t}}
77
78       {{#t}}{{#a}}
79     //! Configure a {{t}} {{a}} parameter.
80     template< class _TValue >
81     void Configure{{t}}{{a}}( const TString& name );
82       {{/a}}{{/t}}
83
84       {{#t}}{{#a}}
85     //! Get a {{t}} {{a}} parameter.
86     const T{{a}}& Get{{t}}{{a}}( const TString& name ) const;
87       {{/a}}{{/t}}
88
89     TValuePtr& GetOutValuePtr( const TString& name );
90     const TValuePtr& GetOutValuePtr( const TString& name ) const;
91
92       {{#t}}{{#a}}
93     //! Get names for all {{t}} {{a}} parameters.
94     virtual std::set< std::string > Get{{t}}{{a}}Names( ) const;
95       {{/a}}{{/t}}
96
97       {{#t}}{{#a}}
98     //! Get a {{t}} {{a}} parameter template.
99     virtual const TValue& Get{{t}}{{a}}Template( const TString& name ) const;
100       {{/a}}{{/t}}
101
102       {{#t}}{{#a}}
103     //! Ask if current object has a {{t}} {{a}} parameter.
104     bool Has{{t}}{{a}}( const TString& name ) const;
105       {{/a}}{{/t}}
106
107       {{#t}}
108     //! Set current object has a {{t}} parameter.
109     template< class _TValue >
110     void Set{{t}}Value( const TString& name, const _TValue& value );
111       {{/t}}
112
113     void SetInValuePtr( const TString& name, TValuePtr& value );
114
115       {{#t}}{{#c}}
116     //! Add a value to a {{t}} {{c}} container.
117     template< class _TValue >
118     void AddTo{{t}}{{c}}( const TString& name, const _TValue& value );
119       {{/c}}{{/t}}
120
121       {{#t}}{{#c}}
122     //! Clear the  {{t}} {{c}} container.
123     void Clear{{t}}{{c}}( const TString& name );
124       {{/c}}{{/t}}
125
126     //! Add a choice
127     template< class _TValue >
128     void AddChoice( const TString& name, const _TValue& v );
129
130     //! Clear choices
131     void ClearChoice( const TString& name );
132
133     //! Configure choices
134     template< class _TValue >
135     void ConfigureChoices( const TString& name );
136
137     //! Get current choice
138     virtual const TValue& GetChoice( const TString& name ) const;
139
140     /*! @defgroup Update
141      * Inform modifications and update sources
142      * @{
143      */
144       {{#a}}
145       {{#t}}
146     virtual void Modified{{t}}{{a}}( const std::string& name );
147       {{/t}}
148       {{/a}}
149     virtual void ModifiedChoice( const std::string& name );
150     bool Update( );
151     //! @}
152
153     /*! @defgroup IO
154      * Methods to save into XML files
155      * @{
156      */
157     template< class _TXMLNodeValue >
158     void LoadXML( const _TXMLNodeValue& node );
159
160     template< class _TXMLNode >
161     void SaveXML( _TXMLNode* node ) const;
162     //! @}
163
164   private:
165     // Purposely not implemented
166     Parameters( const Self& other );
167     Self& operator=( const Self& other );
168
169   protected:
170     //! @ingroup Containers
171     T$a$Params m_$t$$a$Params;
172
173     //! @ingroup Choices
174     TChoiceParams m_ChoiceParams;
175
176   }; // end class
177
178 } // end namespace
179
180 #endif // __cpPlugins__Parameters__h__
181
182 // eof - $RCSfile$