Skip to main content

Controller Plugin Entry

Plugin Entry Module

This module serves as the plugin entry point, similar to a program main function. You can define multiple entry modules and priorities inside a plugin; when the controller loads them, it loads them in priority order.

Entry module loading is divided into several stages:

  1. Validation: This stage mainly checks whether the plugin is valid and can be loaded, including whether the package structure is correct and whether the version meets requirements.
  2. Authorization validation: Authorization is checked before plugin initialization. The plugin developer decides whether authorization is required. If secondary authorization is required, the plugin initialization flow continues only after authorization passes.
  3. Init stage: After all plugins are constructed, initialization begins. Entry modules are sorted by priority; higher-priority modules run first, and the next module runs only after the current one finishes. Execution order among modules with the same priority is not fixed.
  4. Start stage: After all plugin entry modules finish Init, the Start stage runs with the same priority-based order as Init. Plugin logic can run in Start.
  5. Stop stage: Before the controller exits, this stage cleans up resources, again following module priority order.
  6. Destruction stage: Each entry module is destroyed; destruction order is not fixed. If resource cleanup depends on other modules, perform it in Stop according to priority.

Controller Plugin validation stage:

Plugin validation stage

Authorization validation:

A plugin may require authorization before use. If authorization is required, each machine must be authorized individually. Contact Rokae to obtain per-machine authorization codes.

Authorization is controlled in src/launch/authorize.cpp.

Setting this to true enables authorization validation. Validation is disabled by default.

    EXPORT const bool plugin_need_authorize = false;  

Controller Plugin initialization flow

Controller Plugin initialization flow

Usage Example

#include "launch_api.hpp"

// 1. Inherit LaunchAPI and implement Init, Start, and Stop
class Launch:public xcore_api::launch::LaunchAPI{
public:
explicit Launch();
virtual void Init() override;
virtual void Start() override;
virtual void Stop() override;
virtual ~Launch();
};
// 2. Declare as an entry module in the cpp file
LAUNCH_MODULE_PRIORITY(Launch,0)// with priority
LAUNCH_MODULE(Launch) // without priority
// 3. Implement Init, Start, and Stop

This example is implemented in the plugin src/launch module. Users only need to inject their own functions at the appropriate stages.