Symmetri
Loading...
Searching...
No Matches
symmetri::PetriNet Class Referencefinal

PetriNet exposes the possible constructors to create PetriNets. It also allows the user to register a Callback to a transition, or to get a handle for input-transitions. More...

#include <symmetri.h>

Public Member Functions

 PetriNet (const std::set< std::string > &petri_net_xmls, const std::string &case_id, std::shared_ptr< TaskSystem > threadpool, const Marking &goal_marking={}, const PriorityTable &priorities={})
 Construct a new PetriNet object from a set of paths to PNML- or GRML-files. Since PNML-files do not have priorities; you can optionally add a priority table manually.
 PetriNet (const Net &net, const std::string &case_id, std::shared_ptr< TaskSystem > threadpool, const Marking &initial_marking, const Marking &goal_marking={}, const PriorityTable &priorities={})
 Construct a new PetriNet object from a net and initial marking.
std::function< void()> getInputTransitionHandle (const std::string &transition) const noexcept
 By registering a input transition you get a handle to manually force a transition to fire. It returns a callable handle that will schedule a reducer for the transition, generating tokens. This only works for transitions that have no input places.
void registerCallback (const std::string &transition, Callback &&callback) const noexcept
 The default transition payload (DirectMutation) is overloaded by the Callback supplied for a specific transition.
bool tryRegisterCallback (const std::string &transition, Callback &&callback) const noexcept
 Same as registerCallback, but reports whether the Callback was actually registered.
std::vector< Transition > getUnregisteredTransitions () const noexcept
 Get the transitions that still have the default payload (DirectMutation), i.e. transitions for which no Callback has been registered. An empty result means all transitions are registered.
template<typename T, typename... Args>
void registerCallbackInPlace (const std::string &transition, Args &&...args) const noexcept
 Construct a Callback of type T in place. This is required for type that are not moveable;.
Marking getMarking () const noexcept
 Get the Marking object. This function is thread-safe and be called during PetriNet execution.
std::vector< Transition > getActiveTransitions () const noexcept
 Get the list of active transitions. This function is thread-safe and be called during PetriNet execution.
bool reuseApplication (const std::string &case_id)
 reuseApplication resets the PetriNet such that the same net can be used again after a cancel call or natural termination of the PetriNet. You do need to supply a new case_id which must be different.

Friends

Token symmetri::fire (const PetriNet &)
void symmetri::cancel (const PetriNet &)
void symmetri::pause (const PetriNet &)
void symmetri::resume (const PetriNet &)
Eventlog symmetri::getLog (const PetriNet &)

Detailed Description

PetriNet exposes the possible constructors to create PetriNets. It also allows the user to register a Callback to a transition, or to get a handle for input-transitions.

Constructor & Destructor Documentation

◆ PetriNet() [1/2]

symmetri::PetriNet::PetriNet ( const std::set< std::string > & petri_net_xmls,
const std::string & case_id,
std::shared_ptr< TaskSystem > threadpool,
const Marking & goal_marking = {},
const PriorityTable & priorities = {} )

Construct a new PetriNet object from a set of paths to PNML- or GRML-files. Since PNML-files do not have priorities; you can optionally add a priority table manually.

Parameters
petri_net_xmls
case_id
threadpool
goal_marking
priorities

◆ PetriNet() [2/2]

symmetri::PetriNet::PetriNet ( const Net & net,
const std::string & case_id,
std::shared_ptr< TaskSystem > threadpool,
const Marking & initial_marking,
const Marking & goal_marking = {},
const PriorityTable & priorities = {} )

Construct a new PetriNet object from a net and initial marking.

Parameters
net
case_id
threadpool
initial_marking
goal_marking
priorities

Member Function Documentation

◆ getInputTransitionHandle()

std::function< void()> symmetri::PetriNet::getInputTransitionHandle ( const std::string & transition) const
noexcept

By registering a input transition you get a handle to manually force a transition to fire. It returns a callable handle that will schedule a reducer for the transition, generating tokens. This only works for transitions that have no input places.

Parameters
transitionthe name of transition
Returns
std::function<void()>

◆ getMarking()

Marking symmetri::PetriNet::getMarking ( ) const
noexcept

Get the Marking object. This function is thread-safe and be called during PetriNet execution.

Returns
std::vector<Place>

◆ getUnregisteredTransitions()

std::vector< Transition > symmetri::PetriNet::getUnregisteredTransitions ( ) const
noexcept

Get the transitions that still have the default payload (DirectMutation), i.e. transitions for which no Callback has been registered. An empty result means all transitions are registered.

Returns
std::vector<Transition>

◆ registerCallback()

void symmetri::PetriNet::registerCallback ( const std::string & transition,
Callback && callback ) const
noexcept

The default transition payload (DirectMutation) is overloaded by the Callback supplied for a specific transition.

Parameters
transitionthe name of transition
callbackthe callback

◆ registerCallbackInPlace()

template<typename T, typename... Args>
void symmetri::PetriNet::registerCallbackInPlace ( const std::string & transition,
Args &&... args ) const
inlinenoexcept

Construct a Callback of type T in place. This is required for type that are not moveable;.

Template Parameters
Ttype of the Callback
Argstypes of the constructor-arguments
Parameters
transitionthe name of the transitions
argsarguments for constructor of T

◆ reuseApplication()

bool symmetri::PetriNet::reuseApplication ( const std::string & case_id)

reuseApplication resets the PetriNet such that the same net can be used again after a cancel call or natural termination of the PetriNet. You do need to supply a new case_id which must be different.

Parameters
case_idneeds to be a new unique id
Returns
true
false

◆ tryRegisterCallback()

bool symmetri::PetriNet::tryRegisterCallback ( const std::string & transition,
Callback && callback ) const
noexcept

Same as registerCallback, but reports whether the Callback was actually registered.

Parameters
transitionthe name of transition
callbackthe callback
Returns
true the Callback is registered to the transition.
false the net does not contain the transition, or the PetriNet is currently running.

The documentation for this class was generated from the following files:
  • symmetri/include/symmetri/symmetri.h
  • symmetri/symmetri.cpp