logplus/Workflow/WFEngine/WorkflowEngine/include/WorkFlowFile.h

364 lines
9.5 KiB
C
Raw Normal View History

2026-01-16 17:18:41 +08:00
/**
* @file WorkFlowFile.h
* @brief
*
* @author
* @date 2011-7-27
*/
#ifndef PAI_FRAME_WORKFLOWENGINE_WORKFLOWFILE_H
#define PAI_FRAME_WORKFLOWENGINE_WORKFLOWFILE_H
#include <string>
#include <vector>
#include <iostream>
#include "WorkflowConstants.h"
#include "ModuleInformation.h"
#include "ModuleConnection.h"
namespace pai {
namespace workflow {
/**
* @brief -GPU并行
*/
const std::string GPU_PARALLEL_FLAG = "GPU";
/**
* @brief
*/
enum WorkflowEventType
{
MODULE_ADD_EVENT, //添加模块事件
MODULE_PARAM_CHANGE_EVENT, //模块参数改变事件
MODULE_TYPE_CHANGE_EVENT, //模块类型改变事件
MODULE_REMOVE_EVENT //删除模块事件
};
/**
* @brief
*
*/
class PAI_WORKFLOWENGINE_EXPORT CWorkFlowFile
{
private:
long long m_id;
/*
* workflow名称
*
* */
std::string m_strName;
/*
* workflow优先级
*
* */
int m_iPriority;
/*
* workflow断点
* false
* */
bool m_bBreakpoint;
/*
*
* true
* */
bool m_bClusterJob;
/**
* pstm模块则为真
*/
bool isParallelJob;
/**
* -
* ()
*/
// bool isStatisApplyJob;
/**
*
*/
bool isMultiwaveJob;
/**
*
*/
std::string m_strQueueName;
std::string m_strComments;
/**
* CPU,GPU等
*/
bool m_gpuWorkflow;
//当前工作流完成后需要删除的数据
std::vector<std::string> m_NeedDelFiles;
//workflow包含的工作流集合
std::vector<pai::workflow::CModuleConnection*>* m_vctConnections;
std::vector<CModuleInformation*>* m_vctModInfos;
void Clone(const CWorkFlowFile& workflowfile);
CWorkFlowFile & operator=(const CWorkFlowFile&);
public:
/**
* @biref GUI排查内存增长问题
* @return
*/
unsigned long GetMemorySize();
long long GetID() const
{
return m_id;
}
void SetID(long long id)
{
m_id = id;
}
std::string GetQueueName() const
{
return this->m_strQueueName;
}
void SetQueueName(const std::string& queueName){
this->m_strQueueName = queueName;
}
std::string GetName() const
{
return this->m_strName;
}
void SetName(const std::string& strName)
{
this->m_strName = strName;
}
int GetPriority() const
{
return this->m_iPriority;
}
void SetPriority(int iPriority)
{
this->m_iPriority = iPriority;
}
bool GetBreakpoint() const
{
return this->m_bBreakpoint;
}
void SetBreakpoint(bool bBreakpoint)
{
this->m_bBreakpoint = bBreakpoint;
}
bool IsClusterJob() const
{
return this->m_bClusterJob;
}
bool IsParallelJob() const
{
return this->isParallelJob;
}
// bool IsStatisApplyJob() const
// {
// return this->isStatisApplyJob;
// }
bool IsMultiwaveJob() const
{
return this->isMultiwaveJob;
}
void SetClusterJob(bool bClusterJob)
{
this->m_bClusterJob = bClusterJob;
}
void SetParallelJob(bool parallelJob)
{
this->isParallelJob = parallelJob;
}
// void SetStatisApplyJob(bool statisApplyJob)
// {
// this->isStatisApplyJob = statisApplyJob;
// }
void SetMultiwaveJob(bool isMultiwaveJob)
{
this->isMultiwaveJob = isMultiwaveJob;
}
void setGPUWorkflow(bool gpuWorkflow)
{
this->m_gpuWorkflow = gpuWorkflow;
}
bool IsGPUWorkflow() const
{
return this->m_gpuWorkflow;
}
/**
* @deprecated should be moved to editor component
*/
std::string GetComments() const
{
return this->m_strComments;
}
void SetComments(std::string strComments)
{
this->m_strComments = strComments;
}
std::vector<CModuleInformation*>* GetModuleInfos() const
{
return this->m_vctModInfos;
}
std::vector<CModuleConnection*>* GetModuleConnections() const
{
return this->m_vctConnections;
}
std::vector<std::string>& GetNeedDelFiles();
void AddNeedDelFile(const std::string &delFile);
bool AddModule(CModuleInformation*);
bool RemoveModule(int moduleId);
CModuleInformation* GetSpecifiedModule(int moduleId);
bool AddConnection(CModuleConnection* connection);
bool RemoveConnection(CModuleConnection* connection);
void RemoveModuleConnections(int);
/**
* @brief
*
* @return
* @warn
*/
CWorkFlowFile* GetEnabledWorkflow();
/**
* @brief
* @param pModule
* @param type
*/
void ProcessForChange(CModuleInformation *pModuleInfo, WorkflowEventType type);
/**
* @brief pModule是否存在
* @param pModule
*/
bool HasModule(CModuleInformation* pModule);
/*
* @brief
* @param[in/out] files
*/
void GetOutPutFilePaths(std::vector<std::string>& files);
/*
* @brief
* @param[in] files
*/
void SetOutPutFilePaths(const std::vector<std::string>& files);
/*
* @brief
* @param[in/out] files
*/
void GetInPutFilePaths(std::vector<std::string>& files);
bool HasRealTimeModule()
{
for(std::vector<CModuleInformation*>::iterator iter = m_vctModInfos->begin();
iter != m_vctModInfos->end(); iter++)
{
if((*iter)->GetClassName() == "CRealTimeModule")
{
return true;
}
}
return false;
}
void GetAllRealTimeModule(std::vector<CModuleInformation*>& moduleList)
{
for(std::vector<CModuleInformation*>::iterator iter = m_vctModInfos->begin();
iter != m_vctModInfos->end(); iter++)
{
if((*iter)->GetClassName() == "CRealTimeModule")
{
moduleList.push_back(*iter);
}
}
}
bool HasRealTimeModuleConn()
{
for(std::vector<CModuleInformation*>::iterator iter = m_vctModInfos->begin();
iter != m_vctModInfos->end(); iter++)
{
if((*iter)->GetClassName() == "CRealTimeModule")
{
int moduleId = (*iter)->GetId();
for(std::vector<pai::workflow::CModuleConnection*>::iterator connIter = m_vctConnections->begin();
connIter != m_vctConnections->end(); connIter++)
{
if((*connIter)->GetDestId() == moduleId || (*connIter)->GetSourceId() == moduleId)
{
return true;
}
}
return false;
}
}
}
/**
* @brief moduleid获取workflowfile中的moduleinformation
* @param[in/out] moduleID workflowfile中的模块id
*/
CModuleInformation* GetModuleInfoByModuleID(const int moduleID);
/**
* @brief moduleName获取workflowfile中的moduleinformation
* @param[in/out] moduleName workflowfile中的模块className
*/
void GetModuleInfoByClassName(std::vector<CModuleInformation*>& moduleList, const std::string& moduleName);
/**
* @brief moduleid获取workflowfile中的CModuleConnectionmoduleid
* moduleconnection的source
* @param[in] moduleID workflowfile中的模块id
* @param[out] result
*/
void GetModuleConnByModuleIDInSource(std::vector<CModuleConnection*>& result, const int moduleID);
/**
* @brief moduleid获取workflowfile中的CModuleConnectionmoduleid
* moduleconnection的dest
* @param[in] moduleID workflowfile中的模块id
* @param[out] result
*/
void GetModuleConnByModuleIDInDest(std::vector<CModuleConnection*>& result, const int moduleID);
void Print();
/**
*@brief vector<1,2>>Module,12
*@param vector
*@param moduleClassName
*/
std::vector<int>GetModuleInputSequence(const std::string& moduleClassName);
/**
*@brief
*@return NULL;
*/
CModule* FindFirstMutiParallModule();
/**
*@brief
*@return id集合;
*/
std::vector<int> GetChildrenModule(int moduleId=-1);
// /**
// *@brief 查找模块的下游模块
// *@return 返回下游模块集合;
// */
// vector<CModuleInformation *> GetChildrenModule(CModuleInformation *parent);
CWorkFlowFile();
CWorkFlowFile(const CWorkFlowFile& workflowfile);
virtual ~CWorkFlowFile();
/**
* @brief ==
*/
friend bool operator ==(const CWorkFlowFile &workflow_1, const CWorkFlowFile &workflow_2);
private:
CCompositeParameterItem* CastCompositeParam(CParameterItem* param);
};
}
}
#endif