FDR  4.2.7(6ecbe5a21b71ab020e8fcaeccfe5ebaad0599f4f)
session.h
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 #include <string>
6 #include <vector>
7 
8 #include <fdr/evaluator/evaluator_result.h>
9 #include <fdr/evaluator/event.h>
10 #include <fdr/evaluator/process_name.h>
11 #include <fdr/error.h>
12 #include <fdr/lts/events.h>
13 #include <fdr/lts/machine.h>
14 #include <fdr/lts/semantic_model.h>
15 
16 namespace FDR
17 {
18 namespace Assertions
19 {
20 class Assertion;
21 class DeadlockFreeAssertion;
22 class DeterministicAssertion;
23 class DivergenceFreeAssertion;
24 class HasTraceAssertion;
25 class RefinementAssertion;
26 
27 } // end Assertions
28 
30 class FileLoadError : public Error
31 {
32 public:
33  FileLoadError(const std::string& file_name, const std::string& error);
34 
36  std::string file_name() const;
37 
38 private:
39  const std::string file_name_;
40 };
41 
43 class InputFileError : public Error
44 {
45 public:
46  InputFileError(const std::string& error);
47 };
48 
51 {
52 public:
54 
55  PrintStatement(const std::string& location, const std::string& expression);
56 
57  PrintStatement(const PrintStatement&) = default;
58  PrintStatement& operator=(const PrintStatement&) = default;
59 
62  const std::string& expression() const;
63 
66  const std::string& source_location() const;
67 
68 private:
69  std::string expression_;
70  std::string source_location_;
71 };
72 
78 class Session
79 {
80 public:
87  ~Session();
88 
89  Session(const Session&) = delete;
90  Session& operator=(const Session&) = delete;
91 
102  std::vector<std::string> load_file(const std::string& file_path);
103 
114  std::vector<std::string> load_strings_as_file(const std::string& root_file_path,
115  const std::map<std::string, std::string>& file_contents);
116 
118  const std::vector<std::shared_ptr<Assertions::Assertion>>& assertions() const;
119 
121  const std::vector<PrintStatement>& print_statements() const;
122 
133  Canceller* canceller) const;
134 
148  const LTS::SemanticModel semantic_model,
149  Canceller* canceller) const;
150 
160  const std::string& assertion) const;
161 
163  LTS::CompiledEvent compile_event(const std::shared_ptr<Evaluator::Event>& event) const;
164 
169  std::shared_ptr<Evaluator::Event> uncompile_event(const LTS::CompiledEvent event) const;
170 
172  std::vector<std::shared_ptr<Evaluator::Event>> uncompile_events(
173  const std::vector<LTS::CompiledEvent>& events) const;
174 
181  std::shared_ptr<Evaluator::ProcessName> machine_name(const LTS::Machine& machine) const;
182 
189  std::shared_ptr<Evaluator::ProcessName> machine_node_name(const LTS::Machine& machine, const LTS::Node& node) const;
190 
191 private:
192  struct Data;
193 
194  std::unique_ptr<Data> data;
195 
196  friend class Assertions::Assertion;
200  friend class Assertions::HasTraceAssertion;
201  friend class Assertions::RefinementAssertion;
202 };
203 
204 } // end FDR
FDR::PrintStatement::expression
const std::string & expression() const
The expression that this print statement contains, i.e.
FDR::Session::load_strings_as_file
std::vector< std::string > load_strings_as_file(const std::string &root_file_path, const std::map< std::string, std::string > &file_contents)
Loads the specified file using the specified contents strings.
FDR::Assertions::RefinementAssertion
An refinement assertion about two processes.
Definition: refinement_assertion.h:13
FDR::Session::Session
Session()
Creates a new, empty session.
FDR::Session::print_statements
const std::vector< PrintStatement > & print_statements() const
The list of print statements in the input file.
FDR::Session
Encapsulates information about an input file.
Definition: session.h:79
FDR::Session::machine_node_name
std::shared_ptr< Evaluator::ProcessName > machine_node_name(const LTS::Machine &machine, const LTS::Node &node) const
The name the given machine node was assigned in the input file.
FDR::PrintStatement::source_location
const std::string & source_location() const
A representation of the location in the input file this expression is at.
FDR::Session::load_file
std::vector< std::string > load_file(const std::string &file_path)
Loads a file into this session.
FDR::LTS::Machine
A compiled state machine (a GLTS).
Definition: machine.h:43
FDR::Session::machine_name
std::shared_ptr< Evaluator::ProcessName > machine_name(const LTS::Machine &machine) const
The name the given machine was assigned in the input file, if any.
FDR::FileLoadError
Thrown when a file could not be loaded for some reason.
Definition: session.h:31
FDR::LTS::Node
A node (also known as state) in a GLTS.
Definition: node.h:15
FDR::Session::uncompile_events
std::vector< std::shared_ptr< Evaluator::Event > > uncompile_events(const std::vector< LTS::CompiledEvent > &events) const
As per uncompile_event, but uncompiles a list of events.
FDR::Session::evaluate_expression
Evaluator::EvaluatorResult< std::string > evaluate_expression(const std::string &expression, Canceller *canceller) const
Evaluates the expression, returning a string representation of the value.
FDR::Session::evaluate_process
Evaluator::EvaluatorResult< std::shared_ptr< LTS::Machine > > evaluate_process(const std::string &expression, const LTS::SemanticModel semantic_model, Canceller *canceller) const
Evaluates an expression of type Proc into a state machine.
FDR::Assertions::DivergenceFreeAssertion
An assertion that the given machine is divergence free.
Definition: divergence_free_assertion.h:11
FDR::Assertions::DeterministicAssertion
An assertion that the given machine is deterministic.
Definition: deterministic_assertion.h:11
FDR::Assertions::Assertion
An assertion about processes.
Definition: assertion.h:23
FDR::Session::uncompile_event
std::shared_ptr< Evaluator::Event > uncompile_event(const LTS::CompiledEvent event) const
Converts a compiled event into the original event.
FDR::Assertions::DeadlockFreeAssertion
An assertion that a process is deadlock free.
Definition: deadlock_free_assertion.h:11
FDR::Error
An error thrown by libfdr.
Definition: error.h:11
FDR::Canceller
Allows cancellation of a running task to be requested.
Definition: canceller.h:53
FDR::PrintStatement
A print statement in an input file.
Definition: session.h:51
FDR::Session::parse_assertion
Evaluator::EvaluatorResult< std::shared_ptr< Assertions::Assertion > > parse_assertion(const std::string &assertion) const
Parses the given string as an assertion.
FDR::Assertions::HasTraceAssertion
An assertion that a process has a certain trace.
Definition: has_trace_assertion.h:11
FDR::InputFileError
Thrown whenever an error in the user's input script is detected.
Definition: session.h:44
FDR::Session::compile_event
LTS::CompiledEvent compile_event(const std::shared_ptr< Evaluator::Event > &event) const
Converts a raw event into the corresponding compiled event.
FDR::Session::assertions
const std::vector< std::shared_ptr< Assertions::Assertion > > & assertions() const
The list of assertions that are loaded in this session.
FDR::FileLoadError::file_name
std::string file_name() const
The name of the file that was being loaded when the error occured.
FDR::Evaluator::EvaluatorResult
Represents the result of evaluating something.
Definition: evaluator_result.h:13