MeVisLab Resolution Independence API
Loading...
Searching...
No Matches
SoSFMLBase.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, 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 SO_SFMLBASE_H
14#define SO_SFMLBASE_H
15
18
21
22#include <ThirdPartyWarningsDisable.h>
23#include <Inventor/fields/SoSubField.h>
24#include <Inventor/SbLinear.h>
25#include <vector>
26#include <ThirdPartyWarningsRestore.h>
27
28#include <mlDataTypes.h>
29#include <mlTypeDefs.h>
30#include <mlBase.h>
31
32//=============================================================
35
44//=============================================================
45class INVENTORWRAPPER_API SoSFMLBase : public SoSField
46{
47
48 // Use standard field stuff
49 SO_SFIELD_CONSTRUCTOR_HEADER(SoSFMLBase);
50 SO_SFIELD_REQUIRED_HEADER(SoSFMLBase);
51
52public:
54 static void initClass();
55
57 virtual void setValue(ML_NAMESPACE::Base* mlBasePtr);
58 virtual ML_NAMESPACE::Base* getValue() const;
59 SbBool readValue(SoInput* in) override;
60 void writeValue(SoOutput* out) const override;
61
63 template <class Type> Type getTypedValue()
64 {
65 return mlbase_cast<Type>(getValue());
66 }
67
69
75 void addAllowedType(const ML_NAMESPACE::RuntimeType* allowedType);
76
78 template <typename T> void addAllowedType()
79 {
80 addAllowedType(T::getClassTypeId());
81 }
82
84 std::vector<const ML_NAMESPACE::RuntimeType*> getAllowedTypes() const
85 {
86 return _allowedTypes;
87 }
88
91 bool hasUnallowedType() const
92 {
93 return _unallowedType;
94 }
95
96protected:
98 ML_NAMESPACE::Base* _value;
99
101 std::vector<const ML_NAMESPACE::RuntimeType*> _allowedTypes;
102
106};
107
108#endif
#define INVENTORWRAPPER_API
Library initialization and export macros for platform independecy of project.
std::vector< const ml::RuntimeType * > getAllowedTypes() const
Returns a list of allowed Base types for this field.
Definition SoSFMLBase.h:84
void addAllowedType()
Same as above, with template parameter where the Base type can be specified directly.
Definition SoSFMLBase.h:78
void writeValue(SoOutput *out) const override
Type getTypedValue()
Returns a Base pointer of given Type, returns NULL if the base object is not derived from Type.
Definition SoSFMLBase.h:63
bool _isRefCountedBase
Definition SoSFMLBase.h:105
virtual ml::Base * getValue() const
bool hasUnallowedType() const
Definition SoSFMLBase.h:91
ml::Base * _value
Pointer to the stored base object.
Definition SoSFMLBase.h:98
void addAllowedType(const ml::RuntimeType *allowedType)
SbBool readValue(SoInput *in) override
bool _unallowedType
Remember if an unallowed type was assigned to this field.
Definition SoSFMLBase.h:104
static void initClass()
Initializes field class, setting up runtime type info.
std::vector< const ml::RuntimeType * > _allowedTypes
List of allowed Base types. If empty, any type is allowed.
Definition SoSFMLBase.h:101
virtual void setValue(ml::Base *mlBasePtr)
Field access implementation.