RavEngine
Loading...
Searching...
No Matches
SnConvX_MetaData.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26
27#ifndef SN_CONVX_METADATA_H
28#define SN_CONVX_METADATA_H
29
30#include "common/PxMetaDataFlags.h"
31
32#include "SnConvX_Output.h"
33#include "serialization/SnSerialUtils.h"
34
35namespace physx { namespace Sn {
36
37#if PX_VC
38#pragma warning (push)
39#pragma warning (disable : 4371) //layout of class may have changed from a previous version of the compiler due to better packing of member
40#endif
41
42
43 // PT: beware, must match corresponding structure in PxMetaData.h
45 {
47 {
48 memset(this, 0, sizeof(*this));
49 }
50 bool isVTablePtr() const;
51
52 const char* mType;
53 const char* mName;
54 int mOffset;
55 int mSize;
56 int mCount;
58 int mFlags;
60 };
61
63 {
64 PxI32 mType;
65 PxI32 mName;
66 int mOffset;
67 int mSize;
68 int mCount;
70 int mFlags;
72 };
73
75 {
76 PxI64 mType;
77 PxI64 mName;
78 int mOffset;
79 int mSize;
80 int mCount;
82 int mFlags;
84 };
85
87 {
88 PxMetaDataEntry entry;
89 int offset;
90 };
91
93 {
94 ConvertCallback cb;
95 };
96
97 class MetaData;
98
99 struct MetaClass : public PxUserAllocated
100 {
101 bool getFieldByType(const char* type, PxMetaDataEntry& entry) const;
102 bool getFieldByName(const char* name, PxMetaDataEntry& entry) const;
103 bool check(const MetaData& owner);
104
105 ConvertCallback mCallback;
106 MetaClass* mMaster;
107 const char* mClassName;
108 int mSize;
109 int mDepth;
110 PsArray<PxMetaDataEntry> mBaseClasses;
111 PsArray<PxMetaDataEntry> mFields;
112 bool mProcessed;
113
114// int mNbEntries;
115// ExtraDataEntry2 mEntries[256];
116
117 private:
118 void checkAndCompleteClass(const MetaData& owner, int& startOffset, int& nbBytes);
119 };
120
121 enum MetaDataType
122 {
123 META_DATA_NONE,
124 META_DATA_SRC,
125 META_DATA_DST
126 };
127
128 class ConvX;
130 {
131 public:
133 ~MetaData();
134
135 bool load(PxInputStream& inputStream, MetaDataType type);
136
137 inline_ MetaDataType getType() const { return mType; }
138 inline_ int getVersion() const { return mVersion; }
139 inline_ int getPtrSize() const { return mSizeOfPtr; }
140 inline_ int getPlatformTag() const { return mPlatformTag; }
141 inline_ int getGaussMapLimit() const { return mGaussMapLimit; }
142 inline_ int getNbMetaClasses() const { return int(mMetaClasses.size()); }
143 inline_ MetaClass* getMetaClass(unsigned int i) const { return mMetaClasses[i]; }
144 inline_ bool getFlip() const { return mFlip; }
145
146 MetaClass* getMetaClass(const char* name) const;
147 MetaClass* getMetaClass(PxConcreteType::Enum concreteType) const;
148 MetaClass* addNewClass(const char* name, int size, MetaClass* master=NULL, ConvertCallback callback=NULL);
149
150 bool compare(const MetaData& candidate) const;
151 private:
152 MetaData& operator=(const MetaData&);
153 Sn::ConvX& mConvX;
154 MetaDataType mType;
155 int mNbEntries;
156 PxMetaDataEntry* mEntries;
157 char* mStringTable;
158 PsArray<MetaClass*> mMetaClasses;
159 int mVersion;
160 char mBinaryVersionGuid[SN_BINARY_VERSION_GUID_NUM_CHARS + 1];
161 int mSizeOfPtr;
162 int mPlatformTag;
163 int mGaussMapLimit;
164 bool mFlip;
165
166 PsArray< PxPair<PxConcreteType::Enum, PxU32> > mConcreteTypeTable;
167
168 inline_ const char* offsetToText(const char* text) const
169 {
170 const size_t offset = size_t(text);
171 const PxU32 offset32 = PxU32(offset);
172// if(offset==-1)
173 if(offset32==0xffffffff)
174 return NULL;
175 return mStringTable + offset32;
176 }
177 friend struct MetaClass;
178 };
179
180 PxU64 peek(int size, const char* buffer, int flags=0);
181
182#if PX_VC
183#pragma warning (pop)
184#endif
185} }
186
187#endif
Input stream class for I/O.
Definition PxIO.h:50
Definition PxUserAllocated.h:43
Definition SnConvX.h:78
Definition SnConvX_MetaData.h:130
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition SnConvX_MetaData.h:93
Definition SnConvX_MetaData.h:87
Definition SnConvX_MetaData.h:100
Definition SnConvX_MetaData.h:63
int mSize
sizeof(Type)
Definition SnConvX_MetaData.h:67
int mOffsetSize
Offset of dynamic size param, for dynamic arrays.
Definition SnConvX_MetaData.h:69
int mFlags
Field parameters.
Definition SnConvX_MetaData.h:70
int mOffset
Offset from the start of the class (ie from "this", field is located at "this"+Offset)
Definition SnConvX_MetaData.h:66
int mAlignment
Explicit alignment added for DE1340.
Definition SnConvX_MetaData.h:71
PxI32 mType
Field type (bool, byte, quaternion, etc)
Definition SnConvX_MetaData.h:64
int mCount
Number of items of type Type (0 for dynamic sizes)
Definition SnConvX_MetaData.h:68
PxI32 mName
Field name (appears exactly as in the source file)
Definition SnConvX_MetaData.h:65
Definition SnConvX_MetaData.h:75
int mFlags
Field parameters.
Definition SnConvX_MetaData.h:82
int mCount
Number of items of type Type (0 for dynamic sizes)
Definition SnConvX_MetaData.h:80
int mAlignment
Explicit alignment added for DE1340.
Definition SnConvX_MetaData.h:83
int mSize
sizeof(Type)
Definition SnConvX_MetaData.h:79
int mOffsetSize
Offset of dynamic size param, for dynamic arrays.
Definition SnConvX_MetaData.h:81
int mOffset
Offset from the start of the class (ie from "this", field is located at "this"+Offset)
Definition SnConvX_MetaData.h:78
PxI64 mType
Field type (bool, byte, quaternion, etc)
Definition SnConvX_MetaData.h:76
PxI64 mName
Field name (appears exactly as in the source file)
Definition SnConvX_MetaData.h:77
Definition SnConvX_MetaData.h:45
int mAlignment
Explicit alignment added for DE1340.
Definition SnConvX_MetaData.h:59
int mSize
sizeof(Type)
Definition SnConvX_MetaData.h:55
int mOffsetSize
Offset of dynamic size param, for dynamic arrays.
Definition SnConvX_MetaData.h:57
int mOffset
Offset from the start of the class (ie from "this", field is located at "this"+Offset)
Definition SnConvX_MetaData.h:54
int mFlags
Field parameters.
Definition SnConvX_MetaData.h:58
int mCount
Number of items of type Type (0 for dynamic sizes)
Definition SnConvX_MetaData.h:56
const char * mName
Field name (appears exactly as in the source file)
Definition SnConvX_MetaData.h:53
const char * mType
Field type (bool, byte, quaternion, etc)
Definition SnConvX_MetaData.h:52