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

91 lines
3.3 KiB
C
Raw Normal View History

2026-01-16 17:18:41 +08:00
/**
* @file CycleChecker.h
* @brief
*
* @author
* @date 2011-10-24
*/
#ifndef PAI_FRAME_WORKFLOWENGINE_CYCLECHECKER_H
#define PAI_FRAME_WORKFLOWENGINE_CYCLECHECKER_H
#include "WorkFlowFile.h"
#include "WorkflowChecker.h"
#include <string>
#include <map>
#include <vector>
#include <set>
/**
*
*/
#define CONST_SPLIT_PATH_FLAG "-"
namespace pai {
namespace workflow {
/**
*@brief
*
*
*
*
*/
class PAI_WORKFLOWENGINE_EXPORT CCycleChecker: public CWorkflowChecker
{
public:
CCycleChecker();
virtual ~CCycleChecker();
/**
*@brief
*@param [in]workflow输入的工作流对象
*@param [out]ioPaths所有的iopath路径的集合
*@param [out]strErrorMsg
*/
bool GetAllIoPaths(CWorkFlowFile* workflow, std::vector<std::string>&ioPaths, std::string&strErrorMsg);
protected:
/**
* @brief
* @param [in] workflow
* @param [out] strErrorMsg false
*/
virtual bool StepCheck(CWorkFlowFile* workflow, std::string& strErrorMsg);
private:
/**
*@brief
*@param [in]parentPath
*@param [in]parentId
*@param [in]parentNodeClassNamePath
*@param [out]strErrorMsg
*/
void findChildNodeCycle(const std::string& parentPath,int parentId,const std::string& parentNodeClassNamePath,std::string& strErrorMsg);
void InitChildNodesMap(CWorkFlowFile* workflow);
void InitRootlist(CWorkFlowFile* workflow);
bool HasCycle(const std::string& parentNodePath, const std::string& currendNodeId);
std::string GetArc(const std::string& parentNodeId, const std::string& currentNodeId) const;
std::string GetPath(const std::string& parentPath, const std::string& currentId) const;
/**
*@brief inputmodule到outpumodule的以classname连接的路径
*@param [int]parentNodeClassNamePath classname连接
*@param [in]currentId id set容器中的位置
*@param [in]rootposition
*/
std::string GetCurrentPath(const std::string& parentNodeClassNamePath, const std::string& currentId);
/**
*@brief stepId和classname关联放入stepIdToClassNameMaps之中
*/
void CombineStepIdAndClassName(CWorkFlowFile* workflow);
private:
std::set<int> rootlist;
std::map<int, std::vector<int> > childnodesmaps;
std::set<std::string> traversedarcset;
//用与记录inputmodule->outputmodule的总路径
std::vector<std::string> iopaths;
//将模块的stepid与moduleId关联
std::map<std::string, std::string> stepIdToClassNameMaps;
};
}
}
#endif