(四)SDN 控制器 NOX 源碼分析之—— DSO-deployer

DSO_component_context
組件的上下文類,保存組件的運行狀態及組件的實例
構造函數
DSO_component_context::DSO_component_context(const Component_name& name, const std::string& config_path)
構造函數初始化組件的狀態與狀態對應觸發的事件句柄;並將依賴組件列表初始化到【dependencies】成員變量中

接口
void DSO_component_context::load()
用途是得到組件句柄,句柄保存在變量DSO_component_context::handle中
DSO_component_context::instantiate_factory()
這一句與組件實現時必須在最後加REGISTER_COMPONENT(Simple_component_factory<組件名>, 組件名)有關係,通過這個調用可以得到生成組件實例的工廠方法;
void DSO_component_context::instantiate()
爲當前組件上下文對象生成組件實例
void DSO_component_context::configure()
配置當前組件上下文對象中已經包含的組件實例
void DSO_component_context::install()
啓動組件上下文中的組件實例
DSO_component_context::component_factory_function* DSO_component_context::find_factory_function(const char* name) const
DSO_component_context::instantiate_factory()所調用,作用是從動態加載的組件中找到“name”對應的函數名句柄
成員變量

DSO_deployer
動態部署器是用來管理動態加載的組件的。當它被構造時就會對動態組件目錄進行遍歷,將所有的組件都添加到管理成員中
構造函數
DSO_deployer::DSO_deployer(const Component_context* ctxt, const list<string>& lib_dirs)
1.將lib_dirs下所有應用程序目錄(含meta.json)掃一遍;
2.把所有掃到的組件生成DSO_component_context實例,保存到【uninstalled_contexts】成員變量中;
3.將此deployer保存到kernel的部署器列表中;

接口
Component* DSO_deployer :: instantiate(const Component_context* ctxt, const Path_list& lib_search_paths)
得到DSO_Deployer實例;這個方法必須配合Static_component_context類使用才

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章