Skip to content
Snippets Groups Projects
Commit 7ab054e6 authored by Recolic K's avatar Recolic K
Browse files

add GS patch

parent f0bc7bd1
No related branches found
No related tags found
No related merge requests found
Pipeline #860 passed with stage
in 9 seconds
......@@ -15,6 +15,8 @@
#include <rlib/require/cxx14>
#include <rlib/scope_guard.hpp>
#include "dirty-plugins.hpp"
namespace CIS {
using std::string;
using namespace rlib::literals;
......@@ -142,7 +144,7 @@ namespace CIS {
Flow(const Flow &another) : queuedOnRight(another.queuedOnRight), xamlCode(another.xamlCode), prevOperationIsSequential(another.prevOperationIsSequential) {}
// Actually modify xamlCode on "OperationChange".
// for example, A >> B >> C >> D | E. ABCD should be merged into one sequential operation.
// for example, A >> B >> C >> (D | E). ABCD should be merged into one sequential operation.
Flow operator>>(const Flow &seqNext) const {
return binaryOperation(seqNext, true);
}
......@@ -230,7 +232,7 @@ namespace CIS {
inline auto Flow::generateXaml(Metadata metadata) const {
Flow finalized(*this);
finalized.reduceQueuedIfNecessary(!finalized.prevOperationIsSequential); // Always necessary if queue is not empty.
return metadata.generateXamlHead() + finalized.xamlCode + metadata.generateXamlTail();
return metadata.generateXamlHead() + dirty_plugins::patchGS(finalized.xamlCode) + metadata.generateXamlTail();
}
inline auto Flow::generateXaml(std::string className) const {
Metadata defaultMetadata(className);
......
#ifndef CIS_WORKFLOW_GEN_DIRTY_PLUGIN_HPP
#define CIS_WORKFLOW_GEN_DIRTY_PLUGIN_HPP
#include <rlib/string.hpp>
#include "xaml-template.hpp"
namespace CIS::dirty_plugins {
rlib::string patchGS(const rlib::string &input) {
rlib::string output (input);
auto pos_seq = output.find("ControlledSequence");
auto pos_par = output.find("ControlledParallel");
rlib::string plugin_text = CIS::templates::PLUGIN_GlobalSettingsVariable_SEQ;
if(pos_seq == rlib::string::npos && pos_par == rlib::string::npos)
return output;
else if(pos_seq == rlib::string::npos || pos_par < pos_seq)
plugin_text.replace("ControlledSequence", "ControlledParallel");
// else OutMost is sequence, nothing to do.
return output.replace_once(">\n", ">\n" + plugin_text);
}
}
#endif
......@@ -110,6 +110,13 @@ constexpr auto NOOP_XAML =
R"XAML( <mwcwa:NoOpsActivity DisplayName="__TEMPLATE_ARG_DisplayName" __TEMPLATE_ARG_EntityDefPlaceholder/>
)XAML";
// The top-level Sequence or Parallel, need to add this "plugin" to make it happy.
constexpr auto PLUGIN_GlobalSettingsVariable_SEQ =
R"XAML( <mwcwa:ControlledSequence.Variables>
<Variable x:TypeArguments="mwcwcs:GlobalSettings" Name="GlobalSettings" />
</mwcwa:ControlledSequence.Variables>
)XAML";
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment