RavEngine
Loading...
Searching...
No Matches
PxDefaultStreams.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_DEFAULT_STREAMS_H
30#define PX_DEFAULT_STREAMS_H
35#include <stdio.h>
36#include "common/PxPhysXCommonConfig.h"
37#include "foundation/PxIO.h"
38#include "foundation/PxFoundation.h"
39
40typedef FILE* PxFileHandle;
41
42#if !PX_DOXYGEN
43namespace physx
44{
45#endif
46
54{
55public:
58
59 virtual PxU32 write(const void* src, PxU32 count);
60
61 virtual PxU32 getSize() const { return mSize; }
62 virtual PxU8* getData() const { return mData; }
63
64private:
67
68 PxAllocatorCallback& mAllocator;
69 PxU8* mData;
70 PxU32 mSize;
71 PxU32 mCapacity;
72};
73
81{
82public:
83 PxDefaultMemoryInputData(PxU8* data, PxU32 length);
84
85 virtual PxU32 read(void* dest, PxU32 count);
86 virtual PxU32 getLength() const;
87 virtual void seek(PxU32 pos);
88 virtual PxU32 tell() const;
89
90private:
91 PxU32 mSize;
92 const PxU8* mData;
93 PxU32 mPos;
94};
95
96
97
105{
106public:
107 PxDefaultFileOutputStream(const char* name);
109
110 virtual PxU32 write(const void* src, PxU32 count);
111 virtual bool isValid();
112private:
113 PxFileHandle mFile;
114};
115
116
124{
125public:
126 PxDefaultFileInputData(const char* name);
127 virtual ~PxDefaultFileInputData();
128
129 virtual PxU32 read(void* dest, PxU32 count);
130 virtual void seek(PxU32 pos);
131 virtual PxU32 tell() const;
132 virtual PxU32 getLength() const;
133
134 bool isValid() const;
135private:
136 PxFileHandle mFile;
137 PxU32 mLength;
138};
139
140#if !PX_DOXYGEN
141}
142#endif
143
146#endif
147
Abstract base class for an application defined memory allocator that can be used by the Nv library.
Definition PxAllocatorCallback.h:53
default implementation of a file read stream
Definition PxDefaultStreams.h:124
virtual void seek(PxU32 pos)
seek to the given offset from the start of the data.
Definition ExtDefaultStreams.cpp:180
virtual PxU32 tell() const
return the current offset from the start of the data
Definition ExtDefaultStreams.cpp:185
virtual PxU32 read(void *dest, PxU32 count)
read from the stream. The number of bytes read may be less than the number requested.
Definition ExtDefaultStreams.cpp:167
virtual PxU32 getLength() const
return the length of the input data
Definition ExtDefaultStreams.cpp:175
default implementation of a file write stream
Definition PxDefaultStreams.h:105
virtual PxU32 write(const void *src, PxU32 count)
write to the stream. The number of bytes written may be less than the number sent.
Definition ExtDefaultStreams.cpp:132
default implementation of a memory read stream
Definition PxDefaultStreams.h:81
virtual void seek(PxU32 pos)
seek to the given offset from the start of the data.
Definition ExtDefaultStreams.cpp:100
virtual PxU32 read(void *dest, PxU32 count)
read from the stream. The number of bytes read may be less than the number requested.
Definition ExtDefaultStreams.cpp:87
virtual PxU32 getLength() const
return the length of the input data
Definition ExtDefaultStreams.cpp:95
virtual PxU32 tell() const
return the current offset from the start of the data
Definition ExtDefaultStreams.cpp:105
default implementation of a memory write stream
Definition PxDefaultStreams.h:54
virtual PxU32 write(const void *src, PxU32 count)
write to the stream. The number of bytes written may be less than the number sent.
Definition ExtDefaultStreams.cpp:57
Input data class for I/O which provides random read access.
Definition PxIO.h:75
Output stream class for I/O.
Definition PxIO.h:114
PX_C_EXPORT PX_FOUNDATION_API physx::PxAllocatorCallback *PX_CALL_CONV PxGetAllocatorCallback()
Get the allocator callback.
Definition FdFoundation.cpp:259
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39