#pragma once #include "EvaluatedValue.hpp" #include #include #include #include #include class WorkflowConnection { public: size_t Source; size_t Destination; }; class WorkflowStep { public: static constexpr auto kInvalidId = std::numeric_limits::max(); // TODO do we even need this? // enum Type { // NumericAdditionType, // NumericSubtractionType, // NumericMultiplicationType, // NumericDivisionType, // NumericExpressionType, // TextFormattingType, // FormInputType, // DatabaseRowsInputType, // DocumentTemplateExpansionType, // // InvalidType, // TypeCount = InvalidType, // }; protected: struct InputNode { size_t ConnectedStep = kInvalidId; int ConnectedNodeIndex = -1; BaseValue::Type MatchingType = BaseValue::InvalidType; bool IsConnected() const; }; struct OutputNode { size_t ConnectedStep = kInvalidId; int ConnectedNodeIndex = -1; BaseValue::Type MatchingType = BaseValue::InvalidType; bool IsConnected() const; }; friend class Workflow; Workflow* mWorkflow; size_t mId; std::vector mInputs; std::vector mOutputs; public: virtual ~WorkflowStep() = default; WorkflowStep(const WorkflowStep&) = delete; WorkflowStep& operator=(const WorkflowStep&) = delete; WorkflowStep(WorkflowStep&&) = default; WorkflowStep& operator=(WorkflowStep&&) = default; size_t GetId() const; void ConnectInput(int nodeId, size_t outputId, int outputNodeId); void DisconnectInput(int nodeId); bool IsInputConnected(int nodeId) const; void ConnectOutput(int nodeId, size_t inputId, int inputNodeId); void DisconnectOutput(int nodeId); bool IsOutputConnected(int nodeId) const; protected: /// Child classes should call this whenever \c mInputs and \c mOutputs are about to be modified (append or remove) /// after invocation of the constructor. void OnIOAboutToChange(); void OnIOChanged(); }; class Workflow { private: std::vector mConnections; std::vector> mSteps; public: WorkflowConnection* GetConnectionById(size_t id); WorkflowStep* GetStepById(size_t id); void Connect(size_t source, int sourceNode, size_t destination, int destinationNode); void DisconnectBySource(size_t source, int sourceNode); void DisconnectByDestination(size_t destination, int destinationNode); }; class WorkflowEvaluationContext { };