MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLVesselGraph/Properties/mlPropertyValue.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00005 
00010 //----------------------------------------------------------------------------------
00011 
00012 #ifndef __MLPropertyValue_H
00013 #define __MLPropertyValue_H
00014 
00015 // Local includes
00016 #include "mlVesselGraphSystem.h"
00017 #include "mlLightweight.hpp"
00018 
00019 // ML includes
00020 #include <mlTypeDefs.h>
00021 #include <mlLinearAlgebra.h>
00022 #include <mlTreeNode.h>
00023 
00024 // boost includes
00025 #include "mlSystemWarningsDisable.h"
00026 #include <boost/ref.hpp>
00027 #include <boost/tuple/tuple.hpp>
00028 #include <boost/variant.hpp>
00029 #include <boost/mpl/contains.hpp>
00030 #include <boost/mpl/for_each.hpp>
00031 #include <boost/mpl/less_equal.hpp>
00032 #include <boost/mpl/integral_c.hpp>
00033 #include <boost/mpl/vector.hpp>
00034 #include <boost/mpl/sizeof.hpp>
00035 #include "mlSystemWarningsRestore.h"
00036 
00037 ML_START_NAMESPACE
00038 
00039 class PropertyValue {
00040 public:
00041   typedef boost::mpl::vector<MLint8, MLuint8, MLint16, MLuint16, MLint32, MLuint32, MLuint64, MLint64, double, Vector3, Vector6> SupportedPropertyTypes;
00042 
00043   PropertyValue() {};
00044 
00045   template<typename T>
00046   PropertyValue(const T& initialValue) : _variant(initialValue) {};
00047 
00048   bool operator==(const PropertyValue& other) const { return _variant==other._variant; }
00049 
00050   template<typename T>
00051   T& get() { return lightweight::get<T>(_variant); }
00052 
00053   template<typename T>
00054   const T& get() const { return lightweight::get<T>(_variant); }
00055 
00056   template<typename VisitorType>
00057   typename VisitorType::result_type apply(VisitorType& visitor) { return lightweight::apply_visitor(visitor, _variant); }
00058 
00059   template<typename VisitorType>
00060   typename VisitorType::result_type apply(VisitorType& visitor) const { return lightweight::apply_visitor(visitor, _variant); }
00061 
00062   template<typename VisitorType>
00063   typename VisitorType::result_type apply(const VisitorType& visitor) { return lightweight::apply_visitor(visitor, _variant); }
00064 
00065   template<typename VisitorType>
00066   typename VisitorType::result_type apply(const VisitorType& visitor) const { return lightweight::apply_visitor(visitor, _variant); }
00067 
00068   size_t which() const { return _variant.which(); }
00069 
00070 private:
00071   typedef boost::mpl::transform< SupportedPropertyTypes, lightweight::make_lightweight >::type LightweightPropertyTypes;
00072   typedef boost::make_variant_over<LightweightPropertyTypes>::type LightweightVariantType;
00073   LightweightVariantType _variant;
00074 };
00075 
00076 ML_END_NAMESPACE
00077 
00078 #endif // __MLPropertyValue_H