You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
5.1 KiB
C

/**
*
* @file FITKComponentInterface.h
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*
*/
#ifndef __FITKCOMPONENT_INTERFACE_H__
#define __FITKCOMPONENT_INTERFACE_H__
#include "FITKAppFrameworkAPI.h"
#include <functional>
#include <QString>
#include <QWidget>
#include <QVariant>
#include <QHash>
//定义回调函数参数为void*返回值为int
typedef std::function<int(void*)> CallBackFuns;
namespace Core
{
class FITKAbstractDataObject;
}
namespace AppFrame
{
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
class FITKAppFrameworkAPI FITKComponentInterface
{
public:
/**
* @brief Construct a new FITKComponentInterface object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
explicit FITKComponentInterface() = default;
/**
* @brief Destroy the FITKComponentInterface object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
virtual ~FITKComponentInterface() = 0;
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
virtual void init();
/**
* @brief
* @param[i] indexPort
* @return QWidget*
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
virtual QWidget* getWidget(const int indexPort);
/**
* @brief
* @return QString
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04
*/
virtual QString getComponentName() = 0;
/**
* @brief
* @param[i] indexPort
* @return true
* @return false
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-07
*/
virtual bool exec(const int indexPort);
/**
* @brief
* @param[i] name
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-30
*/
void setComponentObjName(const QString & name);
/**
* @brief
* @return QString
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-30
*/
QString getComponentObjName() const;
/**
* @brief
* @param[i] key
* @return CallBackFuns
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-25
*/
CallBackFuns getCallBackFuns(int key);
/**
* @brief
* @param[i] k
* @param[i] f
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-25
*/
void setCallBackFuns(int k, CallBackFuns f);
/**
* @brief
* @param[i] k
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-25
*/
void removeCallBackFun(int k);
/**
* @brief
* @param[i] name
* @param[i] data
* @author libaojun (libaojunqd@foxmail.com)
* @date 2024-10-10
*/
void setDataObject(const QString& name, Core::FITKAbstractDataObject* data);
/**
* @brief
* @param[i] name
* @return Core::FITKAbstractDataobject*
* @author libaojun (libaojunqd@foxmail.com)
* @date 2024-10-10
*/
Core::FITKAbstractDataObject* getDataObject(const QString& name);
template <class T>
/**
* @brief
* @param[i] name
* @return T*
* @author libaojun (libaojunqd@foxmail.com)
* @date 2024-10-10
*/
T* getDataObjectT(const QString& name)
{
return dynamic_cast<T*>(this->getDataObject(name));
}
/**
* @brief
* @author libaojun (libaojunqd@foxmail.com)
* @date 2024-10-10
*/
void resetDataObjects();
protected:
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-30
*/
QString _compObjName{};
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-25
*/
QHash<int, CallBackFuns> _callBackFuns{};
/**
* @brief hash
* @author libaojun (libaojunqd@foxmail.com)
* @date 2024-10-10
*/
QHash<QString, Core::FITKAbstractDataObject*> _dataObjects{};
};
}
#endif