Symmetri
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <stdint.h>
6
7#include <chrono>
8#include <string>
9#include <unordered_map>
10#include <utility>
11#include <vector>
12
13#include "symmetri/colors.hpp"
14
15namespace symmetri {
16using Place = std::string;
18using Transition = std::string;
20using Clock =
21 std::chrono::steady_clock;
23
29struct Event {
30 std::string case_id;
31 std::string transition;
33 Clock::time_point stamp;
34};
35
36using Eventlog = std::vector<Event>;
38
39using Net = std::unordered_map<
41 std::pair<std::vector<std::pair<Place, Token>>,
42 std::vector<std::pair<Place, Token>>>>;
49
50using Marking =
51 std::vector<std::pair<Place, Token>>;
54
56 std::vector<std::pair<Transition, int8_t>>;
58
66class PetriNet;
67
73bool isSynchronous(const DirectMutation &);
74
81
89Token fire(const PetriNet &);
90
99void cancel(const PetriNet &);
100
107void pause(const PetriNet &);
108
115void resume(const PetriNet &);
116
122Eventlog getLog(const PetriNet &);
123
124} // namespace symmetri
Token fire(const T &callback)
Generates a Token based on what kind of information the Callback returns.
Definition callback.h:65
Eventlog getLog(const T &)
Get the Log object. By default it returns an empty vector.
Definition callback.h:83
bool isSynchronous(const T &)
Checks if the callback is synchronous. Synchronous callbacks are immediately executed inside the Petr...
Definition callback.h:22
void resume(const T &)
Templates a resume action for a Callback. By default it does nothing and not resume the Callback.
Definition callback.h:53
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:35
void pause(const T &)
Implements a pause action for a Callback. By default it does nothing and not pause the Callback.
Definition callback.h:44
PetriNet exposes the possible constructors to create PetriNets. It also allows the user to register a...
Definition symmetri.h:33
Tokens are elements that can reside in places. Tokens can have a color which makes them distinguishab...
Definition colors.hpp:74
A DirectMutation is a synchronous no-operation function. It simply mutates the mutation on the petri ...
Definition types.h:65
This struct defines a subset of data that we associate with the result of firing a transition.
Definition types.h:29
Token state
The result of the event.
Definition types.h:32
std::string transition
The transition that generated the event.
Definition types.h:31
Clock::time_point stamp
The timestamp of the event.
Definition types.h:33
std::string case_id
The case_id of this event.
Definition types.h:30
std::vector< Event > Eventlog
Definition types.h:36
std::vector< std::pair< Place, Token > > Marking
Definition types.h:50
std::vector< std::pair< Transition, int8_t > > PriorityTable
Definition types.h:55
std::unordered_map< Transition, std::pair< std::vector< std::pair< Place, Token > >, std::vector< std::pair< Place, Token > > > > Net
Definition types.h:39
std::string Place
Definition types.h:16
std::chrono::steady_clock Clock
Definition types.h:20
std::string Transition
Definition types.h:18