15#include "mcrl2/atermpp/aterm_io_binary.h"
16#include "mcrl2/lps/specification.h"
17#include "mcrl2/lps/stochastic_specification.h"
38template <
typename Specification>
39void save_lps(
const Specification& spec, std::ostream& stream,
const std::string& target =
"")
41 mCRL2log(log::log_level_t::debug) <<
"Saving LPS" << (target.empty() ?
"" :
" to " + target) <<
".\n";
42 atermpp::binary_aterm_ostream(stream) << spec;
50template <
typename Specification>
51void load_lps(Specification& spec, std::istream& stream,
const std::string& source =
"")
53 mCRL2log(log::log_level_t::debug) <<
"Loading LPS" << (source.empty() ?
"" :
" from " + source) <<
".\n";
55 if constexpr (std::is_same_v<Specification, specification>)
58 atermpp::binary_aterm_istream(stream) >> stoch_spec;
63 atermpp::binary_aterm_istream(stream) >> spec;
70template <
typename Specification>
71void save_lps(
const Specification& spec,
const std::string& filename)
73 if (filename.empty() || filename ==
"-")
75 save_lps(spec, std::cout,
"standard output");
79 std::ofstream ofs(filename, std::ios_base::binary);
82 throw mcrl2::runtime_error(
"Could not open file " + filename +
".");
84 save_lps(spec, ofs, filename);
91template <
typename Specification>
92void load_lps(Specification& spec,
const std::string& filename)
94 if (filename.empty() || filename ==
"-")
96 load_lps(spec, std::cin,
"standard input");
100 std::ifstream ifs(filename, std::ios_base::binary);
103 throw mcrl2::runtime_error(
"Could not open file " + filename +
".");
105 load_lps(spec, ifs, filename);
The interface for a class that reads aterm from a stream. The default constructed term aterm() indica...
The interface for a class that writes aterm to a stream. Every written term is retrieved by the corre...
A helper class to restore the state of the aterm_{i,o}stream objects upon destruction....
aterm_stream_state(aterm_stream &stream)
A unordered_map class in which aterms can be stored.
LPS summand containing a deadlock.
const data::data_expression & time() const
Returns the time.
\brief A timed multi-action
const process::action_list & actions() const
const data::data_expression & time() const
Linear process specification.
LPS summand containing a multi-action.
const stochastic_distribution & distribution() const
Returns the distribution of this summand.
\brief A stochastic distribution
A stochastic process initializer.
Linear process specification.
stochastic_specification(const specification &other)
Constructor. This constructor is explicit as implicit conversions of this kind is a source of bugs.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
aterm_istream & operator>>(aterm_istream &stream, aterm &term)
Read the given term from the stream, but for aterm_list we want to use a specific one that performs v...
aterm_istream & operator>>(aterm_istream &stream, aterm_transformer transformer)
Sets the given transformer to be applied to following reads.
atermpp::aterm remove_index_impl(const atermpp::aterm &x)
atermpp::aterm add_index_impl(const atermpp::aterm &x)
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, data_specification &spec)
Reads a data specification from a stream.
The main namespace for the LPS library.
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, deadlock_summand &summand)
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, linear_process_base< ActionSummand > &lps)
void load_lps(Specification &spec, const std::string &filename)
Load LPS from file.
void save_lps(const Specification &spec, std::ostream &stream, const std::string &target="")
Save an LPS in the format specified.
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, lps::stochastic_specification &spec)
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, lps::specification &spec)
Reads LPS from the stream.
atermpp::aterm linear_process_specification_marker()
void save_lps(const Specification &spec, const std::string &filename)
Saves an LPS to a file.
specification remove_stochastic_operators(const stochastic_specification &spec)
Converts a stochastic specification to a specification. Throws an exception if non-empty distribution...
void load_lps(Specification &spec, std::istream &stream, const std::string &source="")
Load LPS from file.
static void read_spec(atermpp::aterm_istream &stream, stochastic_specification &spec)
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, multi_action &action)
static void write_spec(atermpp::aterm_ostream &stream, const stochastic_specification &spec)
atermpp::aterm_istream & operator>>(atermpp::aterm_istream &stream, stochastic_action_summand &summand)
The main namespace for the Process library.