1 // =========================================================================
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __cpPlugins__Parameters__h__
5 #define __cpPlugins__Parameters__h__
9 #include <cpPlugins/Value.h>
17 /*! \brief Class to represent simple scalar values set, to be used as
18 * a base to ProcessObject's
20 class CPPLUGINS_EXPORT Parameters
22 //! Output streaming operator overload
23 friend std::ostream& operator<<( std::ostream& o, const Parameters& p )
30 //! Output streaming operator overload
31 typedef Parameters Self;
33 /*! @defgroup ScalarTypes
34 * Types that describe all base scalar values
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;
46 /*! @defgroup Containers
47 * Types that define possible containers: Sets or Sequences.
50 typedef std::shared_ptr< TValue > TValuePtr;
51 typedef std::set< TValuePtr > TSet;
52 typedef std::deque< TValuePtr > TSequence;
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;
61 * Types that define choices to the user.
64 typedef std::pair< TSetPair, TSet::const_iterator > TChoicePair;
65 typedef std::map< TString, TChoicePair > TChoiceParams;
70 virtual ~Parameters( );
71 void Print( std::ostream& o ) const;
74 //! Configure a {{t}} {{a}} parameter from a template.
75 void Configure{{t}}{{a}}( const TString& name, const TValue& templ );
79 //! Configure a {{t}} {{a}} parameter.
80 template< class _TValue >
81 void Configure{{t}}{{a}}( const TString& name );
85 //! Get a {{t}} {{a}} parameter.
86 const T{{a}}& Get{{t}}{{a}}( const TString& name ) const;
89 TValuePtr& GetOutValuePtr( const TString& name );
90 const TValuePtr& GetOutValuePtr( const TString& name ) const;
93 //! Get names for all {{t}} {{a}} parameters.
94 virtual std::set< std::string > Get{{t}}{{a}}Names( ) const;
98 //! Get a {{t}} {{a}} parameter template.
99 virtual const TValue& Get{{t}}{{a}}Template( const TString& name ) const;
103 //! Ask if current object has a {{t}} {{a}} parameter.
104 bool Has{{t}}{{a}}( const TString& name ) const;
108 //! Set current object has a {{t}} parameter.
109 template< class _TValue >
110 void Set{{t}}Value( const TString& name, const _TValue& value );
113 void SetInValuePtr( const TString& name, TValuePtr& value );
116 //! Add a value to a {{t}} {{c}} container.
117 template< class _TValue >
118 void AddTo{{t}}{{c}}( const TString& name, const _TValue& value );
122 //! Clear the {{t}} {{c}} container.
123 void Clear{{t}}{{c}}( const TString& name );
127 template< class _TValue >
128 void AddChoice( const TString& name, const _TValue& v );
131 void ClearChoice( const TString& name );
133 //! Configure choices
134 template< class _TValue >
135 void ConfigureChoices( const TString& name );
137 //! Get current choice
138 virtual const TValue& GetChoice( const TString& name ) const;
141 * Inform modifications and update sources
146 virtual void Modified{{t}}{{a}}( const std::string& name );
149 virtual void ModifiedChoice( const std::string& name );
154 * Methods to save into XML files
157 template< class _TXMLNodeValue >
158 void LoadXML( const _TXMLNodeValue& node );
160 template< class _TXMLNode >
161 void SaveXML( _TXMLNode* node ) const;
165 // Purposely not implemented
166 Parameters( const Self& other );
167 Self& operator=( const Self& other );
170 //! @ingroup Containers
171 T$a$Params m_$t$$a$Params;
174 TChoiceParams m_ChoiceParams;
180 #endif // __cpPlugins__Parameters__h__