mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-05 17:17:42 +00:00
feat: Python Plugins
This commit is contained in:
@@ -24,13 +24,19 @@ using PrinterAgentFactory =
|
||||
// Information about a registered printer agent
|
||||
struct PrinterAgentInfo
|
||||
{
|
||||
std::string id; // e.g., "orca", "bbl"
|
||||
std::string id; // Registry/config key, e.g. "orca" or a plugin AgentInfo::id
|
||||
std::string display_name; // e.g., "Orca Native", "Bambu Lab"
|
||||
std::string plugin_identifier; // Empty for built-ins, otherwise <plugin_key>;<uuid>;<capability_name>
|
||||
PrinterAgentFactory factory; // Function to create the agent
|
||||
|
||||
bool is_plugin() const { return !plugin_identifier.empty(); }
|
||||
PrinterAgentInfo(const std::string& id_, const std::string& display_name_, PrinterAgentFactory factory_)
|
||||
: id(id_), display_name(display_name_), factory(std::move(factory_))
|
||||
{}
|
||||
|
||||
PrinterAgentInfo(const std::string& id_, const std::string& display_name_, const std::string& plugin_identifier, PrinterAgentFactory factory_)
|
||||
: id(id_), display_name(display_name_), plugin_identifier(plugin_identifier), factory(std::move(factory_))
|
||||
{}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -80,27 +86,32 @@ public:
|
||||
static bool register_printer_agent(const std::string& id, const std::string& display_name, PrinterAgentFactory factory);
|
||||
|
||||
/**
|
||||
* Check if an agent ID is registered
|
||||
* Check if an agent registry/config key is registered
|
||||
*/
|
||||
static bool is_printer_agent_registered(const std::string& id);
|
||||
|
||||
/**
|
||||
* Get info about a registered agent
|
||||
* Get info about a registered agent by registry/config key
|
||||
*/
|
||||
static const PrinterAgentInfo* get_printer_agent_info(const std::string& id);
|
||||
|
||||
/**
|
||||
* Return the full plugin reference for a plugin-backed printer agent ID, or empty for built-ins.
|
||||
*/
|
||||
static std::string get_printer_agent_plugin_identifier(const std::string& id);
|
||||
|
||||
/**
|
||||
* Get all registered printer agents (for UI population)
|
||||
*/
|
||||
static std::vector<PrinterAgentInfo> get_registered_printer_agents();
|
||||
|
||||
/**
|
||||
* Create a printer agent by ID (using registry)
|
||||
* Create a printer agent by registry/config key
|
||||
*
|
||||
* Returns a cached instance if one exists for the given ID, otherwise
|
||||
* Returns a cached instance if one exists for the given key, otherwise
|
||||
* creates a new agent via the registered factory and caches it.
|
||||
*
|
||||
* @param id Agent ID to create
|
||||
* @param id Agent registry/config key to create
|
||||
* @param cloud_agent Cloud agent for token access
|
||||
* @param log_dir Directory for log files
|
||||
* @return Shared pointer to IPrinterAgent, or nullptr if ID not found
|
||||
@@ -148,6 +159,15 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Plugin printer agents
|
||||
static void register_python_plugin(const std::string& plugin_key);
|
||||
static void deregister_python_plugin(const std::string& plugin_key);
|
||||
|
||||
static void register_python_printer_agent(const std::string& plugin_key, const std::string& capability_name);
|
||||
static void deregister_python_printer_agent(const std::string& plugin_key, const std::string& capability_name);
|
||||
|
||||
static bool is_current_printer_agent_plugin();
|
||||
|
||||
private:
|
||||
// Factory is not instantiable
|
||||
NetworkAgentFactory() = delete;
|
||||
|
||||
Reference in New Issue
Block a user