resonance 1.0.1
Loading...
Searching...
No Matches
object.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4
5#include "os/hxstr.h"
6
13namespace Rnd {
14class Dbg;
15class Stream;
16} // namespace Rnd
17
18namespace Rnd {
19
26constexpr unsigned kCopyChildLists = 0x200;
27
43class Object {
44protected:
56
57 // Declared in recovered offset order.
58
59 // Objects that store a pointer to this one. Rnd::Drawable::Parent() and its siblings walk it.
60 std::list<Object *> mRefs; // +0x00
61
62public:
73
85 explicit Object(const HxStr &name);
86
93 virtual ~Object();
94
105 void SetName(const HxStr &name);
106
117 void AddRef(Object *pReferrer);
118
128 void RemoveRef(Object *pReferrer);
129
142 virtual void DumpText(Dbg &sink);
143
151 virtual void Save(Stream &stream) = 0;
152
162 virtual void Replace(Object *pFrom, Object *pTo) = 0;
163
172 virtual const HxStr &ClassName() const = 0;
173
182 virtual void Copy(const Object *pSource, unsigned nFlags) = 0;
183
191 virtual void Load(Stream &stream) = 0;
192
196
201
202private:
203 // Rnd::Manager::Read() sets mMerge and Rnd::Manager::Write() saves it.
204 friend class Manager;
205
206 int mMerge; // +0x10
207 // Set for the whole of ReleaseAllRefs() so that a referrer notified through Replace() cannot
208 // erase an mRefs entry the walk is still standing on.
209 int mDeleting; // +0x14
210};
211
221extern void (*g_pfnNameChanged)(Object *pObject);
222
223} // namespace Rnd
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Sink that the engine formats its diagnostic and failure text into.
Definition dbg.h:33
Base of every object the renderer can load, resolve by name, and serialise.
Definition object.h:43
virtual void Copy(const Object *pSource, unsigned nFlags)=0
Copy the state of pSource into this object.
virtual const HxStr & ClassName() const =0
Report the name of this object's most derived class.
void RemoveRef(Object *pReferrer)
Drop one registration made by AddRef().
std::list< Object * > mRefs
Definition object.h:60
int mInternal
Definition object.h:197
void AddRef(Object *pReferrer)
Register pReferrer as a store of a pointer to this object.
Object(const HxStr &name)
Construct an object and register it under name.
virtual ~Object()
Erase the registry entry and release the name buffer.
HxStr mName
Definition object.h:193
virtual void DumpText(Dbg &sink)
Write a human-readable description of this object to sink.
virtual void Load(Stream &stream)=0
Read this object's serialised form from stream.
void ReleaseAllRefs()
Tell every referrer to drop its pointer to this object.
Object()
Construct an unnamed object.
friend class Manager
Definition object.h:204
void SetName(const HxStr &name)
Re-register this object under a different name.
virtual void Replace(Object *pFrom, Object *pTo)=0
Replace every stored pointer to pFrom with pTo.
virtual void Save(Stream &stream)=0
Write this object's serialised form to stream.
Byte stream that every renderer object serialises itself through.
Definition stream.h:31
The rendering engine.
Definition animhelper.h:3
constexpr unsigned kCopyChildLists
Bit of the Copy() flags word that requests copying the child object lists.
Definition object.h:26
void(* g_pfnNameChanged)(Object *pObject)
Hook invoked with the object whenever a registry key is about to change.