]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Parameters.h.d
Moved to version 1.0
[cpPlugins.git] / lib / cpPlugins / Parameters.h.d
diff --git a/lib/cpPlugins/Parameters.h.d b/lib/cpPlugins/Parameters.h.d
new file mode 100644 (file)
index 0000000..f2cd078
--- /dev/null
@@ -0,0 +1,182 @@
+// =========================================================================
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+#ifndef __cpPlugins__Parameters__h__
+#define __cpPlugins__Parameters__h__
+
+$include "Value.e"
+
+#include <cpPlugins/Value.h>
+#include <deque>
+#include <map>
+#include <set>
+#include <utility>
+
+namespace cpPlugins
+{
+  /*! \brief Class to represent simple scalar values set, to be used as
+   *         a base to ProcessObject's
+   */
+  class CPPLUGINS_EXPORT Parameters
+  {
+    //! Output streaming operator overload
+    friend std::ostream& operator<<( std::ostream& o, const Parameters& p )
+      {
+        p.Print( o );
+        return( o );
+      }
+
+  public:
+    //! Output streaming operator overload
+    typedef Parameters Self;
+
+    /*! @defgroup ScalarTypes
+     * Types that describe all base scalar values
+     * @{
+     */
+    typedef Value            TValue;
+    typedef TValue::TBool    TBool;
+    typedef TValue::TComplex TComplex;
+    typedef TValue::TInteger TInteger;
+    typedef TValue::TNatural TNatural;
+    typedef TValue::TReal    TReal;
+    typedef TValue::TString  TString;
+    //! @}
+
+    /*! @defgroup Containers
+     * Types that define possible containers: Sets or Sequences.
+     * @{
+     */
+    typedef std::shared_ptr< TValue > TValuePtr;
+    typedef std::set< TValuePtr >     TSet;
+    typedef std::deque< TValuePtr >   TSequence;
+
+    typedef std::pair< TValue, TValuePtr > TValuePair;
+    typedef std::pair< TValue, TSet >      TSetPair;
+    typedef std::pair< TValue, TSequence > TSequencePair;
+    typedef std::map< TString, T$a$Pair >  T$a$Params;
+    //! @}
+
+    /*! @defgroup Choices
+     * Types that define choices to the user.
+     * @{
+     */
+    typedef std::pair< TSetPair, TSet::const_iterator > TChoicePair;
+    typedef std::map< TString, TChoicePair >            TChoiceParams;
+    //! @}
+
+  public:
+    Parameters( );
+    virtual ~Parameters( );
+    void Print( std::ostream& o ) const;
+
+      {{#t}}{{#a}}
+    //! Configure a {{t}} {{a}} parameter from a template.
+    void Configure{{t}}{{a}}( const TString& name, const TValue& templ );
+      {{/a}}{{/t}}
+
+      {{#t}}{{#a}}
+    //! Configure a {{t}} {{a}} parameter.
+    template< class _TValue >
+    void Configure{{t}}{{a}}( const TString& name );
+      {{/a}}{{/t}}
+
+      {{#t}}{{#a}}
+    //! Get a {{t}} {{a}} parameter.
+    const T{{a}}& Get{{t}}{{a}}( const TString& name ) const;
+      {{/a}}{{/t}}
+
+    TValuePtr& GetOutValuePtr( const TString& name );
+    const TValuePtr& GetOutValuePtr( const TString& name ) const;
+
+      {{#t}}{{#a}}
+    //! Get names for all {{t}} {{a}} parameters.
+    virtual std::set< std::string > Get{{t}}{{a}}Names( ) const;
+      {{/a}}{{/t}}
+
+      {{#t}}{{#a}}
+    //! Get a {{t}} {{a}} parameter template.
+    virtual const TValue& Get{{t}}{{a}}Template( const TString& name ) const;
+      {{/a}}{{/t}}
+
+      {{#t}}{{#a}}
+    //! Ask if current object has a {{t}} {{a}} parameter.
+    bool Has{{t}}{{a}}( const TString& name ) const;
+      {{/a}}{{/t}}
+
+      {{#t}}
+    //! Set current object has a {{t}} parameter.
+    template< class _TValue >
+    void Set{{t}}Value( const TString& name, const _TValue& value );
+      {{/t}}
+
+    void SetInValuePtr( const TString& name, TValuePtr& value );
+
+      {{#t}}{{#c}}
+    //! Add a value to a {{t}} {{c}} container.
+    template< class _TValue >
+    void AddTo{{t}}{{c}}( const TString& name, const _TValue& value );
+      {{/c}}{{/t}}
+
+      {{#t}}{{#c}}
+    //! Clear the  {{t}} {{c}} container.
+    void Clear{{t}}{{c}}( const TString& name );
+      {{/c}}{{/t}}
+
+    //! Add a choice
+    template< class _TValue >
+    void AddChoice( const TString& name, const _TValue& v );
+
+    //! Clear choices
+    void ClearChoice( const TString& name );
+
+    //! Configure choices
+    template< class _TValue >
+    void ConfigureChoices( const TString& name );
+
+    //! Get current choice
+    virtual const TValue& GetChoice( const TString& name ) const;
+
+    /*! @defgroup Update
+     * Inform modifications and update sources
+     * @{
+     */
+      {{#a}}
+      {{#t}}
+    virtual void Modified{{t}}{{a}}( const std::string& name );
+      {{/t}}
+      {{/a}}
+    virtual void ModifiedChoice( const std::string& name );
+    bool Update( );
+    //! @}
+
+    /*! @defgroup IO
+     * Methods to save into XML files
+     * @{
+     */
+    template< class _TXMLNodeValue >
+    void LoadXML( const _TXMLNodeValue& node );
+
+    template< class _TXMLNode >
+    void SaveXML( _TXMLNode* node ) const;
+    //! @}
+
+  private:
+    // Purposely not implemented
+    Parameters( const Self& other );
+    Self& operator=( const Self& other );
+
+  protected:
+    //! @ingroup Containers
+    T$a$Params m_$t$$a$Params;
+
+    //! @ingroup Choices
+    TChoiceParams m_ChoiceParams;
+
+  }; // end class
+
+} // end namespace
+
+#endif // __cpPlugins__Parameters__h__
+
+// eof - $RCSfile$