resonance 1.0.1
Loading...
Searching...
No Matches
IDablePtr< T > Class Template Reference

Reference to a registered object by its identifier, resolved on first use. More...

#include <idableptr.h>

Public Member Functions

 IDablePtr ()
 Start unresolved, with no identifier.
 IDablePtr (T *pObject)
 Refer to an object, already resolved.
 operator T* () const
 Resolve the identifier to an object, caching the result.

Public Attributes

T * mCached
int mId

Detailed Description

template<typename T>
class IDablePtr< T >

Reference to a registered object by its identifier, resolved on first use.

The name is inferred. No descriptor, allocation tag, or literal in the image identifies the type, and the class is never emitted out of line. Its layout and behaviour come from the packets that embed it: BumpPacket, CripplePacket, CaughtPhrasePacket, and CatchProgressPacket at +0x14, and TrackSelectPacket at +0x18.

The object is eight bytes, a cached pointer and an identifier. Every New() of those packets stores 0 and -1 into the pair. saveGuts() and restoreGuts() transfer only the identifier, and restoreGuts() writes it in place without clearing the cached pointer. PrintExtra() then resolves the pair with the same inline sequence at every site, 0x003e7c64 in CripplePacket::PrintExtra() and 0x003f259c in TrackSelectPacket::PrintExtra() among them. A null cache takes the stand-in object when the identifier is kIDableUnregistered and the table entry otherwise, and the result is cached.

The one instantiation is for Player, whose stand-in is NullPlayer::sInstance. The resolution names that object directly, so the template is written for that instantiation alone.

Both members are public because the packets' transfer members read and write the identifier directly and the image exposes no accessor.

Constructor & Destructor Documentation

◆ IDablePtr() [1/2]

template<typename T>
IDablePtr< T >::IDablePtr ( )
inline

Start unresolved, with no identifier.

◆ IDablePtr() [2/2]

template<typename T>
IDablePtr< T >::IDablePtr ( T * pObject)
inlineexplicit

Refer to an object, already resolved.

Inline, with no address of its own. PhraseMgr::SetPhraseOwner() at 0x001bafa8 expands it for a CaughtPhrasePacket on its stack, caching the object and copying its identifier, or -1 for a null object.

Parameters
pObjectThe object, or null.

Member Function Documentation

◆ operator T*()

template<typename T>
IDablePtr< T >::operator T* ( ) const
inline

Resolve the identifier to an object, caching the result.

An identifier of -1 is not tested for, so an unresolved pair with no identifier indexes the table at -1. That matches every inline copy in the image.

Returns
The object.

Member Data Documentation

◆ mCached

template<typename T>
T* IDablePtr< T >::mCached
mutable

The resolved object, or null before the first resolution. +0x00

◆ mId

template<typename T>
int IDablePtr< T >::mId

The object's identifier in IDable<T>::sObjects. +0x04


The documentation for this class was generated from the following file: