mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Expose SimPersistID to EngineAPI
This commit is contained in:
parent
fe09d6e125
commit
e95a5bf139
2 changed files with 39 additions and 12 deletions
|
|
@ -24,16 +24,26 @@
|
||||||
#include "console/simObject.h"
|
#include "console/simObject.h"
|
||||||
#include "core/util/tDictionary.h"
|
#include "core/util/tDictionary.h"
|
||||||
#include "core/util/safeDelete.h"
|
#include "core/util/safeDelete.h"
|
||||||
|
#include "engineAPI.h"
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_SPEW
|
//#define DEBUG_SPEW
|
||||||
|
|
||||||
|
IMPLEMENT_CLASS(SimPersistID, "")
|
||||||
|
END_IMPLEMENT_CLASS;
|
||||||
|
|
||||||
SimPersistID::LookupTableType* SimPersistID::smLookupTable;
|
SimPersistID::LookupTableType* SimPersistID::smLookupTable;
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SimPersistID::SimPersistID()
|
||||||
|
{
|
||||||
|
mObject = NULL;
|
||||||
|
mUUID.generate();
|
||||||
|
smLookupTable->insertUnique(mUUID, this);
|
||||||
|
}
|
||||||
|
|
||||||
SimPersistID::SimPersistID( SimObject* object )
|
SimPersistID::SimPersistID( SimObject* object )
|
||||||
: mObject( object )
|
: mObject( object )
|
||||||
{
|
{
|
||||||
|
|
@ -136,3 +146,13 @@ SimPersistID* SimPersistID::findOrCreate( const Torque::UUID& uuid )
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineNewEngineMethod(SimPersistID, getUUID, Torque::UUID, (), , "")
|
||||||
|
{
|
||||||
|
return object->getUUID();
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineNewEngineMethod(SimPersistID, getObject, SimObject*, (), , "")
|
||||||
|
{
|
||||||
|
return object->getObject();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@
|
||||||
#include "core/util/refBase.h"
|
#include "core/util/refBase.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _ENGINEOBJECT_H_
|
||||||
|
#include "console/engineObject.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/// @file
|
/// @file
|
||||||
/// Persistent IDs for SimObjects.
|
/// Persistent IDs for SimObjects.
|
||||||
|
|
@ -40,12 +43,27 @@ template< typename, typename > class HashTable;
|
||||||
|
|
||||||
|
|
||||||
/// A globally unique persistent ID for a SimObject.
|
/// A globally unique persistent ID for a SimObject.
|
||||||
class SimPersistID : public StrongRefBase
|
class SimPersistID : public EngineObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
DECLARE_CLASS(SimPersistID, EngineObject);
|
||||||
|
|
||||||
typedef void Parent;
|
typedef void Parent;
|
||||||
friend class SimObject;
|
friend class SimObject;
|
||||||
|
|
||||||
|
///
|
||||||
|
SimPersistID();
|
||||||
|
|
||||||
|
/// Construct a new persistent ID for "object" by generating a fresh
|
||||||
|
/// unique identifier.
|
||||||
|
SimPersistID(SimObject* object);
|
||||||
|
|
||||||
|
/// Construct a persistent ID stub for the given unique identifier.
|
||||||
|
/// The stub remains not bound to any object until it is resolved.
|
||||||
|
SimPersistID(const Torque::UUID& uuid);
|
||||||
|
|
||||||
|
///
|
||||||
|
~SimPersistID();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
@ -60,17 +78,6 @@ class SimPersistID : public StrongRefBase
|
||||||
|
|
||||||
/// Table of persistent object IDs.
|
/// Table of persistent object IDs.
|
||||||
static LookupTableType* smLookupTable;
|
static LookupTableType* smLookupTable;
|
||||||
|
|
||||||
/// Construct a new persistent ID for "object" by generating a fresh
|
|
||||||
/// unique identifier.
|
|
||||||
SimPersistID( SimObject* object );
|
|
||||||
|
|
||||||
/// Construct a persistent ID stub for the given unique identifier.
|
|
||||||
/// The stub remains not bound to any object until it is resolved.
|
|
||||||
SimPersistID( const Torque::UUID& uuid );
|
|
||||||
|
|
||||||
///
|
|
||||||
~SimPersistID();
|
|
||||||
|
|
||||||
/// Bind this unresolved PID to the given object.
|
/// Bind this unresolved PID to the given object.
|
||||||
void resolve( SimObject* object );
|
void resolve( SimObject* object );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue