PxDefaultStreams.h
Go to the documentation of this file.
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 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 
31 #ifndef PX_PHYSICS_EXTENSIONS_DEFAULT_STREAMS_H
32 #define PX_PHYSICS_EXTENSIONS_DEFAULT_STREAMS_H
33 
37 #include <stdio.h>
39 #include "foundation/PxIO.h"
40 #include "PxFoundation.h"
41 
42 typedef FILE* PxFileHandle;
43 
44 #if !PX_DOXYGEN
45 namespace physx
46 {
47 #endif
48 
56 {
57 public:
58  PxDefaultMemoryOutputStream(PxAllocatorCallback &allocator = PxGetFoundation().getAllocatorCallback());
59  virtual ~PxDefaultMemoryOutputStream();
60 
61  virtual PxU32 write(const void* src, PxU32 count);
62 
63  virtual PxU32 getSize() const { return mSize; }
64  virtual PxU8* getData() const { return mData; }
65 
66 private:
69 
74 };
75 
83 {
84 public:
85  PxDefaultMemoryInputData(PxU8* data, PxU32 length);
86 
87  virtual PxU32 read(void* dest, PxU32 count);
88  virtual PxU32 getLength() const;
89  virtual void seek(PxU32 pos);
90  virtual PxU32 tell() const;
91 
92 private:
94  const PxU8* mData;
96 };
97 
98 
99 
107 {
108 public:
109  PxDefaultFileOutputStream(const char* name);
110  virtual ~PxDefaultFileOutputStream();
111 
112  virtual PxU32 write(const void* src, PxU32 count);
113  virtual bool isValid();
114 private:
116 };
117 
118 
126 {
127 public:
128  PxDefaultFileInputData(const char* name);
129  virtual ~PxDefaultFileInputData();
130 
131  virtual PxU32 read(void* dest, PxU32 count);
132  virtual void seek(PxU32 pos);
133  virtual PxU32 tell() const;
134  virtual PxU32 getLength() const;
135 
136  bool isValid() const;
137 private:
140 };
141 
142 #if !PX_DOXYGEN
143 }
144 #endif
145 
148 #endif
149 
Definition: GuContactBuffer.h:37
virtual PxU8 * getData() const
Definition: PxDefaultStreams.h:64
virtual PxU32 getSize() const
Definition: PxDefaultStreams.h:63
default implementation of a memory read stream
Definition: PxDefaultStreams.h:82
Output stream class for I/O.
Definition: PxIO.h:114
PxFileHandle mFile
Definition: PxDefaultStreams.h:115
PxU32 mLength
Definition: PxDefaultStreams.h:139
PxU32 mPos
Definition: PxDefaultStreams.h:95
Input data class for I/O which provides random read access.
Definition: PxIO.h:75
PxAllocatorCallback & mAllocator
Definition: PxDefaultStreams.h:70
const PxU8 * mData
Definition: PxDefaultStreams.h:94
PxU8 * mData
Definition: PxDefaultStreams.h:71
uint8_t PxU8
Definition: PxSimpleTypes.h:75
default implementation of a file write stream
Definition: PxDefaultStreams.h:106
default implementation of a memory write stream
Definition: PxDefaultStreams.h:55
PxU32 mSize
Definition: PxDefaultStreams.h:93
PxU32 mCapacity
Definition: PxDefaultStreams.h:73
PxFileHandle mFile
Definition: PxDefaultStreams.h:138
PxU32 mSize
Definition: PxDefaultStreams.h:72
Abstract base class for an application defined memory allocator that can be used by the Nv library...
Definition: PxAllocatorCallback.h:52
PX_C_EXPORT PX_FOUNDATION_API physx::PxFoundation &PX_CALL_CONV PxGetFoundation()
Retrieves the Foundation SDK after it has been created.
default implementation of a file read stream
Definition: PxDefaultStreams.h:125
uint32_t PxU32
Definition: Px.h:48
FILE * PxFileHandle
Definition: PxDefaultStreams.h:42