MeVisLab Toolbox Reference
mlPropertyValue.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2010, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_PROPERTY_VALUE_H
14#define ML_PROPERTY_VALUE_H
15
16
19
20#include "mlVesselGraphSystem.h"
21#include "VesselGraphTypes.h"
22#include "mlLightweight.h"
23
24// boost includes
26#include <boost/ref.hpp>
27#include <boost/tuple/tuple.hpp>
28#include <boost/variant.hpp>
29#include <boost/mpl/contains.hpp>
30#include <boost/mpl/for_each.hpp>
31#include <boost/mpl/less_equal.hpp>
32#include <boost/mpl/integral_c.hpp>
33#include <boost/mpl/vector.hpp>
34#include <boost/mpl/sizeof.hpp>
36
38
40public:
41 typedef boost::mpl::vector<MLint8, MLuint8, MLint16, MLuint16, MLint32, MLuint32, MLuint64, MLint64, double, Vector3, Vector6> SupportedPropertyTypes;
42
44
45 template<typename T>
46 PropertyValue(const T& initialValue) : _variant(initialValue) {};
47
48 bool operator==(const PropertyValue& other) const { return _variant==other._variant; }
49
50 template<typename T>
51 T& get() {
53 return boost::get<StoredType>(_variant);
54 }
55
56 template<typename T>
57 const T& get() const {
59 return boost::get<StoredType>(_variant);
60 }
61
62 template<typename VisitorType>
63 typename VisitorType::result_type apply(VisitorType& visitor) { return lightweight::apply_visitor(visitor, _variant); }
64
65 template<typename VisitorType>
66 typename VisitorType::result_type apply(VisitorType& visitor) const { return lightweight::apply_visitor(visitor, _variant); }
67
68 template<typename VisitorType>
69 typename VisitorType::result_type apply(const VisitorType& visitor) { return lightweight::apply_visitor(visitor, _variant); }
70
71 template<typename VisitorType>
72 typename VisitorType::result_type apply(const VisitorType& visitor) const { return lightweight::apply_visitor(visitor, _variant); }
73
74 size_t which() const { return static_cast<size_t>(_variant.which()); }
75
76private:
77 typedef boost::mpl::transform< SupportedPropertyTypes, lightweight::make_lightweight >::type LightweightPropertyTypes;
78 typedef boost::make_variant_over<LightweightPropertyTypes>::type LightweightVariantType;
79 LightweightVariantType _variant;
80};
81
83
84#endif // __MLPropertyValue_H
@ T
Class PropertyValue, which is used to hold properties of a given set of allowed types in typesafe way...
PropertyValue(const T &initialValue)
VisitorType::result_type apply(VisitorType &visitor)
VisitorType::result_type apply(VisitorType &visitor) const
VisitorType::result_type apply(const VisitorType &visitor) const
const T & get() const
bool operator==(const PropertyValue &other) const
boost::mpl::vector< MLint8, MLuint8, MLint16, MLuint16, MLint32, MLuint32, MLuint64, MLint64, double, Vector3, Vector6 > SupportedPropertyTypes
VisitorType::result_type apply(const VisitorType &visitor)
size_t which() const
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#define VESSELGRAPH_END_NAMESPACE
#define VESSELGRAPH_BEGIN_NAMESPACE
VisitorType::result_type apply_visitor(VisitorType &visitor, VariantType &value)
boost::mpl::if_< typenameboost::mpl::less_equal< boost::mpl::sizeof_< T >, boost::mpl::int_< 8 > >::type, T, heap_storage< T > >::type type