]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Parameters.h
Simplified parameters
[cpPlugins.git] / lib / cpPlugins / Interface / Parameters.h
diff --git a/lib/cpPlugins/Interface/Parameters.h b/lib/cpPlugins/Interface/Parameters.h
new file mode 100644 (file)
index 0000000..a806ee7
--- /dev/null
@@ -0,0 +1,133 @@
+#ifndef __CPPLUGINS__INTERFACE__PARAMETERS__H__
+#define __CPPLUGINS__INTERFACE__PARAMETERS__H__
+
+#include <map>
+#include <string>
+#include <vector>
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    /**
+     */
+    class Parameters
+    {
+    public:
+      typedef Parameters Self;
+
+      enum Type
+      {
+        String = 0,
+        Int,
+        Uint,
+        Real,
+        Index,
+        Point,
+        StringList,
+        IntList,
+        UintList,
+        RealList,
+        IndexList,
+        PointList
+      };
+
+      typedef std::pair< Self::Type, std::string > TParameter;
+      typedef std::map< std::string, TParameter >   TParameters;
+      typedef long          TInt;
+      typedef unsigned long TUint;
+      typedef double        TReal;
+
+    public:
+      Parameters( );
+      Parameters( const Self& other );
+      virtual ~Parameters( );
+
+      Self& operator=( const Self& other );
+
+      void Configure( const Self::Type& type, const std::string& name );
+      void SetValueAsString( const std::string& name, const std::string& v );
+      void SetValueAsInt( const std::string& name, const TInt& v );
+      void SetValueAsUint( const std::string& name, const TUint& v );
+      void SetValueAsReal( const std::string& name, const TReal& v );
+      void SetValueAsIndex( const std::string& name, const TUint& n, ... );
+      void SetValueAsPoint( const std::string& name, const TUint& n, ... );
+
+      template< class I >
+      void SetValueAsStringList(
+        const std::string& name, const I& b, const I& e
+        );
+
+      template< class I >
+      void SetValueAsIntList(
+        const std::string& name, const I& b, const I& e
+        );
+
+      template< class I >
+      void SetValueAsUintList(
+        const std::string& name, const I& b, const I& e
+        );
+
+      template< class I >
+      void SetValueAsRealList(
+        const std::string& name, const I& b, const I& e
+        );
+
+      template< class I >
+      void SetValueAsIndexList(
+        const std::string& name, const I& b, const I& e
+        );
+
+      template< class I >
+      void SetValueAsPointList(
+        const std::string& name, const I& b, const I& e
+        );
+
+      const std::string& GetValueAsString( const std::string& name ) const;
+      TInt GetValueAsInt( const std::string& name ) const;
+      TUint GetValueAsUint( const std::string& name ) const;
+      TReal GetValueAsReal( const std::string& name ) const;
+
+      template< class I >
+      I GetValueAsIndex( const std::string& name ) const;
+
+      template< class P >
+      P GetValueAsPoint( const std::string& name ) const;
+
+      void GetValueAsStringList(
+        std::vector< std::string >& lst, const std::string& name
+        ) const;
+      void GetValueAsIntList(
+        std::vector< TInt >& lst, const std::string& name
+        ) const;
+      void GetValueAsUintList(
+        std::vector< TUint >& lst, const std::string& name
+        ) const;
+      void GetValueAsRealList(
+        std::vector< TReal >& lst, const std::string& name
+        ) const;
+
+      template< class I >
+      void GetValueAsIndexList(
+        std::vector< I >& lst, const std::string& name
+        ) const;
+
+      template< class P >
+      void GetValueAsPointList(
+        std::vector< P >& lst, const std::string& name
+        ) const;
+
+
+    protected:
+      TParameters m_Parameters;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#include <cpPlugins/Interface/Parameters.hxx>
+
+#endif // __CPPLUGINS__INTERFACE__PARAMETERS__H__
+
+// eof - $RCSfile$