1 | // |
2 | // Redistribution and use in source and binary forms, with or without |
3 | // modification, are permitted provided that the following conditions |
4 | // are met: |
5 | // * Redistributions of source code must retain the above copyright |
6 | // notice, this list of conditions and the following disclaimer. |
7 | // * Redistributions in binary form must reproduce the above copyright |
8 | // notice, this list of conditions and the following disclaimer in the |
9 | // documentation and/or other materials provided with the distribution. |
10 | // * Neither the name of NVIDIA CORPORATION nor the names of its |
11 | // contributors may be used to endorse or promote products derived |
12 | // from this software without specific prior written permission. |
13 | // |
14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY |
15 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
17 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
18 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
19 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
20 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
21 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
22 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | // |
26 | // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved. |
27 | #ifndef PXPVDSDK_PXPVDDATASTREAMHELPERS_H |
28 | #define PXPVDSDK_PXPVDDATASTREAMHELPERS_H |
29 | |
30 | /** \addtogroup pvd |
31 | @{ |
32 | */ |
33 | #include "PxPvdObjectModelBaseTypes.h" |
34 | |
35 | #if !PX_DOXYGEN |
36 | namespace physx |
37 | { |
38 | namespace pvdsdk |
39 | { |
40 | #endif |
41 | |
42 | class PvdPropertyDefinitionHelper |
43 | { |
44 | protected: |
45 | virtual ~PvdPropertyDefinitionHelper() |
46 | { |
47 | } |
48 | |
49 | public: |
50 | /** |
51 | Push a name c such that it appends such as a.b.c. |
52 | */ |
53 | virtual void pushName(const char* inName, const char* inAppendStr = "." ) = 0; |
54 | /** |
55 | Push a name c such that it appends like a.b[c] |
56 | */ |
57 | virtual void pushBracketedName(const char* inName, const char* leftBracket = "[" , const char* rightBracket = "]" ) = 0; |
58 | /** |
59 | * Pop the current name |
60 | */ |
61 | virtual void popName() = 0; |
62 | |
63 | virtual void clearNameStack() = 0; |
64 | /** |
65 | * Get the current name at the top of the name stack. |
66 | * Would return "a.b.c" or "a.b[c]" in the above examples. |
67 | */ |
68 | virtual const char* getTopName() = 0; |
69 | |
70 | virtual void addNamedValue(const char* name, uint32_t value) = 0; |
71 | virtual void clearNamedValues() = 0; |
72 | virtual DataRef<NamedValue> getNamedValues() = 0; |
73 | |
74 | /** |
75 | * Define a property using the top of the name stack and the passed-in semantic |
76 | */ |
77 | virtual void createProperty(const NamespacedName& clsName, const char* inSemantic, const NamespacedName& dtypeName, |
78 | PropertyType::Enum propType = PropertyType::Scalar) = 0; |
79 | |
80 | template <typename TClsType, typename TDataType> |
81 | void createProperty(const char* inSemantic = "" , PropertyType::Enum propType = PropertyType::Scalar) |
82 | { |
83 | createProperty(getPvdNamespacedNameForType<TClsType>(), inSemantic, getPvdNamespacedNameForType<TDataType>(), |
84 | propType); |
85 | } |
86 | |
87 | // The datatype used for instances needs to be pointer unless you actually have pvdsdk::InstanceId members on your |
88 | // value structs. |
89 | virtual void addPropertyMessageArg(const NamespacedName& inDatatype, uint32_t inOffset, uint32_t inSize) = 0; |
90 | |
91 | template <typename TDataType> |
92 | void addPropertyMessageArg(uint32_t offset) |
93 | { |
94 | addPropertyMessageArg(getPvdNamespacedNameForType<TDataType>(), offset, static_cast<uint32_t>(sizeof(TDataType))); |
95 | } |
96 | virtual void addPropertyMessage(const NamespacedName& clsName, const NamespacedName& msgName, |
97 | uint32_t inStructSizeInBytes) = 0; |
98 | template <typename TClsType, typename TMsgType> |
99 | void addPropertyMessage() |
100 | { |
101 | addPropertyMessage(getPvdNamespacedNameForType<TClsType>(), getPvdNamespacedNameForType<TMsgType>(), |
102 | static_cast<uint32_t>(sizeof(TMsgType))); |
103 | } |
104 | virtual void clearPropertyMessageArgs() = 0; |
105 | |
106 | void clearBufferedData() |
107 | { |
108 | clearNameStack(); |
109 | clearPropertyMessageArgs(); |
110 | clearNamedValues(); |
111 | } |
112 | }; |
113 | |
114 | #if !PX_DOXYGEN |
115 | } // pvdsdk |
116 | } // physx |
117 | #endif |
118 | |
119 | /** @} */ |
120 | #endif // PXPVDSDK_PXPVDDATASTREAMHELPERS_H |
121 | |