MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
40{
41public:
42 typedef boost::mpl::vector<MLint8, MLuint8, MLint16, MLuint16, MLint32, MLuint32, MLuint64, MLint64, double, Vector3,
43 Vector6>
45
47
48 template <typename T> PropertyValue(const T& initialValue)
49 : _variant(initialValue) {};
50
51 bool operator==(const PropertyValue& other) const
52 {
53 return _variant == other._variant;
54 }
55
56 template <typename T> T& get()
57 {
59 return boost::get<StoredType>(_variant);
60 }
61
62 template <typename T> const T& get() const
63 {
65 return boost::get<StoredType>(_variant);
66 }
67
68 template <typename VisitorType> typename VisitorType::result_type apply(VisitorType& visitor)
69 {
70 return lightweight::apply_visitor(visitor, _variant);
71 }
72
73 template <typename VisitorType> typename VisitorType::result_type apply(VisitorType& visitor) const
74 {
75 return lightweight::apply_visitor(visitor, _variant);
76 }
77
78 template <typename VisitorType> typename VisitorType::result_type apply(const VisitorType& visitor)
79 {
80 return lightweight::apply_visitor(visitor, _variant);
81 }
82
83 template <typename VisitorType> typename VisitorType::result_type apply(const VisitorType& visitor) const
84 {
85 return lightweight::apply_visitor(visitor, _variant);
86 }
87
88 size_t which() const
89 {
90 return static_cast<size_t>(_variant.which());
91 }
92
93private:
94 typedef boost::mpl::transform<SupportedPropertyTypes, lightweight::make_lightweight>::type LightweightPropertyTypes;
95 typedef boost::make_variant_over<LightweightPropertyTypes>::type LightweightVariantType;
96 LightweightVariantType _variant;
97};
98
100
101#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.
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
Definition mlTypeDefs.h:424
unsigned int MLuint32
Definition mlTypeDefs.h:185
unsigned char MLuint8
Definition mlTypeDefs.h:109
unsigned short MLuint16
Definition mlTypeDefs.h:142
signed short MLint16
Definition mlTypeDefs.h:125
char MLint8
Definition mlTypeDefs.h:97
INT64 MLint64
Include 64-bit integer support for Windows or Unix.
Definition mlTypeDefs.h:411
signed int MLint32
Definition mlTypeDefs.h:161
#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