]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Value.h.d
Moved to version 1.0
[cpPlugins.git] / lib / cpPlugins / Value.h.d
1 // =========================================================================
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __cpPlugins__Value__h__
5 #define __cpPlugins__Value__h__
6
7 $include "Value.e"
8
9 #include <cpPlugins/Config.h>
10 #include <complex>
11
12 namespace cpPlugins
13 {
14   // Some forward declarations...
15   class ProcessObject;
16
17   /*! \brief Class to represent simple scalar values, independently from
18    *         atomic types.
19    */
20   struct CPPLUGINS_EXPORT Value
21   {
22     //! Output streaming operator overload
23     friend std::ostream& operator<<( std::ostream& o, const Value& v )
24       {
25         v.Print( o );
26         return( o );
27       }
28
29   public:
30     //! Simple typedef to be used by lazy programmers :-)
31     typedef Value Self;
32
33     /*! @defgroup ScalarTypes
34      * Types that describe all base scalar values
35      * @{
36      */
37     typedef bool                  TBool;
38     typedef long                  TInteger;
39     typedef unsigned long         TNatural;
40     typedef long double           TReal;
41     typedef std::complex< TReal > TComplex;
42     typedef std::string           TString;
43     //! @}
44
45     /*! @defgroup Constructors
46      * Types that describe all base scalar values
47      * @{
48      */
49     //! Default constructor
50     Value( );
51
52     //! Prepare a particular value
53     Value( const std::type_info& i );
54
55     //! Cast constructor(s)
56     Value( const Self& v );
57       {{#s}}
58     Value( const {{s}}& v );
59       {{/s}}
60
61     //! @}
62
63     //! Output cast operator
64       {{#s}}
65     explicit operator {{s}}( ) const;
66       {{/s}}
67
68     //! Assignement operator
69     Self& operator=( const Self& v );
70       {{#s}}
71     Self& operator=( const {{s}}& v );
72       {{/s}}
73
74     //! Comparison operator
75     bool operator<( const Self& v ) const;
76
77     //! Return a string with contained type information.
78     const std::string& GetTypeName( ) const;
79
80     /*! @defgroup Pipeline
81      * Methods to synchronize values in processing pipelines
82      * @{
83      */
84     ProcessObject* GetSource( );
85     const ProcessObject* GetSource( ) const;
86
87     template< class _TObject >
88     void SetSource( _TObject* source );
89     //! @}
90
91     //! Send information to a stream
92     void Print( std::ostream& o ) const;
93
94   protected:
95     /*! @ingroup ScalarTypes
96      * Types that describe all base scalar values
97      * @{
98      */
99     TString  m_TypeName;
100     TBool    m_Bool;
101     TNatural m_Natural;
102     TInteger m_Integer;
103     TReal    m_Real;
104     TComplex m_Complex;
105     TString  m_String;
106     //! @}
107
108     //! @ingroup Pipeline
109     std::weak_ptr< ProcessObject > m_Source;
110
111   }; // end class
112 } // end namespace
113
114 #endif // __cpPlugins__Value__h__
115
116 // eof - $RCSfile$