MeVisLab Toolbox Reference
mlPropertiesMacros.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 // Defines convenience-macros for backward-compatible access to properties of graph-elements.
14 
15 #ifndef ML_PROPERTIES_MACROS_H
16 #define ML_PROPERTIES_MACROS_H
17 
19 
20 #define STATIC_CASTED_GRAPH_PROPERTY(VisibleType, StoredType, lowerCaseName, upperCaseName) \
21 private: \
22  DefaultPropertyAccessor<StoredType> _##lowerCaseName##Accessor; \
23 public: \
24  VisibleType get##upperCaseName() const { return static_cast<VisibleType>(_##lowerCaseName##Accessor.get(*this)); } \
25  void set##upperCaseName(const VisibleType& newValue) { _##lowerCaseName##Accessor.set(*this, static_cast<StoredType>(newValue)); }
26 
27 #if ML_DEPRECATED_SINCE(3,5,0)
28 #define STATIC_GRAPH_PROPERTY(Type, lowerCaseName, upperCaseName) \
29 private: \
30  DefaultPropertyAccessor<Type> _##lowerCaseName##Accessor; \
31 public: \
32  ML_DEPRECATED Type& lowerCaseName() { return _##lowerCaseName##Accessor(*this); } \
33  Type get##upperCaseName() const { return Type(_##lowerCaseName##Accessor.get(*this)); } \
34  void set##upperCaseName(const Type& newValue) { _##lowerCaseName##Accessor.set(*this, newValue); }
35 
36 #else
37 
38 #define STATIC_GRAPH_PROPERTY(Type, lowerCaseName, upperCaseName) \
39 private: \
40  DefaultPropertyAccessor<Type> _##lowerCaseName##Accessor; \
41 public: \
42  Type get##upperCaseName() const { return Type(_##lowerCaseName##Accessor.get(*this)); } \
43  void set##upperCaseName(const Type& newValue) { _##lowerCaseName##Accessor.set(*this, newValue); }
44 
45 #endif
46 
47 #define READ_OLD_STATIC_PROPERTY(Type, parent, tagName, setFunction) \
48  { \
49  Type tmp; \
50  parent->readChild(tmp, tagName); \
51  setFunction(tmp); \
52  }
53 
54 #endif