MACE  1.0.0
 All Classes Namespaces Files Functions Variables Enumerations Defines
libs/reflect/include/mace/reflect/value_base.hpp
00001 #ifndef _MACE_REFLECT_VALUE_BASE_HPP_
00002 #define _MACE_REFLECT_VALUE_BASE_HPP_
00003 #include <typeinfo>
00004 #include <mace/reflect/value_visitor.hpp>
00005 
00006 namespace mace { namespace reflect {
00007   namespace detail {
00008     struct place_holder;
00009   };
00010 
00011 class iterator;
00012 class value;
00013 class const_iterator;
00014 
00043   class value_base {
00044     public:
00045       value_base();
00046       value_base( const value_base& );
00047       ~value_base();
00048 
00049     bool           is_array()const;
00050     bool           is_function()const;
00051     size_t         size()const;
00052 
00058     iterator       begin();
00059     const_iterator begin()const;
00060     iterator       end();
00061     const_iterator end()const;
00062 
00066       value operator()()const;
00067       value operator()();
00068 
00069       template<typename P1>
00070       value operator()(P1)const;
00071       template<typename P1>
00072       value operator()(P1);
00073 
00074       template<typename P1, typename P2>
00075       value operator()(P1,P2)const;
00076       template<typename P1,typename P2>
00077       value operator()(P1,P2);
00078 
00079 
00080       const char* type()const;
00081   
00082       void visit( read_value_visitor&& v )const;
00083       void visit( write_value_visitor&& v );
00084 
00085       template<typename T>
00086       T as()const;
00087 
00088       template<typename T>
00089       void set_as( const T&& );
00090 
00091       bool operator!()const;
00092 
00093       template<typename T>
00094       inline T& get();
00095       
00096       template<typename T>
00097       inline const T& get()const;
00098 
00099       template<typename T>
00100       inline const T* ptr()const; 
00101 
00102       template<typename T>
00103       inline T* ptr(); 
00104 
00105       bool       has_field( const std::string& field )const;
00106 
00107     protected:
00108       friend class value;
00109       friend class value_ref;
00110       friend class value_cref;
00111       inline const detail::place_holder* get_holder()const;
00112       inline       detail::place_holder* get_holder();
00113 
00114       char held[3*sizeof(void*)];
00115   };
00116 
00117 } }
00118 
00119 #endif