Symmetri
Loading...
Searching...
No Matches
symmetri.h
Go to the documentation of this file.
1#pragma once
2
5#include <set>
6
7#include "symmetri/callback.h"
8#include "symmetri/tasks.h"
9#include "symmetri/types.h"
10
11namespace symmetri {
12
19struct Petri;
20
27class PetriNet final {
28 public:
40 PetriNet(const std::set<std::string> &petri_net_xmls,
41 const std::string &case_id, std::shared_ptr<TaskSystem> threadpool,
42 const Marking &goal_marking = {},
43 const PriorityTable &priorities = {});
44
55 PetriNet(const Net &net, const std::string &case_id,
56 std::shared_ptr<TaskSystem> threadpool,
57 const Marking &initial_marking, const Marking &goal_marking = {},
58 const PriorityTable &priorities = {});
59
69 std::function<void()> getInputTransitionHandle(
70 const std::string &transition) const noexcept;
71
79 void registerCallback(const std::string &transition,
80 const Callback &callback) const noexcept;
81
88 Marking getMarking() const noexcept;
89
99 bool reuseApplication(const std::string &case_id);
100
101 friend Token(symmetri::fire)(const PetriNet &);
102 friend void(symmetri::cancel)(const PetriNet &);
103 friend void(symmetri::pause)(const PetriNet &);
104 friend void(symmetri::resume)(const PetriNet &);
105 friend Eventlog(symmetri::getLog)(const PetriNet &);
106
107 private:
108 const std::shared_ptr<Petri> impl;
110};
111
112} // namespace symmetri
Token fire(const T &callback)
Generates a Token based on what kind of information the Callback returns.
Definition callback.h:64
Eventlog getLog(const T &)
Get the Log object. By default it returns an empty vector.
Definition callback.h:82
void resume(const T &)
Templates a resume action for a Callback. By default it does nothing and not resume the Callback.
Definition callback.h:52
void cancel(const T &)
The default cancel implementation is naive. It only returns a user-exit state and does nothing to the...
Definition callback.h:34
void pause(const T &)
Implements a pause action for a Callback. By default it does nothing and not pause the Callback.
Definition callback.h:43
Callback is a wrapper around any type that you to tie to a transition. Typically this is an invokable...
Definition callback.h:98
PetriNet exposes the possible constructors to create PetriNets. It also allows the user to register a...
Definition symmetri.h:27
Marking getMarking() const noexcept
Get the Marking object. This function is thread-safe and be called during PetriNet execution.
Definition symmetri.cpp:64
void registerCallback(const std::string &transition, const Callback &callback) const noexcept
The default transition payload (DirectMutation) is overload by the Callback supplied for a specific t...
Definition symmetri.cpp:57
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....
Definition symmetri.cpp:37
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 h...
Definition symmetri.cpp:11
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 ...
Definition symmetri.cpp:76
Tokens are elements that can reside in places. Tokens can have a color which makes them distinguishab...
Definition colors.hpp:104
std::vector< std::pair< Transition, int8_t > > PriorityTable
Definition types.h:51
std::vector< Event > Eventlog
Definition types.h:32
std::vector< std::pair< Place, Token > > Marking
Definition types.h:46
std::unordered_map< Transition, std::pair< std::vector< std::pair< Place, Token > >, std::vector< std::pair< Place, Token > > > > Net
Definition types.h:35