NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches

#include <game/cLib/c_dylink.hpp>

Inheritance diagram for DynamicModuleControlBase:
[legend]

Description

Base class for managing a relocatable module.

The class tracks how many times a module is being used via reference counting. It automatically handles the physical loading/linking when the first user requests it, and unloads it only when the last user is finished. All active modules are tracked in a global doubly-linked list.

Derived classes are expected to override the do_* methods to implement module-specific behavior.

Definition at line 46 of file c_dylink.hpp.

Public Member Functions

 DynamicModuleControlBase ()
 Constructs a new DynamicModuleControlBase and adds it to the linked list.
virtual ~DynamicModuleControlBase ()
 Destroys the DynamicModuleControlBase and removes it from the linked list.
virtual const char * getModuleName () const
 Gets the module name.
virtual size_t getModuleSize () const
 Gets the module size in bytes.
virtual const char * getModuleTypeString () const
 Gets a human-readable module type string.
virtual void dump ()
 Outputs debug information about the module.
virtual bool do_load ()
 Module-specific implementation for loading the module into memory.
virtual bool do_load_async ()
 Module-specific implementation for loading the module into memory asynchronously.
virtual bool do_unload ()
 Module-specific implementation for unloading the module from memory.
virtual bool do_link ()
 Module-specific implementation for linking the module, making it ready for use.
virtual bool do_unlink ()
 Module-specific implementation for unlinking the module.
bool link ()
 Loads and links the module if needed.
bool unlink ()
 Unlinks and unloads the module if needed.
bool load_async ()
 Loads the module asynchronously if needed.

Static Public Attributes

static DynamicModuleControlBasemFirst
 The first module in the linked list.
static DynamicModuleControlBasemLast
 The last module in the linked list.

Protected Attributes

u16 mUsageCount
 The number of active users of this module. When this reaches zero, the module may be unloaded.
u16 mLinkCount
 The number of times this module has been successfully linked.
DynamicModuleControlBasempPrev
 The previous module in the linked list.
DynamicModuleControlBasempNext
 The next module in the linked list.

Constructor & Destructor Documentation

◆ DynamicModuleControlBase()

DynamicModuleControlBase::DynamicModuleControlBase ( )

Constructs a new DynamicModuleControlBase and adds it to the linked list.

Definition at line 25 of file c_dylink.cpp.

◆ ~DynamicModuleControlBase()

DynamicModuleControlBase::~DynamicModuleControlBase ( )
virtual

Destroys the DynamicModuleControlBase and removes it from the linked list.

Definition at line 8 of file c_dylink.cpp.

Member Function Documentation

◆ getModuleName()

virtual const char * DynamicModuleControlBase::getModuleName ( ) const
inlinevirtual

Gets the module name.

Returns
A string identifying the module, or nullptr if unnamed.

Reimplemented in DynamicModuleControl.

Definition at line 59 of file c_dylink.hpp.

◆ getModuleSize()

size_t DynamicModuleControlBase::getModuleSize ( ) const
virtual

Gets the module size in bytes.

Returns
The size of the module, or 0 if unknown.

Reimplemented in DynamicModuleControl.

Definition at line 73 of file c_dylink.cpp.

◆ getModuleTypeString()

virtual const char * DynamicModuleControlBase::getModuleTypeString ( ) const
inlinevirtual

Gets a human-readable module type string.

Reimplemented in DynamicModuleControl.

Definition at line 66 of file c_dylink.hpp.

◆ dump()

void DynamicModuleControlBase::dump ( )
virtual

Outputs debug information about the module.

Decompilation Note
This function has been stubbed, but was likely used for debugging purposes during development.

Reimplemented in DynamicModuleControl.

Definition at line 71 of file c_dylink.cpp.

◆ do_load()

virtual bool DynamicModuleControlBase::do_load ( )
inlinevirtual

Module-specific implementation for loading the module into memory.

Returns
Whether the operation was successful.

Reimplemented in DynamicModuleControl.

Definition at line 74 of file c_dylink.hpp.

◆ do_load_async()

virtual bool DynamicModuleControlBase::do_load_async ( )
inlinevirtual

Module-specific implementation for loading the module into memory asynchronously.

Returns
Whether the operation was successfully started.

Reimplemented in DynamicModuleControl.

Definition at line 78 of file c_dylink.hpp.

◆ do_unload()

virtual bool DynamicModuleControlBase::do_unload ( )
inlinevirtual

Module-specific implementation for unloading the module from memory.

Returns
Whether the operation was successful.

Reimplemented in DynamicModuleControl.

Definition at line 82 of file c_dylink.hpp.

◆ do_link()

virtual bool DynamicModuleControlBase::do_link ( )
inlinevirtual

Module-specific implementation for linking the module, making it ready for use.

Returns
Whether the operation was successful.

Reimplemented in dDynamicModuleControl, and DynamicModuleControl.

Definition at line 86 of file c_dylink.hpp.

◆ do_unlink()

virtual bool DynamicModuleControlBase::do_unlink ( )
inlinevirtual

Module-specific implementation for unlinking the module.

Returns
Whether the operation was successful.

Reimplemented in DynamicModuleControl.

Definition at line 90 of file c_dylink.hpp.

◆ link()

bool DynamicModuleControlBase::link ( )

Loads and links the module if needed.

Returns
Whether the operation was successful.

Definition at line 36 of file c_dylink.cpp.

◆ unlink()

bool DynamicModuleControlBase::unlink ( )

Unlinks and unloads the module if needed.

Decompilation Note
This function is not present in the final binary and was reconstructed based on surrounding logic and expected behavior.
Returns
Whether the operation was successful.

Definition at line 54 of file c_dylink.cpp.

◆ load_async()

bool DynamicModuleControlBase::load_async ( )

Loads the module asynchronously if needed.

Returns
true if the load is finished, false if it is still in progress.

Definition at line 64 of file c_dylink.cpp.

Member Data Documentation

◆ mUsageCount

u16 DynamicModuleControlBase::mUsageCount
protected

The number of active users of this module. When this reaches zero, the module may be unloaded.

Definition at line 48 of file c_dylink.hpp.

◆ mLinkCount

u16 DynamicModuleControlBase::mLinkCount
protected

The number of times this module has been successfully linked.

Definition at line 49 of file c_dylink.hpp.

◆ mpPrev

DynamicModuleControlBase* DynamicModuleControlBase::mpPrev
protected

The previous module in the linked list.

Definition at line 50 of file c_dylink.hpp.

◆ mpNext

DynamicModuleControlBase* DynamicModuleControlBase::mpNext
protected

The next module in the linked list.

Definition at line 51 of file c_dylink.hpp.

◆ mFirst

DynamicModuleControlBase * DynamicModuleControlBase::mFirst
static

The first module in the linked list.

Definition at line 106 of file c_dylink.hpp.

◆ mLast

DynamicModuleControlBase * DynamicModuleControlBase::mLast
static

The last module in the linked list.

Definition at line 107 of file c_dylink.hpp.