#pragma once #include #include #include #include #include #include #include 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 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 predecessors; std::vector successors; std::shared_ptr 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& getPredecessors() const noexcept { return predecessors; } std::vector& getPredecessors() noexcept { return predecessors; } const std::vector& getSuccessors() const noexcept { return successors; } std::vector& getSuccessors() noexcept { return successors; } std::shared_ptr getUserData() const noexcept { return userData; } void setUserData(std::shared_ptr data) noexcept { userData = data; } uint64_t getVisitationCount() const noexcept { return visitationCount; } virtual void addToVisitationCount(uint64_t val = 1) noexcept { visitationCount += val; } template T& as() noexcept { return *static_cast(this); } template const T& as() const noexcept { return *static_cast(this); } }; } /* namespace wep */ } /* namespace wfr */