mCRL2
Loading...
Searching...
No Matches
pbes_input_tool.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_PBES_PBES_INPUT_TOOL_H
13#define MCRL2_PBES_PBES_INPUT_TOOL_H
14
16#include "mcrl2/pbes/io.h"
17#include "mcrl2/pbes/io.h"
18
19namespace mcrl2
20{
21
22namespace pbes_system
23{
24
25namespace tools
26{
27
30template <typename Tool>
31class pbes_input_tool: public Tool
32{
33 protected:
34
37
41 virtual std::set<utilities::file_format> available_input_formats() const
42 {
43 std::set<utilities::file_format> result;
44 result.insert(pbes_system::pbes_format_internal());
45 result.insert(pbes_system::pbes_format_text());
46 result.insert(pbes_system::pbes_format_pgsolver());
47 return result;
48 }
49
53 // determine the file format in this way, pbes_format_internal() is returned.
55 {
56 utilities::file_format result = pbes_system::guess_format(Tool::input_filename());
57 if (result == utilities::file_format())
58 {
59 result = pbes_system::guess_format(Tool::input_filename());
60 }
61 if (result == utilities::file_format())
62 {
64 }
65 return result;
66 }
67
71 void add_options(utilities::interface_description& desc)
72 {
73 Tool::add_options(desc);
74 std::set<utilities::file_format> types = available_input_formats();
75 auto option_argument = utilities::make_enum_argument<std::string>("FORMAT");
76 for (const utilities::file_format& type: types)
77 {
78 option_argument.add_value_desc(type.shortname(), type.description(), type == default_input_format());
79 }
80 desc.add_option("in", option_argument, "use input format FORMAT:", 'i');
81 }
82
85 void parse_options(const utilities::command_line_parser& parser)
86 {
87 Tool::parse_options(parser);
89 if(parser.options.count("in"))
90 {
91 std::set<utilities::file_format> types = available_input_formats();
92 std::string arg = parser.option_argument_as<std::string>("in");
93 for (const utilities::file_format& type: types)
94 {
95 if (type.shortname() == arg)
96 {
98 }
99 }
101 {
102 mCRL2log(log::warning) << "Invalid input format given (" << arg << ").\n";
103 }
104 }
106 {
108 mCRL2log(log::verbose) << "Guessing input format: " << m_pbes_input_format.description()
109 << std::endl;
110 }
111 }
112
113
114 public:
121 pbes_input_tool(const std::string& name,
122 const std::string& author,
123 const std::string& what_is,
124 const std::string& tool_description,
125 std::string known_issues = ""
126 )
127 : Tool(name, author, what_is, tool_description, known_issues)
128 {}
129
131 virtual ~pbes_input_tool() = default;
132
136 {
137 return m_pbes_input_format;
138 }
139};
140
141} // namespace tools
142
143} // namespace pbes_system
144
145} // namespace mcrl2
146
147#endif // MCRL2_PBES_PBES_INPUT_TOOL_H
Base class for filter tools that take a pbes as input.
pbes_input_tool(const std::string &name, const std::string &author, const std::string &what_is, const std::string &tool_description, std::string known_issues="")
Constructor.
utilities::file_format m_pbes_input_format
The type of the pbes input format.
virtual utilities::file_format default_input_format() const
Returns the default file format. Override this method to change the standard behavior.
void parse_options(const utilities::command_line_parser &parser)
Parse non-standard options.
virtual std::set< utilities::file_format > available_input_formats() const
Returns the file formats that are available for this tool. Override this method to change the standar...
virtual ~pbes_input_tool()=default
Destructor.
void add_options(utilities::interface_description &desc)
Add options to an interface description. Also includes input format options.
utilities::file_format pbes_input_format() const
Returns the input file format.
const std::string & description() const
Components for command line interfaces of mCRL2 tools.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
@ warning
Definition logger.h:34
@ verbose
Definition logger.h:37
const utilities::file_format & pbes_format_pgsolver()
Definition io.h:48
const utilities::file_format & pbes_format_internal()
Definition io.h:42
const utilities::file_format & pbes_format_text()
Definition io.h:44
const utilities::file_format guess_format(const std::string &filename)
Definition io.h:51
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
IO routines for boolean equation systems.