RavEngine
Loading...
Searching...
No Matches
PxFoundation.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// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_FOUNDATION_H
30#define PX_FOUNDATION_H
31
36#include "foundation/Px.h"
37#include "foundation/PxErrors.h"
38#include "foundation/PxFoundationConfig.h"
39#include "foundation/PxErrors.h"
40
41#include <stdarg.h>
42
43#if !PX_DOXYGEN
44namespace physx
45{
46#endif
47
48class PxAllocationListener;
49class PxErrorCallback;
50
56class PX_FOUNDATION_API PxFoundation
57{
58 public:
67 virtual void release() = 0;
68
73
77 virtual void setErrorLevel(PxErrorCode::Enum mask = PxErrorCode::eMASK_ALL) = 0;
78
82 virtual PxErrorCode::Enum getErrorLevel() const = 0;
83
88
92 virtual bool getReportAllocationNames() const = 0;
93
98 virtual void setReportAllocationNames(bool value) = 0;
99
100 virtual void registerAllocationListener(PxAllocationListener& listener) = 0;
101
102 virtual void deregisterAllocationListener(PxAllocationListener& listener) = 0;
103
104 virtual void registerErrorCallback(PxErrorCallback& callback) = 0;
105
106 virtual void deregisterErrorCallback(PxErrorCallback& callback) = 0;
107
108 virtual bool error(PxErrorCode::Enum c, const char* file, int line, const char* messageFmt, ...) = 0;
109
110 virtual bool error(PxErrorCode::Enum, const char* file, int line, const char* messageFmt, va_list) = 0;
111
112 protected:
113 virtual ~PxFoundation()
114 {
115 }
116};
117
118#if !PX_DOXYGEN
119} // namespace physx
120#endif
121
122// PT: use this to make generated code shorter (e.g. from 52 to 24 bytes of assembly (10 to 4 instructions))
123// We must use a macro here to let __FILE__ expand to the proper filename (it doesn't work with an inlined function).
124#define PX_IMPLEMENT_OUTPUT_ERROR \
125template<const int errorCode> \
126static PX_NOINLINE bool outputError(int line, const char* message) \
127{ \
128 return PxGetFoundation().error(PxErrorCode::Enum(errorCode), __FILE__, line, message); \
129}
130
145PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation* PX_CALL_CONV PxCreateFoundation(physx::PxU32 version, physx::PxAllocatorCallback& allocator, physx::PxErrorCallback& errorCallback);
146
147
148PX_C_EXPORT PX_FOUNDATION_API void PX_CALL_CONV PxSetFoundationInstance(physx::PxFoundation& foundation);
149
150
158#if PX_CLANG
159#if PX_LINUX
160#pragma clang diagnostic push
161#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
162#endif // PX_LINUX
163#endif // PX_CLANG
164PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation& PX_CALL_CONV PxGetFoundation();
165#if PX_CLANG
166#if PX_LINUX
167#pragma clang diagnostic pop
168#endif // PX_LINUX
169#endif // PX_CLANG
170
171#if !PX_DOXYGEN
172namespace physx
173{
174#endif
175class PxProfilerCallback;
176class PxAllocatorCallback;
177class PxErrorCallback;
178#if !PX_DOXYGEN
179} // namespace physx
180#endif
181
185PX_C_EXPORT PX_FOUNDATION_API physx::PxProfilerCallback* PX_CALL_CONV PxGetProfilerCallback();
186
190PX_C_EXPORT PX_FOUNDATION_API void PX_CALL_CONV PxSetProfilerCallback(physx::PxProfilerCallback* profiler);
191
195PX_C_EXPORT PX_FOUNDATION_API physx::PxAllocatorCallback* PX_CALL_CONV PxGetAllocatorCallback();
196
201
205PX_C_EXPORT PX_FOUNDATION_API physx::PxErrorCallback* PX_CALL_CONV PxGetErrorCallback();
206
210PX_C_EXPORT PX_FOUNDATION_API physx::PxErrorCallback* PX_CALL_CONV PxGetBroadcastError();
211
215PX_C_EXPORT PX_FOUNDATION_API physx::PxU32 PX_CALL_CONV PxGetWarnOnceTimeStamp();
216
220PX_C_EXPORT PX_FOUNDATION_API void PX_CALL_CONV PxDecFoundationRefCount();
221
225PX_C_EXPORT PX_FOUNDATION_API void PX_CALL_CONV PxIncFoundationRefCount();
226
228#endif
229
Abstract listener class that listens to allocation and deallocation events from the foundation memory...
Definition PxBroadcast.h:49
Abstract base class for an application defined memory allocator that can be used by the Nv library.
Definition PxAllocatorCallback.h:53
User defined interface class. Used by the library to emit debug information.
Definition PxErrorCallback.h:51
Foundation SDK singleton class.
Definition PxFoundation.h:57
virtual void setReportAllocationNames(bool value)=0
virtual PxAllocatorCallback & getAllocatorCallback()=0
virtual PxErrorCode::Enum getErrorLevel() const =0
virtual void release()=0
Destroys the instance it is called on.
virtual PxErrorCallback & getErrorCallback()=0
virtual void setErrorLevel(PxErrorCode::Enum mask=PxErrorCode::eMASK_ALL)=0
virtual bool getReportAllocationNames() const =0
The pure virtual callback interface for general purpose instrumentation and profiling of GameWorks mo...
Definition PxProfiler.h:42
PX_C_EXPORT PX_FOUNDATION_API void PX_CALL_CONV PxSetProfilerCallback(physx::PxProfilerCallback *profiler)
Set the callback that will be used for all profiling.
Definition FdFoundation.cpp:289
PX_C_EXPORT PX_FOUNDATION_API void PX_CALL_CONV PxDecFoundationRefCount()
Decrement the ref count of PxFoundation.
Definition FdFoundation.cpp:299
#define PX_CALL_CONV
Definition PxPreprocessor.h:299
PX_C_EXPORT PX_FOUNDATION_API physx::PxAllocatorCallback *PX_CALL_CONV PxGetAllocatorCallback()
Get the allocator callback.
Definition FdFoundation.cpp:259
PX_C_EXPORT PX_FOUNDATION_API physx::PxU32 PX_CALL_CONV PxGetWarnOnceTimeStamp()
Get the warn once timestamp.
Definition FdFoundation.cpp:294
PX_C_EXPORT PX_FOUNDATION_API physx::PxErrorCallback *PX_CALL_CONV PxGetErrorCallback()
Get the error callback.
Definition FdFoundation.cpp:269
PX_C_EXPORT PX_FOUNDATION_API physx::PxProfilerCallback *PX_CALL_CONV PxGetProfilerCallback()
Get the callback that will be used for all profiling.
Definition FdFoundation.cpp:284
PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation *PX_CALL_CONV PxCreateFoundation(physx::PxU32 version, physx::PxAllocatorCallback &allocator, physx::PxErrorCallback &errorCallback)
Creates an instance of the foundation class.
Definition FdFoundation.cpp:248
PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation &PX_CALL_CONV PxGetFoundation()
Retrieves the Foundation SDK after it has been created.
Definition FdFoundation.cpp:279
PX_C_EXPORT PX_FOUNDATION_API physx::PxErrorCallback *PX_CALL_CONV PxGetBroadcastError()
Get the broadcasting error callback.
Definition FdFoundation.cpp:274
PX_C_EXPORT PX_FOUNDATION_API physx::PxAllocatorCallback *PX_CALL_CONV PxGetBroadcastAllocator()
Get the broadcasting allocator callback.
Definition FdFoundation.cpp:264
PX_C_EXPORT PX_FOUNDATION_API void PX_CALL_CONV PxIncFoundationRefCount()
Increment the ref count of PxFoundation.
Definition FdFoundation.cpp:304
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Enum
Definition PxErrors.h:52