210 lines
4.9 KiB
C++
Executable File
210 lines
4.9 KiB
C++
Executable File
|
|
#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 */
|
|
|