plugin 的使用分三步,下面以ant::Service举例。
第一步. 声明
class ANT_PUBLIC Service
: public lay::ViewService,
public lay::Editable,
public lay::Plugin,
public lay::Drawing,
public db::Object
{
Service (db::Manager *manager, lay::LayoutView *view);
virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio);
virtual bool mouse_press_event (const db::DPoint &p, unsigned int buttons, bool prio);
virtual bool mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio);
}
第二步. 注册
通过模板把plugin类注册到系统中
antPlugin.cc
static tl::RegisteredClass<lay::PluginDeclaration> config_decl (new ant::PluginDeclaration (), 3000, "ant::Plugin");
}
第三步.生成
void LayoutView::create_plugins (lay::PluginRoot *root, const lay::PluginDeclaration *except_this)
{
for

本文详细介绍了插件系统的工作原理,以ant::Service为例,分为三个步骤:声明、注册和生成。首先,声明了一个继承自多个基类的Service类,包含鼠标事件处理函数。接着,通过tl::RegisteredClass模板将插件类注册到系统中。最后,在LayoutView类中遍历并创建所有注册的插件,根据选项决定是否创建特定插件。这个过程揭示了插件系统如何动态加载和管理组件。
最低0.47元/天 解锁文章
3384

被折叠的 条评论
为什么被折叠?



