MeVisLab Resolution Independence API
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 // Use standard field stuff
48 SO_SFIELD_CONSTRUCTOR_HEADER(SoSFMLBase);
49 SO_SFIELD_REQUIRED_HEADER(SoSFMLBase);
50
51public:
53 static void initClass();
54
56 virtual void setValue(ML_NAMESPACE::Base* mlBasePtr);
57 virtual ML_NAMESPACE::Base* getValue() const;
58 SbBool readValue(SoInput* in) override;
59 void writeValue(SoOutput* out) const override;
60
62 template <class Type>
63 Type getTypedValue() { return mlbase_cast<Type>(getValue()); }
64
66
72 void addAllowedType(const ML_NAMESPACE::RuntimeType* allowedType);
73
75 template <typename T>
76 void addAllowedType() { addAllowedType(T::getClassTypeId()); }
77
79 std::vector<const ML_NAMESPACE::RuntimeType*> getAllowedTypes() const { return _allowedTypes; }
80
83 bool hasUnallowedType() const { return _unallowedType; }
84
85protected:
87 ML_NAMESPACE::Base* _value;
88
90 std::vector<const ML_NAMESPACE::RuntimeType*> _allowedTypes;
91
95};
96
97#endif
#define INVENTORWRAPPER_API
Library initialization and export macros for platform independecy of project.
The SoSFMLBase field is the interface used by Inventor Nodes to output ML Base objects to the outside...
Definition SoSFMLBase.h:45
std::vector< const ml::RuntimeType * > getAllowedTypes() const
Get list of allowed Base types for this field.
Definition SoSFMLBase.h:79
void addAllowedType()
Same as above, with template parameter where the Base type can be specified directly.
Definition SoSFMLBase.h:76
void writeValue(SoOutput *out) const override
Type getTypedValue()
Get a Base pointer of given Type, returns NULL is the base object is not derived from Type.
Definition SoSFMLBase.h:63
bool _isRefCountedBase
Definition SoSFMLBase.h:94
virtual ml::Base * getValue() const
bool hasUnallowedType() const
return true if the last call of setBaseValue had an unallowed type as argument, getBaseValue will ret...
Definition SoSFMLBase.h:83
ml::Base * _value
pointer to the stored base object
Definition SoSFMLBase.h:87
void addAllowedType(const ml::RuntimeType *allowedType)
Add type to list of allowed types.
SbBool readValue(SoInput *in) override
bool _unallowedType
remember if an unallowed type was assigned to this field
Definition SoSFMLBase.h:93
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:90
virtual void setValue(ml::Base *mlBasePtr)
Field access implementation.