Petrichor
Loading...
Searching...
No Matches
IPetrichorHost Struct Referenceabstract

Petrichor consumer-level interface. More...

#include <petrichor.h>

Public Member Functions

virtual void log (PetrichorLogLevel level, const char *tag, const char *msg) const =0
 Writes a log message through the host.
virtual const char * mods_dir () const =0
 Returns the root directory containing installed packages.
virtual const char * temp_dir () const =0
 Returns the host's temporary working directory.
virtual const char * store_dir () const
 Returns the directory used for persistent package storage.
virtual const char * version () const
 Returns the current project version.
virtual void mod_ctx_enter (const char *dir, const char *id)
 Notifies the host that a mod's context is becoming active.
virtual void mod_ctx_exit ()
 Notifies the host that the current mod context is ending.
virtual const char * project_name () const
 Returns the current project name.
virtual ~IPetrichorHost ()=default
 Virtual destructor.

Detailed Description

Petrichor consumer-level interface.

Implemented by the host application and passed to Augment during initialization. Provides logging, memory allocation, symbol resolution, event registration, and access to host-specific services required by modules.

Member Function Documentation

◆ log()

virtual void IPetrichorHost::log ( PetrichorLogLevel level,
const char * tag,
const char * msg ) const
pure virtual

Writes a log message through the host.

Parameters
levelLog severity.
tagSource or subsystem name.
msgNull-terminated message.

◆ mod_ctx_enter()

virtual void IPetrichorHost::mod_ctx_enter ( const char * dir,
const char * id )
inlinevirtual

Notifies the host that a mod's context is becoming active.

Called before invoking into a mod's Luau code (e.g. lifecycle callbacks like tick/save/shutdown), so the host can attribute subsequent behavior (logging, crash reports, stack traces) to the correct mod. Paired with a matching mod_ctx_exit() call once the mod invocation completes.

Parameters
dirFilesystem directory of the mod entering context.
idUnique identifier of the mod entering context.

◆ mod_ctx_exit()

virtual void IPetrichorHost::mod_ctx_exit ( )
inlinevirtual

Notifies the host that the current mod context is ending.

Called after a mod invocation started by mod_ctx_enter() completes, so the host can clear any active-mod attribution state.

◆ project_name()

virtual const char * IPetrichorHost::project_name ( ) const
inlinevirtual

Returns the current project name.

Returns
Project name or "unnamed"

Hosts should ALWAYS include a project name. It is used for error outputs.

◆ store_dir()

virtual const char * IPetrichorHost::store_dir ( ) const
inlinevirtual

Returns the directory used for persistent package storage.

Hosts that do not provide persistent storage should return nullptr.

◆ version()

virtual const char * IPetrichorHost::version ( ) const
inlinevirtual

Returns the current project version.

Returns
Client version or "unversioned"

Hosts should ALWAYS include a version. It is recommended to generate it from your CMake once and use it all over. Used for automatic version checking


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