]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Value.h.d
Moved to version 1.0
[cpPlugins.git] / lib / cpPlugins / Value.h.d
diff --git a/lib/cpPlugins/Value.h.d b/lib/cpPlugins/Value.h.d
new file mode 100644 (file)
index 0000000..6f24721
--- /dev/null
@@ -0,0 +1,116 @@
+// =========================================================================
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+#ifndef __cpPlugins__Value__h__
+#define __cpPlugins__Value__h__
+
+$include "Value.e"
+
+#include <cpPlugins/Config.h>
+#include <complex>
+
+namespace cpPlugins
+{
+  // Some forward declarations...
+  class ProcessObject;
+
+  /*! \brief Class to represent simple scalar values, independently from
+   *         atomic types.
+   */
+  struct CPPLUGINS_EXPORT Value
+  {
+    //! Output streaming operator overload
+    friend std::ostream& operator<<( std::ostream& o, const Value& v )
+      {
+        v.Print( o );
+        return( o );
+      }
+
+  public:
+    //! Simple typedef to be used by lazy programmers :-)
+    typedef Value Self;
+
+    /*! @defgroup ScalarTypes
+     * Types that describe all base scalar values
+     * @{
+     */
+    typedef bool                  TBool;
+    typedef long                  TInteger;
+    typedef unsigned long         TNatural;
+    typedef long double           TReal;
+    typedef std::complex< TReal > TComplex;
+    typedef std::string           TString;
+    //! @}
+
+    /*! @defgroup Constructors
+     * Types that describe all base scalar values
+     * @{
+     */
+    //! Default constructor
+    Value( );
+
+    //! Prepare a particular value
+    Value( const std::type_info& i );
+
+    //! Cast constructor(s)
+    Value( const Self& v );
+      {{#s}}
+    Value( const {{s}}& v );
+      {{/s}}
+
+    //! @}
+
+    //! Output cast operator
+      {{#s}}
+    explicit operator {{s}}( ) const;
+      {{/s}}
+
+    //! Assignement operator
+    Self& operator=( const Self& v );
+      {{#s}}
+    Self& operator=( const {{s}}& v );
+      {{/s}}
+
+    //! Comparison operator
+    bool operator<( const Self& v ) const;
+
+    //! Return a string with contained type information.
+    const std::string& GetTypeName( ) const;
+
+    /*! @defgroup Pipeline
+     * Methods to synchronize values in processing pipelines
+     * @{
+     */
+    ProcessObject* GetSource( );
+    const ProcessObject* GetSource( ) const;
+
+    template< class _TObject >
+    void SetSource( _TObject* source );
+    //! @}
+
+    //! Send information to a stream
+    void Print( std::ostream& o ) const;
+
+  protected:
+    /*! @ingroup ScalarTypes
+     * Types that describe all base scalar values
+     * @{
+     */
+    TString  m_TypeName;
+    TBool    m_Bool;
+    TNatural m_Natural;
+    TInteger m_Integer;
+    TReal    m_Real;
+    TComplex m_Complex;
+    TString  m_String;
+    //! @}
+
+    //! @ingroup Pipeline
+    std::weak_ptr< ProcessObject > m_Source;
+
+  }; // end class
+} // end namespace
+
+#endif // __cpPlugins__Value__h__
+
+// eof - $RCSfile$