添加修饰节点类型
This commit is contained in:
parent
d4100de598
commit
83842aa439
|
@ -93,7 +93,6 @@ std::shared_ptr<ConvertDelegate> MapKernal::getConvert(const QString& name)
|
|||
void MapKernal::registExecute(std::shared_ptr<ExecuteDelegate> ins)
|
||||
{
|
||||
_execute_types[ins->typeName()] = ins;
|
||||
emit this->executeTypeListChanged();
|
||||
}
|
||||
|
||||
std::shared_ptr<MessageLoader> MapKernal::messageLoader() const
|
||||
|
@ -114,6 +113,7 @@ void MapKernal::initial()
|
|||
registNode(std::make_shared<ParallelNode>(this->shared_from_this()));
|
||||
registNode(std::make_shared<CompareNode>(this->shared_from_this()));
|
||||
registNode(std::make_shared<ExecuteNode>(this->shared_from_this()));
|
||||
registNode(std::make_shared<ModifiedNode>(this->shared_from_this()));
|
||||
registNode(std::make_shared<BehaviorMapNode>(this->shared_from_this()));
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ std::weak_ptr<LogicalNode> LogicalNode::parent() const
|
|||
}
|
||||
|
||||
BehaviorMapNode::BehaviorMapNode(std::shared_ptr<MapKernal> core)
|
||||
:LogicalNode(NodeKind::MAPNODE, core){
|
||||
:LogicalNode(NodeKind::MAPNODE, core) {
|
||||
}
|
||||
|
||||
void BehaviorMapNode::setVariable(const QString& key, IO_TYPE t, std::shared_ptr<TopicData> ins)
|
||||
|
@ -844,3 +844,96 @@ void ExecuteNode::saveTo(QJsonObject& obj) const
|
|||
ModifiedNode::ModifiedNode(std::shared_ptr<MapKernal> kernal)
|
||||
: LogicalNode(NodeKind::MODIFYNODE, kernal) {
|
||||
}
|
||||
|
||||
ModifyType ModifiedNode::modifyType() const
|
||||
{
|
||||
return _type_appoint;
|
||||
}
|
||||
|
||||
void ModifiedNode::resetModify(ModifyType t)
|
||||
{
|
||||
this->_type_appoint = t;
|
||||
}
|
||||
|
||||
void ModifiedNode::insert(std::shared_ptr<LogicalNode> node, int index /*= -1*/)
|
||||
{
|
||||
if (children().size())
|
||||
return;
|
||||
|
||||
LogicalNode::insert(node);
|
||||
}
|
||||
|
||||
QString ModifiedNode::typeName() const
|
||||
{
|
||||
switch (modifyType())
|
||||
{
|
||||
case ModifyType::ALWAYS_SUCCESS:
|
||||
return u8"修饰<永远成功>";
|
||||
case ModifyType::ALWAYS_FAILURE:
|
||||
return u8"修饰<永远失败>";
|
||||
case ModifyType::RESULT_INVENTER:
|
||||
return u8"修饰<结果反转>";
|
||||
default:
|
||||
return u8"修饰<>";
|
||||
}
|
||||
}
|
||||
|
||||
QHash<QString, std::shared_ptr<TopicData>> ModifiedNode::inputList() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QHash<QString, std::shared_ptr<TopicData>> ModifiedNode::outputList() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void ModifiedNode::reset()
|
||||
{
|
||||
this->_result_store = LogicalResult::UNDEFINED;
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<LogicalNode>> ModifiedNode::getForwards() const
|
||||
{
|
||||
return children();
|
||||
}
|
||||
|
||||
bool ModifiedNode::fallback(std::shared_ptr<LogicalNode> node, LogicalResult ste)
|
||||
{
|
||||
this->_result_store = ste;
|
||||
return true;
|
||||
}
|
||||
|
||||
LogicalResult ModifiedNode::execute()
|
||||
{
|
||||
switch (_type_appoint)
|
||||
{
|
||||
case ModifyType::RESULT_INVENTER:
|
||||
if (_result_store == LogicalResult::SUCCESS) {
|
||||
return LogicalResult::FAILURE;
|
||||
}
|
||||
else {
|
||||
return LogicalResult::SUCCESS;
|
||||
}
|
||||
case ModifyType::ALWAYS_SUCCESS:
|
||||
return LogicalResult::SUCCESS;
|
||||
case ModifyType::ALWAYS_FAILURE:
|
||||
case ModifyType::NONE:
|
||||
return LogicalResult::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Serializable> ModifiedNode::newDefault() const
|
||||
{
|
||||
return std::make_shared<ModifiedNode>(this->getKernal());
|
||||
}
|
||||
|
||||
void ModifiedNode::recoveryFrom(const QJsonObject& obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ModifiedNode::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -70,10 +70,6 @@ signals:
|
|||
/// 转换器类型列表变更
|
||||
/// </summary>
|
||||
void convertTypeListChanged();
|
||||
/// <summary>
|
||||
/// 执行节点类型列表变更
|
||||
/// </summary>
|
||||
void executeTypeListChanged();
|
||||
|
||||
|
||||
public:
|
||||
|
@ -695,8 +691,8 @@ enum class ModifyType {
|
|||
};
|
||||
class COMPONENTBASIC_EXPORT ModifiedNode : public LogicalNode {
|
||||
private:
|
||||
std::shared_ptr<MapKernal> _bind_kernal;
|
||||
ModifyType _type_appoint = ModifyType::NONE;
|
||||
LogicalResult _result_store = LogicalResult::UNDEFINED;
|
||||
|
||||
public:
|
||||
ModifiedNode(std::shared_ptr<MapKernal> kernal);
|
||||
|
@ -705,6 +701,22 @@ public:
|
|||
void resetModify(ModifyType t);
|
||||
|
||||
|
||||
void insert(std::shared_ptr<LogicalNode> node, int index = -1) override;
|
||||
|
||||
QString typeName() const override;
|
||||
QHash<QString, std::shared_ptr<TopicData>> inputList() const override;
|
||||
QHash<QString, std::shared_ptr<TopicData>> outputList() const override;
|
||||
|
||||
QList<std::shared_ptr<LogicalNode>> getForwards() const override;
|
||||
bool fallback(std::shared_ptr<LogicalNode> node, LogicalResult ste) override;
|
||||
|
||||
void reset() override;
|
||||
LogicalResult execute() override;
|
||||
|
||||
std::shared_ptr<Serializable> newDefault() const override;
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
|
||||
};
|
||||
|
||||
// 行为节点 ====================================================================
|
||||
|
|
Loading…
Reference in New Issue