1,定义接口文件
/******************************************************************************************************
* Copyright (C) 2014, All right reserved.
* file Basic_Module_Interface.h
* version 1.0
* author NingJian (freegodly@gmail.com)
* brief
* detail
平台插件接口文件
* TODO
* history 2014-9-17 created by NingJian
*
* note
******************************************************************************************************/
#ifndef BASIC_MODULE_INTERFACE_H
#define BASIC_MODULE_INTERFACE_H
#include <iostream>
#include <map>
#include <tr1/memory>
#include <tr1/functional>
#include <QScriptEngine>
#include <QScriptValue>
#include <QtCore/QtPlugin>
#include <QString>
/* ############################################################################################################# */
///
/// > 方便获取软件编译时间
///
#ifndef STT_BUILD_TIME
#define STT_BUILD_TIME std::string("Build Time: ")+std::string(__TIME__)+std::string(" ")+std::string(__DATE__)
#endif
/* ############################################################################################################# */
///
/// > 定义测试结构信息
///
#ifndef STT_TEST_INFO
#define STT_TEST_INFO
///
/// \brief The TEST_INFO struct
///
struct TEST_INFO
{
///
/// \brief id [ID信息]
///
int id;
std::string name;
///
/// \brief variable_map [测试结构的自定义数据存储]
///
std::map<std::string,std::string> variable_map;
};
///
/// \brief The TEST_FUN_INFO struct
///
struct TEST_FUN_INFO
{
std::string modle_name;
std::string fun_name;
std::string fun_describe;
};
#endif
/* ############################################################################################################# */
///
/// > 定义模块函数指针类型
///
#ifndef STT_FUN_REG
#define STT_FUN_REG
///
/// > 实现运行指令的函数类型 定义
///
typedef bool (*RUN_FUN)(QString fun_name, int test_id,QString arg1 ,QString arg2,QString arg3,QString arg4, QString arg5,QString arg6,QString arg7,QString arg8,QString arg9);
///
/// > 实现运行模块配置函数类型 定义
///
typedef bool (*UI_FUN)();
///
/// > 实现注册模块配置函数 定义
///
typedef void (*REG_UI_FUN) (QString image_path,QString config_name ,UI_FUN f );
#endif
/* ############################################################################################################# */
class IBasicModule
{
public:
virtual ~IBasicModule(){}
///
/// \brief initiation
/// 加载初始化资源等
///
virtual bool init(std::map<int,TEST_INFO> &test_info,std::map<std::string,TEST_FUN_INFO> &test_fun_info,std::map<std::string,std::string> &moudles_config,RUN_FUN run_fun)const =0;
///
/// \brief initiation
/// 加载释放资源等
///
virtual bool release()const =0;
///
/// \brief initiation
/// 测试前的初始化资源等
///
virtual bool initiation(int test_id)const =0;
///
/// \brief initiation
/// 测试后的释放资源等
///
virtual bool finish(int test_id)const =0;
///
/// \brief reg_fun
/// 注册命令的函数 需要实现要注册到平台的指令
/// 保存STT平台传来的函数和结构信息供该类以后调用
///
/// \param rf
/// 注册指令的平台回调函数指针
/// 如果模块有自定义数据导入,需要向test_info中添加数据
///
virtual void reg_fun(int test_id,QScriptEngine *eng ) const = 0;
virtual void reg_ui_fun(REG_UI_FUN reg_ui_f)const = 0;
///
/// \brief get_moudle_version
/// 获取模块的版本信息
/// \return
///
virtual std::string get_moudle_version() const =0;
///
/// \brief get_moudle_name
/// \return
///
virtual std::string get_moudle_name() const =0;