PxCollection Class Reference
[Common]
Collection class for serialization.
More...
#include <PxSerialFramework.h>
Public Member Functions | |
PxCollection () | |
virtual | ~PxCollection () |
PX_DEPRECATED PX_INLINE void | setUserData (PxSerializable &object, PxSerialObjectRef ref) |
deprecated alias for setObjectRef | |
virtual void | serialize (PxOutputStream &stream, bool exportNames=false)=0 |
Serializes a collection. | |
virtual bool | deserialize (void *buffer128, PxUserReferences *newReferences, const PxUserReferences *externalReferences)=0 |
Deserializes a collection. | |
virtual bool | setObjectRef (PxSerializable &object, PxSerialObjectRef ref)=0 |
Sets user-data/name for a PxSerializable. | |
virtual PxUserReferences * | getObjectRefs () const =0 |
Retrieves the object references specified by the user for this collection. | |
virtual bool | addExternalRef (PxSerializable &object, PxSerialObjectRef ref)=0 |
Declares an reference to an object outside the collection. | |
virtual PxUserReferences * | getExternalRefs () const =0 |
Retrieve all external reference pairs. | |
virtual PxU32 | getNbObjects () const =0 |
Gets number of objects in the collection. | |
virtual PxSerializable * | getObject (PxU32 index) const =0 |
Gets object from the collection. | |
virtual void | release ()=0 |
Deletes a collection object. | |
Private Member Functions | |
virtual void | addUnique (PxSerializable &)=0 |
Friends | |
class | PxSerializable |
Detailed Description
Collection class for serialization.A collection is a container for serializable SDK objects. All serializable SDK objects inherit from PxSerializable. Serialization and deserialization only work through collections.
A scene is typically serialized using the following steps:
1) create a collection 2) collect objects to serialize 3) serialize collection 4) release collection
For example the code may look like this:
PxPhysics* physics; // The physics SDK object PxScene* scene; // The physics scene SerialStream s; // The user-defined stream doing the actual write to disk
PxCollection* collection = physics->createCollection(); // step 1) PxCollectForExportSDK(*physics, *collection); // step 2) PxCollectForExportScene(*scene, *collection); // step 2) collection->serialize(s); // step 3) physics->releaseCollection(collection); // step 4)
A scene is typically deserialized using the following steps:
1) load a serialized block somewhere in memory 2) create a collection object 3) deserialize objects (populate collection with objects from the memory block) 4) add collected objects to scene 5) release collection
For example the code may look like this:
PxPhysics* physics; // The physics SDK object PxScene* scene; // The physics scene void* memory128; // a 128-byte aligned buffer previously loaded from disk by the user - step 1)
PxCollection* collection = physics->createCollection(); // step 2) collection->deserialize(memory128, NULL, NULL); // step 3) physics->addCollection(*collection, scene); // step 4) collection->release(); // step 5)
- See also:
- PxSerializable
Constructor & Destructor Documentation
PxCollection::PxCollection | ( | ) | [inline] |
virtual PxCollection::~PxCollection | ( | ) | [inline, virtual] |
Member Function Documentation
virtual bool PxCollection::addExternalRef | ( | PxSerializable & | object, | |
PxSerialObjectRef | ref | |||
) | [pure virtual] |
Declares an reference to an object outside the collection.
Some objects in the collection might have pointers/references to objects that are not within the collection. Such objects will not be serialized when the collection is serialized, and the references will be marked for resolution when the collection is deserialized.
- Parameters:
-
[in] object Serializable object. See PxSerializable [in] ref user-defined name for this object
- Returns:
- true if success
- See also:
- PxSerializable setObjectRef
virtual void PxCollection::addUnique | ( | PxSerializable & | ) | [private, pure virtual] |
Referenced by PxSerializable::collectForExport().
virtual bool PxCollection::deserialize | ( | void * | buffer128, | |
PxUserReferences * | newReferences, | |||
const PxUserReferences * | externalReferences | |||
) | [pure virtual] |
Deserializes a collection.
Initializes/creates objects within the given input buffer, which must have been deserialized from disk already by the user. The input buffer must be 128-bytes aligned.
Deserialized objects are added to the collection.
Object references for the collection can be retrieved, if necessary. External references can be passed, if necesary.
- Parameters:
-
[in] buffer128 Deserialized input buffer, 128-bytes aligned [out] newReferences map of new object references created by deserialization, or NULL. See PxUserReferences [in] externalReferences map for resolving the collection's external references, or NULL. See PxUserReferences
- Returns:
- True if success
- See also:
- PxUserReferences
virtual PxUserReferences* PxCollection::getExternalRefs | ( | ) | const [pure virtual] |
Retrieve all external reference pairs.
- Note:
- the pairs retrieved are those set by the application with addExternalRef. No external references are created in the collection during deserialization.
- Returns:
- the external references
- See also:
- addExternalRef getNbExternalRefs
virtual PxU32 PxCollection::getNbObjects | ( | ) | const [pure virtual] |
Gets number of objects in the collection.
- Returns:
- Number of objects in the collection
virtual PxSerializable* PxCollection::getObject | ( | PxU32 | index | ) | const [pure virtual] |
Gets object from the collection.
- Parameters:
-
[in] index Object index, between 0 (incl) and getNbObjects() (excl).
- Returns:
- Desired object from the collection
- See also:
- PxSerializable
virtual PxUserReferences* PxCollection::getObjectRefs | ( | ) | const [pure virtual] |
Retrieves the object references specified by the user for this collection.
note that user references created by deserialization are not returned by this function.
virtual void PxCollection::release | ( | ) | [pure virtual] |
Deletes a collection object.
This function only deletes the collection object, i.e. the container class. It doesn't delete objects that are part of the collection.
- See also:
- PxPhysics::createCollection()
virtual void PxCollection::serialize | ( | PxOutputStream & | stream, | |
bool | exportNames = false | |||
) | [pure virtual] |
Serializes a collection.
Writes out collected objects to a binary stream. Objects are output in the order defined by PxSerialOrder, according to their type.
Object references and external references, as defined by the setObjectRef and addExternalRef functions, are also serialized.
- Parameters:
-
[in] stream User-defined serialization stream. [in] exportNames If true, objects' names are serialized along with the objects. Not serializing names produce smaller files.
- See also:
- PxSerialOrder setUserData addExternalRef
virtual bool PxCollection::setObjectRef | ( | PxSerializable & | object, | |
PxSerialObjectRef | ref | |||
) | [pure virtual] |
Sets user-data/name for a PxSerializable.
This is used to assign an object reference to a PxSerializable. The references are serialized with the collection, and can be used after deserialization to look up objects by reference.
- Parameters:
-
[in] object Serializable object. See PxSerializable [in] ref user-defined object reference for this object
- Returns:
- true if success
- See also:
- PxSerializable addExternalRef getObjectRef
PX_DEPRECATED PX_INLINE void PxCollection::setUserData | ( | PxSerializable & | object, | |
PxSerialObjectRef | ref | |||
) | [inline] |
deprecated alias for setObjectRef
- Parameters:
-
[in] object Serializable object. See PxSerializable [in] ref user-defined object reference for this object
- See also:
- setObjectRef
Friends And Related Function Documentation
friend class PxSerializable [friend] |
The documentation for this class was generated from the following file:
Copyright © 2008-2012 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com