forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenUserData.h
61 lines (46 loc) · 1.44 KB
/
GenUserData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
// All rights reserved. See LICENSE.txt for license.
//
#ifndef MATERIALX_GENUSERDATA_H
#define MATERIALX_GENUSERDATA_H
/// @file
/// User data base class for shader generation
#include <MaterialXGenShader/Export.h>
MATERIALX_NAMESPACE_BEGIN
class GenUserData;
/// Shared pointer to a GenUserData
using GenUserDataPtr = std::shared_ptr<GenUserData>;
/// Shared pointer to a constant GenUserData
using ConstGenUserDataPtr = std::shared_ptr<const GenUserData>;
/// @class GenUserData
/// Base class for custom user data needed during shader generation.
class MX_GENSHADER_API GenUserData : public std::enable_shared_from_this<GenUserData>
{
public:
virtual ~GenUserData() { }
/// Return a shared pointer for this object.
GenUserDataPtr getSelf()
{
return shared_from_this();
}
/// Return a shared pointer for this object.
ConstGenUserDataPtr getSelf() const
{
return shared_from_this();
}
/// Return this object cast to a templated type.
template<class T> shared_ptr<T> asA()
{
return std::dynamic_pointer_cast<T>(getSelf());
}
/// Return this object cast to a templated type.
template<class T> shared_ptr<const T> asA() const
{
return std::dynamic_pointer_cast<const T>(getSelf());
}
protected:
GenUserData() { }
};
MATERIALX_NAMESPACE_END
#endif // MATERIALX_GENCONTEXT_H