add some documentation to RegisterShipInitFunc (#4995)

This commit is contained in:
briaguya 2025-02-06 18:47:06 -08:00 committed by GitHub
parent f2a3ac1740
commit ca0617b035
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,6 +26,37 @@ struct ShipInit {
} }
}; };
/**
* @brief Register a function to execute on boot and (optionally) in other situations
*
* @param initFunc The function to execute
* @param updatePaths Strings to specify additional situations in which to execute the function
*
* ### Examples:
*
* #### Execute function `bar` on boot
*
* ```cpp
* static RegisterShipInitFunc foo(bar);
* ```
*
* #### Execute function `bar` on boot and when the CVar `baz` might have changed
*
* ```cpp
* static RegisterShipInitFunc foo(bar, { "baz" });
* ```
*
* #### Execute function `bar` on boot and when `IS_RANDO` might have changed
*
* ```cpp
* static RegisterShipInitFunc foo(bar, { "IS_RANDO" });
* ```
*
* ### Additional Information:
*
* To get a better sense of when your function will be executed
* you can look for `ShipInit::Init` calls throughout the codebase
*/
struct RegisterShipInitFunc { struct RegisterShipInitFunc {
RegisterShipInitFunc(std::function<void()> initFunc, const std::set<std::string>& updatePaths = {}) { RegisterShipInitFunc(std::function<void()> initFunc, const std::set<std::string>& updatePaths = {}) {
auto& shipInitFuncs = ShipInit::GetAll(); auto& shipInitFuncs = ShipInit::GetAll();