HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
9 /// @file
10 /// User data base class for shader generation
11 
13 
15 
16 class GenUserData;
17 
18 /// Shared pointer to a GenUserData
19 using GenUserDataPtr = std::shared_ptr<GenUserData>;
20 
21 /// Shared pointer to a constant GenUserData
22 using ConstGenUserDataPtr = std::shared_ptr<const GenUserData>;
23 
24 /// @class GenUserData
25 /// Base class for custom user data needed during shader generation.
26 class MX_GENSHADER_API GenUserData : public std::enable_shared_from_this<GenUserData>
27 {
28  public:
29  virtual ~GenUserData() { }
30 
31  /// Return a shared pointer for this object.
33  {
34  return shared_from_this();
35  }
36 
37  /// Return a shared pointer for this object.
39  {
40  return shared_from_this();
41  }
42 
43  /// Return this object cast to a templated type.
44  template <class T> shared_ptr<T> asA()
45  {
46  return std::dynamic_pointer_cast<T>(getSelf());
47  }
48 
49  /// Return this object cast to a templated type.
50  template <class T> shared_ptr<const T> asA() const
51  {
52  return std::dynamic_pointer_cast<const T>(getSelf());
53  }
54 
55  protected:
57 };
58 
60 
61 #endif // MATERIALX_GENCONTEXT_H
shared_ptr< const T > asA() const
Return this object cast to a templated type.
Definition: GenUserData.h:50
GenUserDataPtr getSelf()
Return a shared pointer for this object.
Definition: GenUserData.h:32
virtual ~GenUserData()
Definition: GenUserData.h:29
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
ConstGenUserDataPtr getSelf() const
Return a shared pointer for this object.
Definition: GenUserData.h:38
std::shared_ptr< const GenUserData > ConstGenUserDataPtr
Shared pointer to a constant GenUserData.
Definition: GenUserData.h:22
#define MX_GENSHADER_API
Definition: Export.h:18
std::shared_ptr< GenUserData > GenUserDataPtr
Shared pointer to a GenUserData.
Definition: GenUserData.h:19
shared_ptr< T > asA()
Return this object cast to a templated type.
Definition: GenUserData.h:44
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26