Initial commit
This commit is contained in:
Executable
+209
@@ -0,0 +1,209 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <wfr/common/types/WfsTypes.h>
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
|
||||
// Forward declarations
|
||||
namespace enactment {
|
||||
class WepBuilder;
|
||||
}
|
||||
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Workflow;
|
||||
class ActivityInstance;
|
||||
class ActivityTemplate;
|
||||
|
||||
|
||||
class Activity {
|
||||
friend class ActivityTemplate;
|
||||
friend class Workflow;
|
||||
friend class enactment::WepBuilder;
|
||||
|
||||
// Static non-public properties
|
||||
private:
|
||||
/**
|
||||
* Static variable holding the next free activityID.
|
||||
**/
|
||||
static std::atomic<wfr_id_t> nextActivityID;
|
||||
|
||||
/**
|
||||
* Returns the next free activityID.
|
||||
*
|
||||
* @return next free activityID.
|
||||
*/
|
||||
static wfr_id_t getNextActivityID() { return nextActivityID.fetch_add(1); }
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
private:
|
||||
/** Status of this activity object. **/
|
||||
ActivityStatus status;
|
||||
|
||||
/** Vector holding references to instances of this workflow activity. **/
|
||||
std::vector<ActivityInstance*> instanceList;
|
||||
|
||||
/** Reference to the parent of this activity object (structure-wise). **/
|
||||
Activity* parent = nullptr;
|
||||
|
||||
std::vector<Activity*> successors;
|
||||
|
||||
std::vector<Activity*> predecessors;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
/** Unique ID of this workflow activity. **/
|
||||
const wfr_id_t activityID;
|
||||
|
||||
/** Parent workflow instance of this activity object. **/
|
||||
Workflow& workflow;
|
||||
|
||||
/** Parent activitiy template of this activity object. **/
|
||||
ActivityTemplate& baseTemplate;
|
||||
|
||||
|
||||
// Non-public functions
|
||||
private:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param workflow workflow instance this activity object belongs to.
|
||||
* @param baseTemplate activity template this object is associated with.
|
||||
* @param parent the parent activity of this object (structure-wise).
|
||||
*/
|
||||
Activity( Workflow& workflow, ActivityTemplate& baseTemplate );
|
||||
|
||||
/**
|
||||
* Initialises this activity object.
|
||||
*
|
||||
* @param activities list of activities for successor/predecessor lists generation.
|
||||
**/
|
||||
void initActivity();
|
||||
|
||||
/**
|
||||
* Creates a new activity instance of this activity object.
|
||||
*
|
||||
* @return new activity instance.
|
||||
**/
|
||||
ActivityInstance* createNewInstance(wfr_id_t iterationID = 0);
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
/** Destructor. **/
|
||||
~Activity() noexcept;
|
||||
|
||||
ActivityType activityType() const noexcept;
|
||||
|
||||
bool isCompositeActivity() const noexcept;
|
||||
|
||||
bool isLoop() const noexcept;
|
||||
|
||||
bool isConditional() const noexcept;
|
||||
|
||||
/**
|
||||
* Returns the number of activity instances of this activity object.
|
||||
*
|
||||
* @return number of activity instances.
|
||||
**/
|
||||
wfr_size_t getInstanceCount() const noexcept { return instanceList.size(); }
|
||||
|
||||
/**
|
||||
* Returns a reference to the vector holding the activity instance references.
|
||||
*
|
||||
* @return reference to the vector holding the activity instance references.
|
||||
**/
|
||||
const std::vector<ActivityInstance*>& getInstanceList() const noexcept { return instanceList; }
|
||||
|
||||
/**
|
||||
* Returns the parent activity of this object (structure-wise).
|
||||
*
|
||||
* @return parent activity.
|
||||
**/
|
||||
Activity* getParent() const noexcept { return parent; }
|
||||
|
||||
wfr_size_t getChildrenCount(wfr_id_t branchID = 0) const noexcept;
|
||||
|
||||
std::vector<Activity*> getChildren(wfr_id_t branchID = 0) const noexcept;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of successors.
|
||||
*
|
||||
* @return number of successors.
|
||||
**/
|
||||
wfr_size_t getSuccessorCount() const noexcept { return successors.size(); }
|
||||
|
||||
/**
|
||||
* Returns a reference to the array holding the successors.
|
||||
*
|
||||
* @return reference to the array holding the successors.
|
||||
**/
|
||||
const std::vector<Activity*> getSuccessors() const noexcept { return successors; }
|
||||
|
||||
/**
|
||||
* Returns whether the given activityID belongs to a successor.
|
||||
*
|
||||
* @param aid activityID to test.
|
||||
* @return true if successor, false otherwise.
|
||||
*/
|
||||
bool isSuccessor(wfr_id_t aid) const noexcept;
|
||||
|
||||
/**
|
||||
* Returns whether the given reference is a successor.
|
||||
*
|
||||
* @param act reference to test
|
||||
* @return true if successor, false otherwise.
|
||||
*/
|
||||
bool isSuccessor(Activity& act) const noexcept;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of predecessors.
|
||||
*
|
||||
* @return number of predecessors.
|
||||
**/
|
||||
wfr_size_t getPredecessorCount() const noexcept { return predecessors.size(); }
|
||||
|
||||
/**
|
||||
* Returns a reference to the array holding the predecessors.
|
||||
*
|
||||
* @return reference to the array holding the predecessors.
|
||||
**/
|
||||
const std::vector<Activity*> getPredecessors() { return predecessors; }
|
||||
|
||||
/**
|
||||
* Returns whether the given activityID belongs to a predecessor.
|
||||
*
|
||||
* @param aid activityID to test.
|
||||
* @return true if predecessor, false otherwise.
|
||||
*/
|
||||
bool isPredecessor(wfr_id_t aid) const noexcept;
|
||||
|
||||
/**
|
||||
* Returns whether the given reference is a predecessor.
|
||||
*
|
||||
* @param act reference to test
|
||||
* @return true if predecessor, false otherwise.
|
||||
*/
|
||||
bool isPredecessor(Activity& act) const noexcept;
|
||||
|
||||
/**
|
||||
* Returns the status of this activity.
|
||||
*
|
||||
* @return activity status.
|
||||
**/
|
||||
ActivityStatus getActivityStatus() const noexcept { return status; }
|
||||
|
||||
void setActivityStatus(ActivityStatus status);
|
||||
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
Executable
+282
@@ -0,0 +1,282 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <wfr/common/types/WfsTypes.h>
|
||||
#include <wfr/common/types/LwdTypes.h>
|
||||
#include <wfr/common/exceptions/exceptions.h>
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace wfr {
|
||||
|
||||
// Forward declarations
|
||||
namespace scheduling { class SchedulingDecision; }
|
||||
namespace enactment { class WepBuilder; }
|
||||
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
|
||||
|
||||
class ActivityInstance {
|
||||
friend class enactment::WepBuilder;
|
||||
|
||||
// Static non-public properties
|
||||
private:
|
||||
/**
|
||||
* Static variable holding the next free activity instanceID.
|
||||
**/
|
||||
static std::atomic<wfr_id_t> nextInstanceID;
|
||||
|
||||
/**
|
||||
* Returns the next free activity instanceID.
|
||||
*
|
||||
* @return next free activity instanceID.
|
||||
*/
|
||||
static wfr_id_t getNextInstanceID();
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
protected:
|
||||
/** Activity instance state. **/
|
||||
ActivityInstanceStatus status;
|
||||
|
||||
/** Reference to the parent of this activity instance object (structure-wise). **/
|
||||
ActivityInstance* parentActivity = nullptr;
|
||||
|
||||
/** Vector of successors. **/
|
||||
std::vector<ActivityInstance*> successors;
|
||||
|
||||
/** Vector of predecessors. **/
|
||||
std::vector<ActivityInstance*> predecessors;
|
||||
|
||||
/** Reference to input data struct. **/
|
||||
lwd::_wfr_lwd *inputData = nullptr;
|
||||
bool inputDataOwnership = false;
|
||||
|
||||
/** Reference to output data struct. **/
|
||||
lwd::_wfr_lwd *outputData = nullptr;
|
||||
bool outputDataOwnership = false;
|
||||
|
||||
bool allInputsAvailable = false;
|
||||
|
||||
bool allOutputsAvailable = false;
|
||||
|
||||
std::exception_ptr errorCause;
|
||||
|
||||
wfr::wfr_timestamp_sc_t readyTime;
|
||||
|
||||
wfr::wfr_timestamp_sc_t startTime;
|
||||
|
||||
wfr::wfr_timestamp_sc_t endTime;
|
||||
|
||||
uint64_t visitationCount = 0;
|
||||
|
||||
bool dirtyStateFlag = false;
|
||||
|
||||
std::shared_ptr<void> userData;
|
||||
|
||||
std::shared_ptr<scheduling::SchedulingDecision> schedulingDecision;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
/** Unique ID of this activity instance object. **/
|
||||
const wfr_id_t instanceID;
|
||||
|
||||
/** Activity this object is an instance of. **/
|
||||
const Activity& baseActivity;
|
||||
|
||||
const wfr_id_t iterationID;
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param parentActivity activity this object is an instance of.
|
||||
*/
|
||||
ActivityInstance(Activity& baseActivity, const wfr_id_t& iterationID = 0) noexcept;
|
||||
|
||||
/** Destructor. **/
|
||||
virtual ~ActivityInstance() noexcept {
|
||||
if (inputData && inputDataOwnership) {
|
||||
delete inputData;
|
||||
inputData = nullptr;
|
||||
}
|
||||
if (outputData && outputDataOwnership) {
|
||||
delete outputData;
|
||||
outputData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ActivityType activityType() const noexcept;
|
||||
|
||||
bool isCompositeActivity() const noexcept;
|
||||
|
||||
bool isLoop() const noexcept;
|
||||
|
||||
bool isConditional() const noexcept;
|
||||
|
||||
/**
|
||||
* Returns the state of this activity instance.
|
||||
*
|
||||
* @return state of this activity instance.
|
||||
**/
|
||||
ActivityInstanceStatus getInstanceStatus() const noexcept { return status; }
|
||||
|
||||
/**
|
||||
* Sets the state of this activity instance.
|
||||
*
|
||||
* @param status new state.
|
||||
**/
|
||||
void setInstanceStatus(const ActivityInstanceStatus& status);
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns a reference to this activity instance input data.
|
||||
*
|
||||
* @return input data.
|
||||
**/
|
||||
lwd::_wfr_lwd* const getInputData() const noexcept { return inputData; }
|
||||
|
||||
/**
|
||||
* Sets this instants input data.
|
||||
*
|
||||
* @param data input data.
|
||||
*/
|
||||
void setInputData(lwd::_wfr_lwd* data, bool ownership = true) noexcept {
|
||||
inputData = data;
|
||||
inputDataOwnership = ownership;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns a reference to this activity instance output data.
|
||||
*
|
||||
* @return output data.
|
||||
**/
|
||||
lwd::_wfr_lwd* const getOutputData() const noexcept { return outputData; }
|
||||
|
||||
/**
|
||||
* Sets this instants output data.
|
||||
*
|
||||
* @param data output data.
|
||||
*/
|
||||
void setOutputData(lwd::_wfr_lwd* data, bool ownership = true) noexcept {
|
||||
outputData = data;
|
||||
outputDataOwnership = ownership;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of predecessors.
|
||||
*
|
||||
* @return number of predecessors.
|
||||
**/
|
||||
wfr_size_t getPredecessorCount() const noexcept { return predecessors.size(); }
|
||||
|
||||
const std::vector<ActivityInstance*>& getPredecessors() const noexcept { return predecessors; }
|
||||
|
||||
std::vector<ActivityInstance*>& getPredecessors() noexcept { return predecessors; }
|
||||
|
||||
ActivityInstance* const getPredecessor(wfr_size_t index) const noexcept {
|
||||
return predecessors.at(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of successors.
|
||||
*
|
||||
* @return number of successors.
|
||||
**/
|
||||
wfr_size_t getSuccessorCount() const noexcept { return successors.size(); }
|
||||
|
||||
const std::vector<ActivityInstance*>& getSuccessors() const noexcept { return successors; }
|
||||
|
||||
std::vector<ActivityInstance*>& getSuccessors() noexcept { return successors; }
|
||||
|
||||
ActivityInstance* const getSuccessor(int index) const noexcept {
|
||||
return successors.at(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent of this instance (structure-wise).
|
||||
*
|
||||
* @return parent of this instance.
|
||||
**/
|
||||
ActivityInstance* const getParentActivity() const noexcept { return parentActivity; }
|
||||
|
||||
/**
|
||||
* Sets the parent of this instance (structure-wise).
|
||||
*
|
||||
* parent parent of this instance.
|
||||
**/
|
||||
void setParentActivity(ActivityInstance* parent) noexcept { this->parentActivity = parent; }
|
||||
|
||||
|
||||
bool areAllInputsAvailable() const noexcept { return allInputsAvailable; }
|
||||
|
||||
void setAllInputsAvailable(const bool& areAvailable = true) noexcept { allInputsAvailable = areAvailable; }
|
||||
|
||||
bool areAllOutputsAvailable() const noexcept { return allOutputsAvailable; }
|
||||
|
||||
void setAllOutputsAvailable(const bool& areAvailable = true) noexcept { allOutputsAvailable = areAvailable; }
|
||||
|
||||
|
||||
std::exception_ptr getErrorCause() const noexcept { return errorCause; }
|
||||
|
||||
void setErrorState(std::exception_ptr exception = nullptr)noexcept;
|
||||
|
||||
|
||||
const wfr::wfr_timestamp_sc_t& getReadyTime() const noexcept { return readyTime; }
|
||||
|
||||
const wfr::wfr_timestamp_sc_t& getStartTime() const noexcept { return startTime; }
|
||||
|
||||
const wfr::wfr_timestamp_sc_t& getEndTime() const noexcept { return endTime; }
|
||||
|
||||
|
||||
uint64_t getVisitationCount() const noexcept { return visitationCount; }
|
||||
|
||||
void addToVisitationCount(uint64_t val = 1) noexcept { visitationCount += val; }
|
||||
|
||||
|
||||
void setDirtyState() { dirtyStateFlag = true; }
|
||||
|
||||
bool isDirtyState() const { return dirtyStateFlag; }
|
||||
|
||||
void resetDirtyState() { dirtyStateFlag = false; }
|
||||
|
||||
|
||||
virtual bool executePreExecutionHooks(bool earlyEvaluation) { return false; }
|
||||
|
||||
virtual bool executeExecutionHook(bool earlyEvaluation) { return false; }
|
||||
|
||||
virtual bool executePostExecutionHooks(bool earlyEvaluation) { return false; }
|
||||
|
||||
std::shared_ptr<void> getUserData() { return userData; }
|
||||
|
||||
void setUserData(std::shared_ptr<void> data) { userData = data; }
|
||||
|
||||
void setSchedulingDecision(std::shared_ptr<scheduling::SchedulingDecision> sd = std::shared_ptr<scheduling::SchedulingDecision>()) noexcept {
|
||||
if (sd) {
|
||||
this->schedulingDecision = sd;
|
||||
} else {
|
||||
this->schedulingDecision.reset();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void executeSimMode() noexcept;
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
T& as() noexcept { return *static_cast<T*>(this); }
|
||||
|
||||
template<class T>
|
||||
const T& as() const noexcept { return *static_cast<const T*>(this); }
|
||||
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
Executable
+257
@@ -0,0 +1,257 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/types/LwdTypes.h>
|
||||
#include <wfr/common/types/WfsTypes.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
// forward declarations
|
||||
class Workflow;
|
||||
class WorkflowTemplate;
|
||||
class Activity;
|
||||
class AtomicActivityImplementation;
|
||||
class AtomicActivityType;
|
||||
|
||||
|
||||
class ActivityTemplate {
|
||||
friend class WorkflowTemplate;
|
||||
friend class Workflow;
|
||||
friend class Activity;
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
protected:
|
||||
/** Parent activity. **/
|
||||
ActivityTemplate* parentActivity = nullptr;
|
||||
|
||||
/** Parent workflow. **/
|
||||
WorkflowTemplate* parentWorkflow = nullptr;
|
||||
|
||||
// Successors
|
||||
std::initializer_list<wfr_id_t> succRawList;
|
||||
std::vector<ActivityTemplate*> successors;
|
||||
|
||||
// Predecessors
|
||||
std::initializer_list<wfr_id_t> predRawList;
|
||||
std::vector<ActivityTemplate*> predecessors;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
/** Unique ID (>0).**/
|
||||
const wfr_id_t templateID;
|
||||
|
||||
const std::string activityName;
|
||||
|
||||
const ActivityType activityType;
|
||||
|
||||
const wfr_size_t parentActivityID;
|
||||
|
||||
/** BranchID of the parents execution branch (0 represents default branch). **/
|
||||
const wfr_id_t branchID;
|
||||
|
||||
const bool isCompositeActivity;
|
||||
|
||||
const bool isLoop;
|
||||
|
||||
const bool isConditional;
|
||||
|
||||
// Non-public functions.
|
||||
protected:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param id templateID of this template object.
|
||||
* @param type type of this template object.
|
||||
* @param branchID ID of the parents (structure-wise) execution branch this object belongs to.
|
||||
* @param succList list of templateIDs representing this objects successors (structure-wise).
|
||||
* @param predList list of templateIDs representing this objects predecessors (structure-wise).
|
||||
* @param name activity name of this object.
|
||||
**/
|
||||
ActivityTemplate( wfr_id_t id,
|
||||
ActivityType type,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
bool isCompositeActivity,
|
||||
bool isLoop,
|
||||
bool isConditional ) noexcept;
|
||||
|
||||
void initActivityTemplate(WorkflowTemplate& parentWorkflow);
|
||||
|
||||
virtual void checkStructure();
|
||||
|
||||
Activity* createActivityFromTemplate(wfr::wfs::Workflow& workflow);
|
||||
|
||||
// Public functions.
|
||||
public:
|
||||
virtual ~ActivityTemplate() noexcept {}
|
||||
|
||||
ActivityTemplate* getParentActivity() const noexcept { return parentActivity;}
|
||||
|
||||
WorkflowTemplate* getParentWorkflow() const noexcept {
|
||||
assert(parentWorkflow != nullptr);
|
||||
return parentWorkflow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of this objects successors.
|
||||
* @return number of successors.
|
||||
**/
|
||||
wfr_size_t getSuccessorCount() const noexcept { return successors.size(); }
|
||||
|
||||
/**
|
||||
* Returns all successors.
|
||||
* @return reference to vector with successors
|
||||
**/
|
||||
const std::vector<ActivityTemplate*>& getSuccessors() const noexcept { return successors; }
|
||||
|
||||
/**
|
||||
* Returns the successor with the given index.
|
||||
* @param index index of successor
|
||||
* @return successor with given index
|
||||
**/
|
||||
ActivityTemplate* getSuccessor(wfr_size_t index) const noexcept {
|
||||
if (index < successors.size()) {
|
||||
return successors[index];
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given activity is a successor of this object.
|
||||
* @param activity reference to test.
|
||||
* @return true if the given reference represents a successor, otherwise false.
|
||||
**/
|
||||
bool isSuccessor(const ActivityTemplate& activity) const noexcept {
|
||||
for (auto i : successors) {
|
||||
if (i == &activity) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of this objects predecessors.
|
||||
* @return number of predecessors.
|
||||
**/
|
||||
wfr_size_t getPredecessorCount() const noexcept { return predecessors.size(); }
|
||||
|
||||
/**
|
||||
* Returns all predecessors.
|
||||
* @return reference to vector with predecessors
|
||||
**/
|
||||
const std::vector<ActivityTemplate*>& getPredecessors() const noexcept { return predecessors; }
|
||||
|
||||
/**
|
||||
* Returns the predecessor with the given index.
|
||||
* @param index index of predecessor
|
||||
* @return predecessor with given index
|
||||
**/
|
||||
ActivityTemplate* getPredecessor(wfr_size_t index) const noexcept {
|
||||
if (index < predecessors.size()) {
|
||||
return predecessors[index];
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given activity is a successor of this object.
|
||||
* @param activity reference to test.
|
||||
* @return true if the given reference represents a successor, otherwise false.
|
||||
**/
|
||||
bool isPredecessor(const ActivityTemplate& activity) const noexcept {
|
||||
for (auto i : predecessors) {
|
||||
if (i == &activity) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T& as() noexcept { return *static_cast<T*>(this); }
|
||||
|
||||
template<class T>
|
||||
const T& as() const noexcept { return *static_cast<const T*>(this); }
|
||||
|
||||
|
||||
/* ********************************************************** *
|
||||
* Convenience functions for activity template instantiation. *
|
||||
* ********************************************************** */
|
||||
public:
|
||||
|
||||
static ActivityTemplate* atomic( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
std::initializer_list<wfr_id_t> succList,
|
||||
std::initializer_list<wfr_id_t> predList,
|
||||
InputHookFunc inputHook,
|
||||
std::shared_ptr<AtomicActivityType> atomicActivityType );
|
||||
|
||||
static ActivityTemplate* assign( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
std::initializer_list<wfr_id_t> succList,
|
||||
std::initializer_list<wfr_id_t> predList,
|
||||
InputHookFunc inputHook,
|
||||
ExecutionHookFunc execHook );
|
||||
|
||||
static ActivityTemplate* container( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
std::initializer_list<wfr_id_t> succList,
|
||||
std::initializer_list<wfr_id_t> predList,
|
||||
InputHookFunc inputHook,
|
||||
OutputHookFunc outputHook );
|
||||
|
||||
static ActivityTemplate* forLoop( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
InputHookFunc inputFuncHook,
|
||||
OutputHookFunc outputFuncHook,
|
||||
ForCounterHookFunc counterFuncHook,
|
||||
LoopIterationHookFunc iterationFuncHook,
|
||||
bool isParallel );
|
||||
|
||||
static ActivityTemplate* whileLoop( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
InputHookFunc inputFuncHook,
|
||||
OutputHookFunc outputFuncHook,
|
||||
WhileConditionHookFunc conditionFuncHook,
|
||||
LoopIterationHookFunc iterationFuncHook );
|
||||
|
||||
static ActivityTemplate* conditional( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
InputHookFunc inputFuncHook,
|
||||
OutputHookFunc outputFuncHook,
|
||||
BranchConditionHookFunc branchFuncHook );
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/types/WfsTypes.h>
|
||||
#include <wfr/common/resource/ResourceCapabilities.h>
|
||||
#include <wfr/common/utils/Properties.h>
|
||||
#include <initializer_list>
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
/**
|
||||
* Base class for atomic activity implementations.
|
||||
*
|
||||
* Must be cast to type specific class to be able to access type specific information.
|
||||
* Currently implemented sub-classes:
|
||||
* x) PThreadActivityImplementation
|
||||
* x) OpenCLActivityImplementation
|
||||
* x) CUDAActivityImplementation
|
||||
**/
|
||||
class AtomicActivityImplementation {
|
||||
|
||||
// Static objects to guarantee unique implementation IDs.
|
||||
private:
|
||||
static std::atomic<wfr_id_t> nextImplementationID;
|
||||
static wfr_id_t getNextImplementationID() {
|
||||
return nextImplementationID.fetch_add(1);
|
||||
}
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
protected:
|
||||
std::vector<resource::RequiredResourceCapability> requiredCapabilities;
|
||||
utils::Properties properties;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const wfr_id_t implementationID;
|
||||
const ActivityImplementationType implementationType;
|
||||
const std::string name;
|
||||
|
||||
// Non-public functions.
|
||||
protected:
|
||||
AtomicActivityImplementation( ActivityImplementationType implementationType,
|
||||
const std::vector<resource::RequiredResourceCapability>& capabilities,
|
||||
const utils::Properties& properties,
|
||||
const std::string& name) noexcept
|
||||
: requiredCapabilities(capabilities), properties(properties),
|
||||
implementationID(getNextImplementationID()), implementationType(implementationType), name(name) {}
|
||||
|
||||
// Public functions.
|
||||
public:
|
||||
virtual ~AtomicActivityImplementation() noexcept {}
|
||||
|
||||
/**
|
||||
* Returns a vector with capabilities required for execution of this implementation.
|
||||
**/
|
||||
const std::vector<resource::RequiredResourceCapability>& getRequiredCapabilities() const noexcept { return requiredCapabilities; }
|
||||
|
||||
/**
|
||||
* Returns properties associated with this implementation.
|
||||
**/
|
||||
const utils::Properties& getProperties() const noexcept { return properties; }
|
||||
|
||||
/**
|
||||
* Helper function to ease cast operations.
|
||||
**/
|
||||
template<class T>
|
||||
T& as() noexcept { return *static_cast<T*>(this); }
|
||||
|
||||
/**
|
||||
* Const helper function to ease cast operations.
|
||||
**/
|
||||
template<class T>
|
||||
const T& as() const noexcept { return *static_cast<const T*>(this); }
|
||||
|
||||
/*
|
||||
* Static factory functions for creating activity implementation objects.
|
||||
*
|
||||
* Returned objects need to be manually deleted (Using smartpointers here causes too much overhead).
|
||||
* AtomicActivityImplementation objects are usually passed to an AtomicActivityType object which manages the lifecycle.
|
||||
*/
|
||||
public:
|
||||
/**
|
||||
* Returns a new pthread implementation object.
|
||||
*
|
||||
* Do not add GenericCPU capability as it is already automatically added.
|
||||
**/
|
||||
static AtomicActivityImplementation* PThread( const ExecutionHookFunc& executionFuncHook,
|
||||
const std::string& name = "",
|
||||
utils::PropertyList properties = {},
|
||||
resource::RequiredCapabilityList capabilities = {} ) noexcept;
|
||||
|
||||
/**
|
||||
* Returns a new OpenCL implementation object.
|
||||
*
|
||||
* Do not add OpenCL capability as it is already automatically added.
|
||||
**/
|
||||
static AtomicActivityImplementation* OpenCL( const ExecutionHookFunc& executionFuncHook,
|
||||
const std::string& name = "",
|
||||
std::initializer_list<wfr_size_t> minVersion = {0, 0},
|
||||
std::initializer_list<wfr_size_t> maxVersion = {0, 0},
|
||||
utils::PropertyList properties = {},
|
||||
resource::RequiredCapabilityList capabilities = {} ) noexcept;
|
||||
|
||||
/**
|
||||
* Returns a new CUDA implementation object.
|
||||
**/
|
||||
static AtomicActivityImplementation* CUDA( const ExecutionHookFunc& executionFuncHook,
|
||||
const std::string& name = "",
|
||||
std::initializer_list<wfr_size_t> minVersion = {0, 0},
|
||||
std::initializer_list<wfr_size_t> maxVersion = {0, 0},
|
||||
utils::PropertyList properties = {},
|
||||
resource::RequiredCapabilityList capabilities = {} ) noexcept;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/types/LwdTypes.h>
|
||||
#include <wfr/common/types/WfsTypes.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
// forward declarations
|
||||
class AtomicActivityImplementation;
|
||||
|
||||
/**
|
||||
* Represents an atomic activity type.
|
||||
**/
|
||||
class AtomicActivityType {
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
private:
|
||||
std::vector<wfs::AtomicActivityImplementation*> implementations;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const std::string name;
|
||||
|
||||
// Non-public functions.
|
||||
private:
|
||||
AtomicActivityType(const std::string& name, const std::initializer_list<AtomicActivityImplementation*>& implementations) noexcept
|
||||
: implementations(implementations), name(name) {}
|
||||
|
||||
// Public functions.
|
||||
public:
|
||||
~AtomicActivityType() noexcept;
|
||||
|
||||
/**
|
||||
* Returns the number of implementations.
|
||||
**/
|
||||
wfr_size_t getImplementationCount() const noexcept { return implementations.size(); }
|
||||
|
||||
/**
|
||||
* Returns a vector containing all implementations.
|
||||
**/
|
||||
const std::vector<AtomicActivityImplementation*>& getImplementations() const noexcept { return implementations; }
|
||||
|
||||
|
||||
/*
|
||||
* Static factory functions for creating atomic activity type objects.
|
||||
*
|
||||
* Returned objects may be referenced by more than one object and there is no single parent object,
|
||||
* therefore we are using shared pointers.
|
||||
*/
|
||||
public:
|
||||
/**
|
||||
* Returns a new atomic activity type object.
|
||||
**/
|
||||
static std::shared_ptr<AtomicActivityType> create(const std::string& name, const std::initializer_list<AtomicActivityImplementation*>& implementations) noexcept {
|
||||
return std::shared_ptr<AtomicActivityType>(new AtomicActivityType(name, implementations));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
Executable
+260
@@ -0,0 +1,260 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/types/WfsTypes.h>
|
||||
#include <wfr/common/types/LwdTypes.h>
|
||||
#include <wfr/common/exceptions/exceptions.h>
|
||||
#include <wfr/config.h>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
class WorkflowTemplate;
|
||||
|
||||
|
||||
class Workflow {
|
||||
friend class WorkflowTemplate;
|
||||
|
||||
// Static non-public properties
|
||||
private:
|
||||
/**
|
||||
* Static variable holding the next free workflow instanceID.
|
||||
**/
|
||||
static std::atomic<wfr_id_t> nextWorkflowID;
|
||||
|
||||
/**
|
||||
* Returns the next free workflow instanceID.
|
||||
*
|
||||
* @return next free workflow instanceID.
|
||||
*/
|
||||
static wfr_id_t getNextWorkflowID() { return nextWorkflowID.fetch_add(1); }
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
private:
|
||||
/**
|
||||
* The current status of this workflow instance.
|
||||
**/
|
||||
WorkflowStatus status;
|
||||
|
||||
/**
|
||||
* Flag to indicate that the workflow is about to be finished.
|
||||
*/
|
||||
bool finishFlag = false;
|
||||
|
||||
/**
|
||||
* Vector holding the activities of this workflow instance.
|
||||
**/
|
||||
std::vector<Activity*> activities;
|
||||
|
||||
/**
|
||||
* Reference to top-level activity.
|
||||
**/
|
||||
Activity* topLevelActivity = nullptr;
|
||||
|
||||
/**
|
||||
* Cause of error.
|
||||
**/
|
||||
std::exception_ptr errorCause;
|
||||
|
||||
wfr::wfr_timestamp_sc_t createTime;
|
||||
wfr::wfr_timestamp_sc_t startTime;
|
||||
wfr::wfr_timestamp_sc_t endTime;
|
||||
|
||||
#ifdef WFR_ENABLE_STATISTICS
|
||||
std::mutex statMutex;
|
||||
|
||||
wfr::wfr_duration_sc_t enactmentTime = wfr::wfr_duration_sc_t::zero();
|
||||
|
||||
std::atomic<wfr_size_t> createdCompositeInstanceCount = ATOMIC_VAR_INIT(0);
|
||||
std::atomic<wfr_size_t> finishedCompositeInstanceCount = ATOMIC_VAR_INIT(0);
|
||||
std::atomic<wfr_size_t> errorCompositeInstanceCount = ATOMIC_VAR_INIT(0);
|
||||
|
||||
std::atomic<wfr_size_t> createdAtomicInstanceCount = ATOMIC_VAR_INIT(0);
|
||||
std::atomic<wfr_size_t> finishedAtomicInstanceCount = ATOMIC_VAR_INIT(0);
|
||||
std::atomic<wfr_size_t> errorAtomicInstanceCount = ATOMIC_VAR_INIT(0);
|
||||
|
||||
wfr::wfr_duration_sc_t cumulativeAtomicReadyWaitingDuration = wfr::wfr_duration_sc_t::zero();
|
||||
wfr::wfr_duration_sc_t cumulativeAtomicRunningDuration = wfr::wfr_duration_sc_t::zero();
|
||||
|
||||
std::atomic<wfr_size_t> wepNodeCount = ATOMIC_VAR_INIT(0);
|
||||
std::atomic<wfr_size_t> wepVisitationCount = ATOMIC_VAR_INIT(0);
|
||||
std::atomic<wfr_size_t> wepUpdateCount = ATOMIC_VAR_INIT(0);
|
||||
std::atomic<wfr_size_t> wepUpdateNotifyCount = ATOMIC_VAR_INIT(0);
|
||||
|
||||
std::atomic<double> cummulativePredictionTime = ATOMIC_VAR_INIT(0.0);
|
||||
#endif
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
/**
|
||||
* The instanceID of this workflow instance object.
|
||||
**/
|
||||
const wfr_id_t workflowID;
|
||||
|
||||
/**
|
||||
* The parent workflow object of this workflow instance.
|
||||
**/
|
||||
WorkflowTemplate& baseTemplate;
|
||||
|
||||
|
||||
// Non-public functions
|
||||
private:
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param parent parent workflow object of this workflow instance.
|
||||
*/
|
||||
Workflow(WorkflowTemplate& baseTemplate);
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
/** Destructor. **/
|
||||
~Workflow() noexcept;
|
||||
|
||||
/**
|
||||
* Returns the status of this workflow instance.
|
||||
*
|
||||
* @return workflow instance status.
|
||||
*/
|
||||
WorkflowStatus getWorkflowStatus() const noexcept { return status; }
|
||||
|
||||
void setWorkflowStatus (WorkflowStatus status);
|
||||
|
||||
bool getFinishFlag() { return finishFlag; }
|
||||
|
||||
void setFinishFlag(bool val = true) { finishFlag = val; }
|
||||
|
||||
/**
|
||||
* Returns the number of contained workflow activities.
|
||||
*
|
||||
* @return number of contained workflow activities.
|
||||
**/
|
||||
wfr_size_t getActivityCount() const noexcept { return activities.size(); }
|
||||
|
||||
/**
|
||||
* Returns a reference to the static array holding the contained workflow activities.
|
||||
*
|
||||
* @return Reference to the array of contained workflow activities.
|
||||
*/
|
||||
const std::vector<Activity*> getActivities() const noexcept { return activities; }
|
||||
|
||||
/**
|
||||
* Returns the workflow activity with the given activityID.
|
||||
*
|
||||
* @param id activityID.
|
||||
* @return workflow activity with the given activityID.
|
||||
*/
|
||||
Activity* getActivityByID(wfr_id_t id) const noexcept;
|
||||
|
||||
/**
|
||||
* Returns the workflow activity with the given templateID.
|
||||
*
|
||||
* @param id templateID.
|
||||
* @return workflow activity with the given templateID.
|
||||
*/
|
||||
Activity* getActivityByTemplateID(wfr_id_t id) const noexcept;
|
||||
|
||||
/**
|
||||
* Returns a reference to the top-level activity.
|
||||
*
|
||||
* @return top-level activity.
|
||||
*/
|
||||
Activity* getTopLevelActivity() const noexcept {
|
||||
assert(topLevelActivity);
|
||||
return topLevelActivity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the execution of this workflow instance.
|
||||
*
|
||||
* The function blocks till the execution has finished.
|
||||
*
|
||||
* @param input reference to workflow input data.
|
||||
* @param output reference to workflow output data.
|
||||
* @return
|
||||
*/
|
||||
WorkflowStatus executeSync( lwd::_wfr_lwd* input, lwd::_wfr_lwd* output );
|
||||
|
||||
|
||||
std::exception_ptr getErrorCause() const noexcept { return errorCause; }
|
||||
void setErrorState(std::exception_ptr cause = std::exception_ptr());
|
||||
|
||||
|
||||
const wfr::wfr_timestamp_sc_t& getCreateTime() const noexcept { return createTime; }
|
||||
const wfr::wfr_timestamp_sc_t& getStartTime() const noexcept { return startTime; }
|
||||
const wfr::wfr_timestamp_sc_t& getEndTime() const noexcept { return endTime; }
|
||||
wfr::wfr_duration_sc_t getWorkflowDuration() const noexcept { return endTime - startTime; };
|
||||
wfr::wfr_duration_sc_t getMakespan() const noexcept { return endTime - createTime; };
|
||||
|
||||
#ifdef WFR_ENABLE_STATISTICS
|
||||
|
||||
wfr::wfr_duration_sc_t getEnactmentTime() const noexcept { return enactmentTime; }
|
||||
void addToEnactmentTime(wfr::wfr_duration_sc_t time) {
|
||||
std::lock_guard<std::mutex> lock(statMutex);
|
||||
enactmentTime += time;
|
||||
}
|
||||
|
||||
wfr_size_t getCreatedCompositeInstanceCount() { return createdCompositeInstanceCount; }
|
||||
void addToCreatedCompositeInstanceCount(wfr_size_t value = 1) { createdCompositeInstanceCount.fetch_add(value); }
|
||||
|
||||
wfr_size_t getFinishedCompositeInstanceCount() { return finishedCompositeInstanceCount; }
|
||||
void addToFinishedCompositeInstanceCount(wfr_size_t value = 1) { finishedCompositeInstanceCount.fetch_add(value); }
|
||||
|
||||
wfr_size_t getErrorCompositeInstanceCount() { return errorCompositeInstanceCount; }
|
||||
void addToErrorCompositeInstanceCount(wfr_size_t value = 1) { errorCompositeInstanceCount.fetch_add(value); }
|
||||
|
||||
|
||||
wfr_size_t getCreatedAtomicInstanceCount() { return createdAtomicInstanceCount; }
|
||||
void addToCreatedAtomicInstanceCount(wfr_size_t value = 1) { createdAtomicInstanceCount.fetch_add(value); }
|
||||
|
||||
wfr_size_t getFinishedAtomicInstanceCount() { return finishedAtomicInstanceCount; }
|
||||
void addToFinishedAtomicInstanceCount(wfr_size_t value = 1) { finishedAtomicInstanceCount.fetch_add(value); }
|
||||
|
||||
wfr_size_t getErrorAtomicInstanceCount() { return errorAtomicInstanceCount; }
|
||||
void addToErrorAtomicInstanceCount(wfr_size_t value = 1) { errorAtomicInstanceCount.fetch_add(value); }
|
||||
|
||||
wfr::wfr_duration_sc_t getCumulaticeAtomicRunningDuration() {
|
||||
std::lock_guard<std::mutex> lock(statMutex);
|
||||
return cumulativeAtomicRunningDuration;
|
||||
}
|
||||
void addToCumulaticeAtomicRunningDuration(wfr::wfr_duration_sc_t time) {
|
||||
std::lock_guard<std::mutex> lock(statMutex);
|
||||
cumulativeAtomicRunningDuration += time;
|
||||
}
|
||||
|
||||
wfr::wfr_duration_sc_t getCumulaticeAtomicReadyWaitingDuration() {
|
||||
std::lock_guard<std::mutex> lock(statMutex);
|
||||
return cumulativeAtomicReadyWaitingDuration;
|
||||
}
|
||||
void addToCumulaticeAtomicReadyWaitingDuration(wfr::wfr_duration_sc_t time) {
|
||||
std::lock_guard<std::mutex> lock(statMutex);
|
||||
cumulativeAtomicReadyWaitingDuration += time;
|
||||
}
|
||||
|
||||
wfr_size_t getWepNodeCount() { return wepNodeCount; }
|
||||
void setWepNodeCount(wfr_size_t count) { wepNodeCount = count; }
|
||||
|
||||
wfr_size_t getWepVisitationCount() { return wepVisitationCount; }
|
||||
void addToWepVisitationCount(wfr_size_t value = 1) { wepVisitationCount.fetch_add(value); }
|
||||
|
||||
wfr_size_t getWepUpdateCount() { return wepUpdateCount; }
|
||||
void addToWepUpdateCount(wfr_size_t value = 1) { wepUpdateCount.fetch_add(value); }
|
||||
|
||||
wfr_size_t getWepUpdateNotifyCount() { return wepUpdateNotifyCount; }
|
||||
void addToWepUpdateNotifyCount(wfr_size_t value = 1) { wepUpdateNotifyCount.fetch_add(value); }
|
||||
|
||||
void printStatistics(std::ostream& sout = std::cout);
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/types/LwdTypes.h>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class ActivityTemplate;
|
||||
class Workflow;
|
||||
|
||||
/**
|
||||
* Represents a workflow.
|
||||
*
|
||||
* Holds all invariant information that can be shared between different workflow instances (e.g. workflow name, structure).
|
||||
**/
|
||||
class WorkflowTemplate {
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
private:
|
||||
std::vector<ActivityTemplate*> activities;
|
||||
ActivityTemplate* toplevelActivity = nullptr;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const std::string workflowName;
|
||||
const wfr_id_t topLevelActivityID;
|
||||
|
||||
// Non-public functions.
|
||||
private:
|
||||
void checkStructure();
|
||||
|
||||
// Public functions.
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param activities workflow activity templates.
|
||||
* @param topLevelActivityID ID of top-level workflow activity template.
|
||||
* @param name name of the workflow.
|
||||
**/
|
||||
WorkflowTemplate( const std::string& name,
|
||||
wfr_id_t topLevelActivityID,
|
||||
std::initializer_list<ActivityTemplate*> activities );
|
||||
|
||||
~WorkflowTemplate() noexcept;
|
||||
|
||||
/**
|
||||
* Returns the number of workflow activities.
|
||||
*
|
||||
* @return number of workflow activities
|
||||
**/
|
||||
wfr_size_t getActivityCount() const noexcept { return activities.size(); }
|
||||
|
||||
/**
|
||||
* Returns a pointer to the array of workflow activities.
|
||||
*
|
||||
* @return pointer to the array of workflow activities
|
||||
**/
|
||||
const std::vector<ActivityTemplate*>& getActivities() const noexcept { return activities; }
|
||||
|
||||
/**
|
||||
* Returns the activity template with the specified ID.
|
||||
*
|
||||
* @param id ID of workflow activity template.
|
||||
* @return workflow activity template.
|
||||
**/
|
||||
ActivityTemplate* getActivityByID(wfr_id_t id) const noexcept;
|
||||
|
||||
/**
|
||||
* Returns the ID of the top-level workflow activity template.
|
||||
*
|
||||
* @return ID of the top-level workflow activity template.
|
||||
**/
|
||||
wfr_id_t getTopLevelActivityID() const noexcept { return topLevelActivityID; }
|
||||
|
||||
/**
|
||||
* Returns the top-level workflow activity template.
|
||||
*
|
||||
* @return top-level workflow activity template.
|
||||
**/
|
||||
ActivityTemplate* getTopLevelActivity() const noexcept { return toplevelActivity; }
|
||||
|
||||
|
||||
/**
|
||||
* Executes the workflow.
|
||||
*
|
||||
* Blocks till execution has finished.
|
||||
*
|
||||
* @param input workflow input data.
|
||||
* @param input workflow output data.
|
||||
* @return status.
|
||||
**/
|
||||
std::shared_ptr<Workflow> execute(lwd::_wfr_lwd* input, lwd::_wfr_lwd* output);
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/AtomicActivityImplementation.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class CUDAActivityImplementation : public AtomicActivityImplementation {
|
||||
public:
|
||||
const ExecutionHookFunc executionFuncHook;
|
||||
public:
|
||||
CUDAActivityImplementation( const ExecutionHookFunc& executionFuncHook,
|
||||
const std::vector<resource::RequiredResourceCapability>& capabilities,
|
||||
const utils::Properties& properties,
|
||||
const std::string& name = "") noexcept
|
||||
: AtomicActivityImplementation(ActivityImplementationType::CUDA, capabilities, properties, name),
|
||||
executionFuncHook(executionFuncHook) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/AtomicActivityImplementation.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class OpenCLActivityImplementation : public AtomicActivityImplementation {
|
||||
public:
|
||||
const ExecutionHookFunc executionFuncHook;
|
||||
public:
|
||||
OpenCLActivityImplementation( const ExecutionHookFunc& executionFuncHook,
|
||||
const std::vector<resource::RequiredResourceCapability>& capabilities,
|
||||
const utils::Properties& properties,
|
||||
const std::string& name = "") noexcept
|
||||
: AtomicActivityImplementation(ActivityImplementationType::OpenCL, capabilities, properties, name),
|
||||
executionFuncHook(executionFuncHook) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/AtomicActivityImplementation.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class PThreadActivityImplementation : public AtomicActivityImplementation {
|
||||
public:
|
||||
const ExecutionHookFunc executionFuncHook;
|
||||
public:
|
||||
PThreadActivityImplementation( const ExecutionHookFunc& executionFuncHook,
|
||||
const std::vector<resource::RequiredResourceCapability>& capabilities,
|
||||
const utils::Properties& properties,
|
||||
const std::string& name ) noexcept
|
||||
: AtomicActivityImplementation(ActivityImplementationType::PThread, capabilities, properties, name),
|
||||
executionFuncHook(executionFuncHook) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/ActivityInstance.h>
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
class AtomicActivityImplementation;
|
||||
|
||||
|
||||
class AssignActivityInstance: public wfr::wfs::ActivityInstance {
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
AssignActivityInstance(Activity& baseActivity, wfr_id_t iterationID = 0) noexcept
|
||||
: ActivityInstance(baseActivity, iterationID) {}
|
||||
|
||||
virtual bool executePreExecutionHooks(bool earlyEvaluation) override;
|
||||
|
||||
virtual bool executeExecutionHook(bool earlyEvaluation) override;
|
||||
|
||||
virtual void notifyParent() noexcept;
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,33 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/ActivityInstance.h>
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
class AtomicActivityImplementation;
|
||||
|
||||
|
||||
class AtomicActivityInstance: public wfr::wfs::ActivityInstance {
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
protected:
|
||||
bool _ownedByExecutionLayer = false;
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
AtomicActivityInstance(Activity& baseActivity, wfr_id_t iterationID = 0) noexcept
|
||||
: ActivityInstance(baseActivity, iterationID) {}
|
||||
|
||||
virtual bool executePreExecutionHooks(bool earlyEvaluation) override;
|
||||
|
||||
bool ownedByExecutionLayer() const noexcept { return _ownedByExecutionLayer; }
|
||||
|
||||
void setOwnedByExecutionLayer(bool owned) noexcept { _ownedByExecutionLayer = owned; }
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/ActivityInstance.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace wfr {
|
||||
|
||||
// Forward declaration
|
||||
namespace enactment {
|
||||
class WepBuilder;
|
||||
}
|
||||
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
|
||||
|
||||
class CompositeActivityInstance: public wfr::wfs::ActivityInstance {
|
||||
friend class enactment::WepBuilder;
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
protected:
|
||||
std::vector<ActivityInstance*> children;
|
||||
std::map<wfr_size_t, ActivityInstance*> childrenByInstanceID;
|
||||
std::map<wfr_size_t, std::vector<ActivityInstance*>> childrenByActivityID;
|
||||
wfr_size_t finishedChildrenCount = 0;
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
CompositeActivityInstance(Activity& baseActivity, wfr_id_t iterationID = 0) noexcept
|
||||
: ActivityInstance(baseActivity, iterationID) {}
|
||||
|
||||
wfr_size_t getChildrenCount() const noexcept { return children.size(); }
|
||||
const std::vector<ActivityInstance*>& getChildren() const noexcept { return children; }
|
||||
ActivityInstance* getChild(wfr_id_t instanceID) const noexcept;
|
||||
ActivityInstance* getChild(wfr_id_t activityID, wfr_id_t iterationID) const noexcept;
|
||||
|
||||
|
||||
wfr_size_t getFinishedChildrenCount() const noexcept { return finishedChildrenCount; }
|
||||
|
||||
virtual void notifyChildHasFinished(ActivityInstance& ai) noexcept;
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/instances/CompositeActivityInstance.h>
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
|
||||
|
||||
class ConditionalActivityInstance: public CompositeActivityInstance {
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
private:
|
||||
wfr_size_t activeExecutionBranchID = 0;
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
ConditionalActivityInstance(Activity& baseActivity, wfr_id_t iterationID = 0) noexcept
|
||||
: CompositeActivityInstance(baseActivity, iterationID) {}
|
||||
|
||||
wfr_id_t getExecutionBranchID() const noexcept { return activeExecutionBranchID; }
|
||||
|
||||
void setExecutionBranchID(wfr_size_t branchId) noexcept { this->activeExecutionBranchID = branchId; }
|
||||
|
||||
virtual bool executePreExecutionHooks(bool earlyEvaluation) override;
|
||||
|
||||
virtual bool executePostExecutionHooks(bool earlyEvaluation) override;
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/instances/CompositeActivityInstance.h>
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
|
||||
|
||||
class ContainerActivityInstance: public CompositeActivityInstance {
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
ContainerActivityInstance(Activity& baseActivity, wfr_id_t iterationID = 0) noexcept
|
||||
: CompositeActivityInstance(baseActivity, iterationID) {}
|
||||
|
||||
virtual bool executePreExecutionHooks(bool earlyEvaluation) override;
|
||||
|
||||
virtual bool executePostExecutionHooks(bool earlyEvalation) override;
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,50 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/instances/LoopActivityInstance.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
|
||||
|
||||
class ForLoopActivityInstance: public LoopActivityInstance {
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
private:
|
||||
wfr_size_t loopCounterStart = 0;
|
||||
wfr_size_t loopCounterStep = 1;
|
||||
wfr_size_t loopCounterMax = 0;
|
||||
bool loopCounterValueSet = false;
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
ForLoopActivityInstance(Activity& baseActivity, bool isParallel, wfr_id_t iterationID = 0) noexcept
|
||||
: LoopActivityInstance(baseActivity, isParallel, iterationID) {}
|
||||
|
||||
|
||||
void setLoopCounter(wfr_size_t start, wfr_size_t step, wfr_size_t max);
|
||||
|
||||
wfr_size_t getLoopCounterStart() const noexcept { return loopCounterStart; }
|
||||
|
||||
wfr_size_t getLoopCounterStep() const noexcept { return loopCounterStep; }
|
||||
|
||||
wfr_size_t getLoopCounterMax() const noexcept { return loopCounterMax; }
|
||||
|
||||
bool isLoopCounterValueAvailable() const noexcept { return loopCounterValueSet; }
|
||||
|
||||
wfr_size_t getLoopCounterValue(wfr_id_t iterationID) const noexcept { return loopCounterStart + (iterationID * loopCounterStep); }
|
||||
|
||||
|
||||
virtual void notifyChildHasFinished(ActivityInstance& ai) noexcept;
|
||||
|
||||
virtual bool executePreExecutionHooks(bool earlyEvaluation) override;
|
||||
|
||||
virtual bool executePostExecutionHooks(bool earlyEvaluation) override;
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/instances/CompositeActivityInstance.h>
|
||||
#include <vector>
|
||||
|
||||
namespace wfr {
|
||||
|
||||
// Forward declarations
|
||||
namespace enactment {
|
||||
class WepBuilder;
|
||||
}
|
||||
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
|
||||
|
||||
class LoopActivityInstance: public CompositeActivityInstance {
|
||||
friend class enactment::WepBuilder;
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
protected:
|
||||
wfr_size_t iterationCount = 0;
|
||||
wfr_size_t handledIterationCount = 0;
|
||||
bool finalisedFlag = false;
|
||||
std::vector<wfr_size_t> finishedChildrenPerIteration;
|
||||
std::vector<bool> finishedIterations;
|
||||
std::vector<bool> runningIterations;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const bool isParallel;
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
LoopActivityInstance(Activity& baseActivity, bool isParallel, wfr_id_t iterationID = 0) noexcept
|
||||
: CompositeActivityInstance(baseActivity, iterationID), isParallel(isParallel) {}
|
||||
|
||||
wfr_size_t getIterationCount() const noexcept { return iterationCount; }
|
||||
|
||||
void setIterationCount(wfr_size_t count) noexcept;
|
||||
|
||||
void setHandledIterationCount(wfr_size_t handledIterationCount) noexcept { this->handledIterationCount = handledIterationCount; }
|
||||
|
||||
wfr_size_t getHandledIterationCount() const noexcept { return handledIterationCount; }
|
||||
|
||||
bool isFinalised() const noexcept { return finalisedFlag; }
|
||||
|
||||
void setFinalised(bool v) noexcept { finalisedFlag = v; }
|
||||
|
||||
bool hasIterationFinished(wfr_id_t iterationID) const noexcept {
|
||||
if (iterationID < finishedIterations.size())
|
||||
return finishedIterations[iterationID];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isIterationRunning(wfr_id_t iterationID)const noexcept {
|
||||
if (iterationID < runningIterations.size())
|
||||
return runningIterations[iterationID];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
ActivityInstanceStatus getIterationInstanceStatus(wfr_id_t iterationID) const noexcept;
|
||||
|
||||
|
||||
virtual void notifyChildHasFinished(ActivityInstance& ai) noexcept override;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/instances/LoopActivityInstance.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
// Forward declarations
|
||||
class Activity;
|
||||
|
||||
|
||||
class WhileLoopActivityInstance : public LoopActivityInstance {
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
WhileLoopActivityInstance(Activity& baseActivity, wfr_id_t iterationID = 0) noexcept
|
||||
: LoopActivityInstance(baseActivity, false, iterationID) {}
|
||||
|
||||
virtual bool executePreExecutionHooks(bool earlyEvaluation) override;
|
||||
|
||||
virtual bool executePostExecutionHooks(bool earlyEvaluation) override;
|
||||
|
||||
virtual void notifyChildHasFinished(ActivityInstance& ai) noexcept;
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/ActivityTemplate.h>
|
||||
#include <wfr/common/wfs/AtomicActivityType.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class AssignActivityTemplate : public ActivityTemplate {
|
||||
friend class ActivityTemplate;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const InputHookFunc inputFuncHook;
|
||||
const ExecutionHookFunc execFuncHook;
|
||||
|
||||
// Non-public functions.
|
||||
private:
|
||||
AssignActivityTemplate( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
InputHookFunc inputFuncHook,
|
||||
ExecutionHookFunc execFuncHook ) noexcept
|
||||
: ActivityTemplate(id, ActivityType::Assign, name, parentID, branchID, succList, predList, false, false, false),
|
||||
inputFuncHook(inputFuncHook), execFuncHook(execFuncHook) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/ActivityTemplate.h>
|
||||
#include <wfr/common/wfs/AtomicActivityType.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class AtomicActivityTemplate : public ActivityTemplate {
|
||||
friend class ActivityTemplate;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const InputHookFunc inputFuncHook;
|
||||
const std::shared_ptr<AtomicActivityType> atomicActivityType;
|
||||
|
||||
// Non-public functions.
|
||||
private:
|
||||
AtomicActivityTemplate( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
InputHookFunc inputFuncHook,
|
||||
std::shared_ptr<AtomicActivityType> atomicActivityType ) noexcept
|
||||
: ActivityTemplate(id, ActivityType::Atomic, name, parentID, branchID, succList, predList, false, false, false),
|
||||
inputFuncHook(inputFuncHook), atomicActivityType(atomicActivityType) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/ActivityTemplate.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class ConditionalActivityTemplate : public ActivityTemplate {
|
||||
friend class ActivityTemplate;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const InputHookFunc inputFuncHook;
|
||||
const OutputHookFunc outputFuncHook;
|
||||
const BranchConditionHookFunc branchFuncHook;
|
||||
|
||||
// Non-public functions.
|
||||
private:
|
||||
ConditionalActivityTemplate( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
InputHookFunc inputFuncHook,
|
||||
OutputHookFunc outputFuncHook,
|
||||
BranchConditionHookFunc branchFuncHook ) noexcept
|
||||
: ActivityTemplate(id, ActivityType::Conditional, name, parentID, branchID, succList, predList, true, false, true),
|
||||
inputFuncHook(inputFuncHook), outputFuncHook(outputFuncHook), branchFuncHook(branchFuncHook) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/ActivityTemplate.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class ContainerActivityTemplate : public ActivityTemplate {
|
||||
friend class ActivityTemplate;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const InputHookFunc inputFuncHook;
|
||||
const OutputHookFunc outputFuncHook;
|
||||
|
||||
// Non-public functions.
|
||||
private:
|
||||
ContainerActivityTemplate( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
InputHookFunc inputFuncHook,
|
||||
OutputHookFunc outputFuncHook ) noexcept
|
||||
: ActivityTemplate(id, ActivityType::Container, name, parentID, branchID, succList, predList, true, false, false),
|
||||
inputFuncHook(inputFuncHook), outputFuncHook(outputFuncHook) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/ActivityTemplate.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class ForLoopActivityTemplate : public ActivityTemplate {
|
||||
friend class ActivityTemplate;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const InputHookFunc inputFuncHook;
|
||||
const OutputHookFunc outputFuncHook;
|
||||
const ForCounterHookFunc counterFuncHook;
|
||||
const LoopIterationHookFunc iterationFuncHook;
|
||||
const bool isParallel;
|
||||
|
||||
// Non-public functions.
|
||||
private:
|
||||
ForLoopActivityTemplate( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
InputHookFunc inputFuncHook,
|
||||
OutputHookFunc outputFuncHook,
|
||||
ForCounterHookFunc counterFuncHook,
|
||||
LoopIterationHookFunc iterationFuncHook,
|
||||
bool isParallel ) noexcept
|
||||
: ActivityTemplate(id, ActivityType::ForLoop, name, parentID, branchID, succList, predList, true, true, false),
|
||||
inputFuncHook(inputFuncHook), outputFuncHook(outputFuncHook), counterFuncHook(counterFuncHook),
|
||||
iterationFuncHook(iterationFuncHook), isParallel(isParallel) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/wfs/ActivityTemplate.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
|
||||
|
||||
class WhileLoopActivityTemplate : public ActivityTemplate {
|
||||
friend class ActivityTemplate;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const InputHookFunc inputFuncHook;
|
||||
const OutputHookFunc outputFuncHook;
|
||||
const WhileConditionHookFunc conditionFuncHook;
|
||||
const LoopIterationHookFunc iterationFuncHook;
|
||||
|
||||
// Non-public functions.
|
||||
private:
|
||||
WhileLoopActivityTemplate( wfr_id_t id,
|
||||
const std::string& name,
|
||||
wfr_id_t parentID,
|
||||
wfr_id_t branchID,
|
||||
const std::initializer_list<wfr_id_t>& succList,
|
||||
const std::initializer_list<wfr_id_t>& predList,
|
||||
InputHookFunc inputFuncHook,
|
||||
OutputHookFunc outputFuncHook,
|
||||
WhileConditionHookFunc conditionFuncHook,
|
||||
LoopIterationHookFunc iterationFuncHook ) noexcept
|
||||
: ActivityTemplate(id, ActivityType::WhileLoop, name, parentID, branchID, succList, predList, true, true, false),
|
||||
inputFuncHook(inputFuncHook), outputFuncHook(outputFuncHook), conditionFuncHook(conditionFuncHook),
|
||||
iterationFuncHook(iterationFuncHook) {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace wfs */
|
||||
} /* namespace wfr */
|
||||
Reference in New Issue
Block a user