Main Page Class List Class Members

NvBlastTkCommon.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27
28
29 #ifndef NVBLASTTKCOMMON_H
30 #define NVBLASTTKCOMMON_H
31
32
33 #include "NvBlastGlobals.h"
34 #include "NvBlastTkGUID.h"
35
36
37 // Macro to define standard object classes. An intermediate class is defined which holds common implementations.
38 #define NVBLASTTK_IMPL_DECLARE(_name) \
39 class Tk##_name##Type : public Tk##_name \
40 { \
41 public: \
42 /* Blank constructor generates a new NvBlastID and informs framework */ \
43 Tk##_name##Type() \
44 { \
45 memset(&m_ID, 0, sizeof(NvBlastID)); \
46 setID(TkGenerateGUID(this)); \
47 TkFrameworkImpl::get()->onCreate(*this); \
48 } \
49 \
50 /* This constructor takes an existing NvBlastID and informs framework */ \
51 Tk##_name##Type(const NvBlastID& id) \
52 { \
53 memset(&m_ID, 0, sizeof(NvBlastID)); \
54 setID(id); \
55 TkFrameworkImpl::get()->onCreate(*this); \
56 } \
57 \
58 /* Destructor informs framework */ \
59 ~Tk##_name##Type() { TkFrameworkImpl::get()->onDestroy(*this); } \
60 \
61 /* Begin TkIdentifiable */ \
62 virtual void setID(const NvBlastID& id) override \
63 { \
64 /* Inform framework of ID change */ \
65 TkFrameworkImpl::get()->onIDChange(*this, m_ID, id); \
66 m_ID = id; \
67 } \
68 virtual const NvBlastID& getID() const override { return getIDInternal(); } \
69 virtual const TkType& getType() const override { return s_type; } \
70 /* End TkIdentifiable */ \
71 \
72 /* Begin public API */ \
73 \
74 /* Inline method for internal access to NvBlastID */ \
75 const NvBlastID& getIDInternal() const { return m_ID; } \
76 \
77 /* End public API */ \
78 \
79 /* Static type information */ \
80 static TkTypeImpl s_type; \
81 \
82 private: \
83 NvBlastID m_ID; /* NvBlastID for a TkIdentifiable object */ \
84 }; \
85 \
86 /* Derive object implementation from common implementation class above */ \
87 class Tk##_name##Impl final : public Tk##_name##Type
88
89
90 // Macro to declare standard object interfaces, enums, etc.
91 #define NVBLASTTK_IMPL_DEFINE_IDENTIFIABLE(_id0, _id1, _id2, _id3) \
92 /* Begin TkObject */ \
93 virtual void release() override; \
94 /* End TkObject */ \
95 \
96 /* Enums */ \
97 \
98 /* Generate a ClassID enum used to identify this TkIdentifiable. */ \
99 enum { ClassID = NVBLAST_FOURCC(_id0, _id1, _id2, _id3) }
100
101
102 // Macro to define class type data
103 #define NVBLASTTK_DEFINE_TYPE_IDENTIFIABLE(_name) \
104 TkTypeImpl Tk##_name##Type::s_type("Tk" #_name, Tk##_name##Impl::ClassID, 0)
105
106
107 #endif // ifndef NVBLASTTKCOMMON_H
NvBlastGlobals.h
NvBlastTkGUID.h