MaterialX 1.39.1
Loading...
Searching...
No Matches
GenUserData.h
Go to the documentation of this file.
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_GENUSERDATA_H
7#define MATERIALX_GENUSERDATA_H
8
11
13
14MATERIALX_NAMESPACE_BEGIN
15
16class GenUserData;
17
19using GenUserDataPtr = std::shared_ptr<GenUserData>;
20
22using ConstGenUserDataPtr = std::shared_ptr<const GenUserData>;
23
26class MX_GENSHADER_API GenUserData : public std::enable_shared_from_this<GenUserData>
27{
28 public:
29 virtual ~GenUserData() { }
30
33 {
34 return shared_from_this();
35 }
36
39 {
40 return shared_from_this();
41 }
42
44 template <class T> shared_ptr<T> asA()
45 {
46 return std::dynamic_pointer_cast<T>(getSelf());
47 }
48
50 template <class T> shared_ptr<const T> asA() const
51 {
52 return std::dynamic_pointer_cast<const T>(getSelf());
53 }
54
55 protected:
56 GenUserData() { }
57};
58
59MATERIALX_NAMESPACE_END
60
61#endif // MATERIALX_GENCONTEXT_H
std::shared_ptr< const GenUserData > ConstGenUserDataPtr
Shared pointer to a constant GenUserData.
Definition: GenUserData.h:22
std::shared_ptr< GenUserData > GenUserDataPtr
Shared pointer to a GenUserData.
Definition: GenUserData.h:19
Macros for declaring imported and exported symbols.
Base class for custom user data needed during shader generation.
Definition: GenUserData.h:27
shared_ptr< const T > asA() const
Return this object cast to a templated type.
Definition: GenUserData.h:50
ConstGenUserDataPtr getSelf() const
Return a shared pointer for this object.
Definition: GenUserData.h:38
shared_ptr< T > asA()
Return this object cast to a templated type.
Definition: GenUserData.h:44
GenUserDataPtr getSelf()
Return a shared pointer for this object.
Definition: GenUserData.h:32