/** * @file ConfigureManager.h * @brief 配置文件管理 * * @author 黄军 * @date 2011-8-10 */ #ifndef PAI_FRAME_WORKFLOWENGINE_CONFIGUREMANAGER_H #define PAI_FRAME_WORKFLOWENGINE_CONFIGUREMANAGER_H #include #include #include #include #include #include #include #include #include "Turtle.h" #include "WorkflowConstants.h" #include "Configure.h" namespace pai{ namespace workflow { typedef std::map Properties; /** * @brief 配置文件管理 * 1.解析Property类型的配置文件,通过索引Key的方式去查找配置项 * 2.保存Property选项为,Properties配置文件 */ class PAI_WORKFLOWENGINE_EXPORT CConfigureManager { public: CConfigureManager(); virtual ~CConfigureManager(); private: /* * 配置项集合 * */ Properties m_mapProperties; std::string m_strPropFilePath; pai::conf::CConfigure configure; public: /* * @brief 解析配置文件 * 如果解析成功,直接可以通过m_properties字段获取配置项目。 * @param[in] strPropFilePath 配置文件全路径 * @return 解析文件是否成功 */ bool ParserFile(const std::string& strPropFilePath); /* * @brief 获取配置项值 * @param[in] strKey 配置项目名名词 * @return 如果配置项不存在返回空字符串(string.empty()==true),否则返回配置项值 */ const std::string GetValue(const std::string& strKey); /* * @brief 解析默认配置文件[设置环境变量=WORKFLOW_CONFIG_PATH] * 如果解析成功,直接可以通过m_properties字段获取配置项目。 * @return 解析文件是否成功 */ bool ParaseDefaultFile(); /* * @brief 保存Key/Value配置项,为配置文件 * @return 保存是否成功 */ bool Save(Properties& prop,const std::string& filepath); }; } } /** * @brief 返回全局唯一的配置管理 */ extern PAI_WORKFLOWENGINE_EXPORT pai::workflow::CConfigureManager* GetConfigureManager(); #endif