logplus/Workflow/WFEngine/WorkflowEngine/include/WorkflowGenerator.h
2026-01-16 17:18:41 +08:00

80 lines
2.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* WorkflowGenerator.h
*
* Created on: Jul 28, 2011
* Author: dev
*/
#ifndef PAI_FRAME_WORKFLOWENGINE_CWORKFLOWGENERATOR_H
#define PAI_FRAME_WORKFLOWENGINE_CWORKFLOWGENERATOR_H
#include <string>
#include "TemplateInformation.h"
#include "ConfigureManager.h"
#include <ctemplate/template.h>
using ctemplate::TemplateDictionary;
using pai::workflow::CTemplateInformation;
namespace pai {
namespace workflow {
/**
*@brief 代码生成器类
*模板文件定义了逻辑与文本分离的两种文件格式
*此类是工作流代码生成器的核心,在此类中完成模板文件(.tpl格式)中
*逻辑部分缺省值的代码实现通过Data dictionary将文本代码与
*逻辑代码匹配,从而生成代码文件。
*/
class CWorkflowGenerator {
public:
CWorkflowGenerator(const std::string&, const std::string&);
CWorkflowGenerator();
virtual ~CWorkflowGenerator();
/**@brief 生成工作流代码,完成模板逻辑信息的具体实现。
* 在此函数中构建模板的Data dictionary给出模板信息中variable与section的具体实现形式
* 完成模板逻辑信息的替换。
* @param[in] info
* @see CTemplateInformation
*/
void Generate(CTemplateInformation* info);
/**
* @brief 生成工作流代码Buff
* 在此函数中构建模板的Data dictionary给出模板信息中variable与section的具体实现形式
* 完成模板逻辑信息的替换。
* @param[in] cTemplateInfo 填充的内容
* @param[in/out] strOutContent 填充模板后的内容
*/
void GenerateBuff(CTemplateInformation* cTemplateInfo,std::string& strOutContent);
private:
void WriteToFile(const std::string& strOutContent);
void GetCurrentContent(std::string& strOutContent);
void InitWorkflow(TemplateDictionary* parentDict);
void FillModulesStatements(TemplateDictionary* parentDict);
void FillModuleStatment(TemplateDictionary* parentDict,pai::workflow::SInitializationBlock& block);
void FillStandardModuleParamBlocks(TemplateDictionary* parentDict,pai::workflow::SInitializationBlock& block);
void FillNewBufferStatements(TemplateDictionary* parentDict);
void FillOutputBufferStatements(TemplateDictionary* parentDict);
void FillInputBufferStatements(TemplateDictionary* parentDict);
CWorkflowGenerator(const CWorkflowGenerator & generator);
CWorkflowGenerator & operator=(const CWorkflowGenerator & generator);
private:
std::string cppfile;
ctemplate::TemplateDictionary* rootDictionary;
std::vector<SInitializationBlock> initializationBlocks;
std::vector<SAddingNextModuleStatement> nextModuleStatements;
std::vector<SSettingInputBufferStatement> inputBufferStatements;
std::vector<SSettingOutputBufferStatement> outputBufferStatements;
std::vector<SNewBufferStatement> newBufferStatements;
};
}
}
#endif