The mclass class uses the singleton pattern to provide an application-wide interface for loading modules. Additionally, the mclass:modules method makes it possible to find out what modules are currently loaded.
Input(s) Method Output(s) |
Description |
Class-context methods | |
- new instance |
Constructor. |
- singleton instance |
Get an mclass singleton instance. |
Instance-context methods | |
modname load - |
Load a module. |
modname unload_notify - |
Notify the mclass singleton of a module unload. |
- modules modules |
Get loaded modules. |
onyx:0> $modclopt mclass:singleton:load onyx:0>
onyx:0> mclass:singleton:modules 1 sprint <$modprompt -instance=$module- $modclopt -instance=$module-> onyx:0>
onyx:0> mclass:new 1 sprint -instance- onyx:0>
onyx:0> mclass:singleton 1 sprint -instance=$mclass- onyx:0>
# Unload the module. # #instance# #- unload - $unload { # Evaluate the pre-unload hook. ,pre_unload_hook eval # Iteratively undefine the module definitions, as recorded in the mdefs # dict. ,mdefs { exch 0 get #defdict #defname undef } foreach # Evaluate the post-unload hook. ,post_unload_hook eval # Notify mclass_singleton of the unload. ,name ,mclass_singleton:unload_notify } bind