80 lines
2.1 KiB
C++
Executable File
80 lines
2.1 KiB
C++
Executable File
|
|
#pragma once
|
|
|
|
#include <wfr/common/types/WepTypes.h>
|
|
#include <wfr/common/types/WfrTypes.h>
|
|
#include <wfr/common/types/WfsTypes.h>
|
|
#include <vector>
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <stdint.h>
|
|
|
|
|
|
namespace wfr {
|
|
|
|
// Forward declarations
|
|
namespace enactment {
|
|
class WepBuilder;
|
|
}
|
|
|
|
namespace wep {
|
|
|
|
|
|
class AbstractWepNode {
|
|
friend class enactment::WepBuilder;
|
|
|
|
// Static non-public properties
|
|
protected:
|
|
/**
|
|
* Static variable holding the next free wepID.
|
|
**/
|
|
static std::atomic<wfr_id_t> nextWepNodeID;
|
|
|
|
/**
|
|
* Returns the next free wepID.
|
|
*
|
|
* @return next free wepID.
|
|
*/
|
|
static wfr_id_t getNextWepNodeID() noexcept { return nextWepNodeID.fetch_add(1); }
|
|
|
|
// Mutable properties that need to be accessed via getter-/setter-functions.
|
|
protected:
|
|
std::vector<AbstractWepNode*> predecessors;
|
|
std::vector<AbstractWepNode*> successors;
|
|
std::shared_ptr<void> userData;
|
|
uint64_t visitationCount = 0;
|
|
|
|
// Invariant properties that can be accessed directly.
|
|
public:
|
|
const wfr_id_t nodeID;
|
|
const WepNodeType nodeType;
|
|
const bool withActivityInstance;
|
|
|
|
// Public functions
|
|
public:
|
|
AbstractWepNode(WepNodeType nodeType, bool withInstance) noexcept
|
|
: nodeID(getNextWepNodeID()), nodeType(nodeType), withActivityInstance(withInstance) {}
|
|
virtual ~AbstractWepNode() noexcept {}
|
|
|
|
const std::vector<AbstractWepNode*>& getPredecessors() const noexcept { return predecessors; }
|
|
std::vector<AbstractWepNode*>& getPredecessors() noexcept { return predecessors; }
|
|
const std::vector<AbstractWepNode*>& getSuccessors() const noexcept { return successors; }
|
|
std::vector<AbstractWepNode*>& getSuccessors() noexcept { return successors; }
|
|
|
|
std::shared_ptr<void> getUserData() const noexcept { return userData; }
|
|
void setUserData(std::shared_ptr<void> data) noexcept { userData = data; }
|
|
|
|
uint64_t getVisitationCount() const noexcept { return visitationCount; }
|
|
virtual void addToVisitationCount(uint64_t val = 1) noexcept { visitationCount += val; }
|
|
|
|
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 wep */
|
|
} /* namespace wfr */
|
|
|