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

130 lines
4.0 KiB
C
Raw Normal View History

2026-01-16 17:18:41 +08:00
/*
* UnrelateWorkFlowFileHelper.h
*
* Created on: Mar 5, 2015
* Author: dev
*/
#ifndef PAI_FRAME_WORKFLOWENGINE_UNRELATEWORKFLOWFILEHELPER_H
#define PAI_FRAME_WORKFLOWENGINE_UNRELATEWORKFLOWFILEHELPER_H
#include <set>
#include <vector>
#include "WorkFlowFile.h"
class CUnrelateWorkFlowFileHelperTest;
namespace pai{
namespace workflow{
struct UnrelateRoot2LeafPair
{
std::set<int> roots;
std::set<int> leafs;
bool HasRoots(const int root)
{
if(roots.count(root) > 0)
{
return true;
}else
{
return false;
}
}
void InsertPair(int root, std::set<int>& leaf)
{
roots.insert(root);
for(std::set<int>::iterator iter = leaf.begin(); iter != leaf.end(); iter++)
{
leafs.insert(*iter);
}
}
};
class CUnrelateWorkFlowFileHelper
{
private:
std::vector<CWorkFlowFile*>* unrelatedWorkflowFileList;
friend class ::CUnrelateWorkFlowFileHelperTest; //for test
private:
/**
* @brief workflowfile中的所有输出
* @param[in] workflowFile
* @param[in/out] leafList moduleid
*/
void GetLeafList(CWorkFlowFile* workflowFile, std::set<int>& leafList);
/**
* @brief workflowfile中的所有输入
* @param[in] workflowFile
* @param[in/out] rootList moduleid
*/
void GetRootList(CWorkFlowFile* workflowFile, std::set<int>& rootList);
/**
* @brief
* @param[in] connections
* @param[in] rootList
* @param[in] leafList
* @param[in/out] root2LeafList moduleid id的映射
*/
void GetRoot2LeafList(std::vector<CModuleConnection*>* connections, std::set<int>& rootList,
std::set<int>& leafList, std::map<int, std::set<int> >& root2LeafList);
/**
* @brief
* @param[in] connections
* @param[in] leafList
* @param[in] moduleID id
* @param[in/out] findLeafs
*/
void InternalGetRoot2LeafList(std::vector<CModuleConnection*>* connections,
std::set<int>& leafList, int moduleID, std::set<int>& findLeafs);
/**
* @brief
* @param[in] root2LeafList moduleid id的映射
* @param[in/out] root2LeafPairList
*/
void GetUnrelateRoot2LeafPair(std::map<int, std::set<int> >& root2LeafList,
std::vector<UnrelateRoot2LeafPair>& root2LeafPairList);
/**
* @brief rootlist中跟节点
* @param[in] rootList
* @param[in] connections
* @param[in/out] unrelateWorkflowModuleIDs moduleid
*/
void GetUnrelateModuleIdByRootId(std::set<int>& rootList, std::vector<CModuleConnection*>* connections,
std::set<int>& unrelateWorkflowModuleIDs);
/**
* @brief
* @param[in] sourceId
* @param[in] connections
* @param[in/out] unrelateWorkflowModuleIDs moduleid
*/
void InneralGetUnrelateModuleIdByRootId(const int sourceId, std::vector<CModuleConnection*>* connections,
std::set<int>& unrelateWorkflowModuleIDs);
/**
* @brief sourceWorkflowFile的基础上创建新的workflowfile对象
* @param[in] sourceWorkflowFile
* @param[in] unrelateWorkflowModuleIDs workflowfile中包含的moduleid
* @return workflowfile对象
*/
CWorkFlowFile* GetNewWorkFlowFile(CWorkFlowFile* sourceWorkflowFile,
std::set<int>& unrelateWorkflowModuleIDs);
public:
CUnrelateWorkFlowFileHelper(CWorkFlowFile* workflowFile);
~CUnrelateWorkFlowFileHelper();
/**
* @brief workflowFile拆分后workflowFile有可能出现多个互补相干的工作流
* @param[in] workflowFile
* @param[in/out] unrelatedWorkflowFileList
*/
std::vector<CWorkFlowFile*>* GetUnrelatedWorkFlowFile();
void GetTopLevelWkf(std::vector<CWorkFlowFile*>& result, std::map<int, int>& outputID2inputID);
};
}
}
#endif /* WORKFLOWFILEWRAPPER_H_ */