Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Raven::ScriptRegistry Class Reference

Singleton that owns all loaded script DLLs and their type registrations. More...

#include <ScriptRegistry.h>

Public Member Functions

bool LoadModule (const std::string &path)
 Loads a script DLL, registers its types, and installs a file watcher.
void UnloadAll ()
 Unloads all modules, stops the file watcher, and clears the registry.
TypeRegistry & GetTypeRegistry ()
 Returns the mutable type registry populated by the script DLL.
ScriptLifecycle * GetLifecycle (const TypeID &id)
 Looks up the lifecycle callbacks for a registered type.
bool IsDirty () const
 Returns true if a DLL change has been detected and a reload is pending.
void FlushReload ()
 Performs the pending hot-reload if IsDirty is true.

Static Public Member Functions

static ScriptRegistry & Get ()
 Returns the process-wide singleton instance.

Detailed Description

Singleton that owns all loaded script DLLs and their type registrations.

  • A filewatch::FileWatch monitors the source DLL.
  • On modification, IsDirty returns true.
  • The engine calls FlushReload at a safe point (e.g. between frames).
  • All existing modules are unloaded, the registry is cleared, and the DLL is re-copied and re-loaded via LoadModule.

The source DLL is copied to a _live path before loading so that the compiler can overwrite the original while the engine is running.

Member Function Documentation

◆ FlushReload()

void Raven::ScriptRegistry::FlushReload ( )

Performs the pending hot-reload if IsDirty is true.

Unloads all current modules, clears the registry, and calls LoadModule with the path that triggered the reload. Safe to call every frame; no-op when not dirty.

◆ Get()

ScriptRegistry & Raven::ScriptRegistry::Get ( )
inlinestatic

Returns the process-wide singleton instance.

Returns
Reference to the sole ScriptRegistry.

◆ GetLifecycle()

ScriptLifecycle * Raven::ScriptRegistry::GetLifecycle ( const TypeID & id)

Looks up the lifecycle callbacks for a registered type.

Parameters
idReflection TypeID of the script class.
Returns
Pointer to the ScriptLifecycle, or nullptr if not found.

◆ GetTypeRegistry()

TypeRegistry & Raven::ScriptRegistry::GetTypeRegistry ( )
inline

Returns the mutable type registry populated by the script DLL.

Returns
Reference to the internal TypeRegistry.

◆ IsDirty()

bool Raven::ScriptRegistry::IsDirty ( ) const
inline

Returns true if a DLL change has been detected and a reload is pending.

◆ LoadModule()

bool Raven::ScriptRegistry::LoadModule ( const std::string & path)

Loads a script DLL, registers its types, and installs a file watcher.

The DLL is shadow-copied to a _live path before LoadLibraryA is called. Up to 10 load attempts are made with back-off to handle linker lock races.

Parameters
pathAbsolute path to the source script DLL.
Returns
true on success; false if copying, loading, or registration failed.

◆ UnloadAll()

void Raven::ScriptRegistry::UnloadAll ( )

Unloads all modules, stops the file watcher, and clears the registry.


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