添加Delegate校验机制

This commit is contained in:
codeboss 2025-08-10 17:07:28 +08:00
parent 66c957d7e5
commit 9171ae8786
1 changed files with 12 additions and 2 deletions

View File

@ -77,13 +77,23 @@ QHash<QString, std::shared_ptr<ExtractImpl>> TranslateBasic::totalExtractors() c
void TranslateBasic::addDelegate(std::shared_ptr<ExtractImpl> inst)
{
auto exist = std::count_if(
auto repeat_name_count = std::count_if(
this->_custom_rule_types.begin(), this->_custom_rule_types.end(),
[=](std::shared_ptr<ExtractImpl> v) {
return v->aliasName() == inst->aliasName();
});
assert("RuleName不能重复" && !exist);
if(repeat_name_count)
throw new BaseException(u8"RuleName不能重复");
switch (inst->outType()) {
case DataType::LIST_COLLECTION:
case DataType::UNION_COMBINATE:
throw new BaseException(u8"不能接受的委托类型!");
default:
break;
}
this->_custom_rule_types << inst;
}