UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Scenario.h
1 /***************************************************************************
2  * Copyright (C) 2014 by Jan Stückrath <jan.stueckrath@uni-due.de> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
18  ***************************************************************************/
19 
20 #ifndef SCENARIO_H
21 #define SCENARIO_H
22 
23 #include "globals.h"
24 #include "../basic_types/InitialisationException.h"
25 #include "../basic_types/RunException.h"
26 
27 namespace uncover {
28  namespace basic_types {
29 
36  class Scenario
37  {
38 
39  public:
40 
44  virtual ~Scenario();
45 
51  void initialize(vector<string>& params);
52 
56  virtual void run() = 0;
57 
62  string getName() const;
63 
68  bool isInitialized() const;
69 
75  string getScenarioDesciption() const;
76 
77  protected:
78 
85  Scenario(string name, string desciptor, vector<string> const& alternateNames = vector<string>());
86 
92  virtual void initialize(unordered_map<string,string>& parameters) = 0;
93 
103  void addParameter(string paramName, string description, bool mandatory = true);
104 
111  void addSynonymFor(string original, string synonym);
112 
117  void checkInitializationAndThrow() const;
118 
122  const string scenarioName;
123 
127  const vector<string> alternateNames;
128 
133  const string scenarioDescriptor;
134 
135  private:
136 
141  vector<string> parameterNames;
142 
146  unordered_map<string,pair<string,bool>> parameterDescriptor;
147 
151  unordered_map<string,string> synonyms;
152 
157 
158  };
159 
163  typedef unique_ptr<Scenario> Scenario_up;
164 
165  }
166 }
167 
168 #endif
vector< string > parameterNames
Contains the names of all parameters of the Scenario.
Definition: Scenario.h:141
const string scenarioName
A unique name of this scenario starting with "scn_".
Definition: Scenario.h:122
void checkInitializationAndThrow() const
Check if the Scenario was initialized and throws a RunException if it was not.
Definition: Scenario.cpp:174
Scenario(string name, string desciptor, vector< string > const &alternateNames=vector< string >())
Generates an uninitialized Scenario with the given name and call descriptor.
Definition: Scenario.cpp:36
const string scenarioDescriptor
Contains a description of how a call of this scenario may look like.
Definition: Scenario.h:133
void addSynonymFor(string original, string synonym)
Stores that the parameter 'original' is also meant if 'synonym' was given as parameter.
Definition: Scenario.cpp:170
bool wasInitialized
Stores whether the Scenario was initialized or not.
Definition: Scenario.h:156
unique_ptr< Scenario > Scenario_up
Alias of a unique pointer to a Scenario object.
Definition: Scenario.h:163
virtual void run()=0
Executes the scenario.
string getScenarioDesciption() const
Returns a full description of the given Scenario.
Definition: Scenario.cpp:118
A scenario is a subprogram using a set of input parameters to execute some algorithms, producing desired output.
Definition: Scenario.h:36
bool isInitialized() const
Check whether the Scenario was already initialized or not.
Definition: Scenario.cpp:114
virtual ~Scenario()
The destructor of the current Scenario.
Definition: Scenario.cpp:40
unordered_map< string, string > synonyms
Stores all synonyms for parameters.
Definition: Scenario.h:151
void initialize(vector< string > &params)
Initializes the current Scenario with the given vector of parameters.
Definition: Scenario.cpp:42
string getName() const
Returns the name of this Scenario, which is a string beginning with 'scn_'.
Definition: Scenario.cpp:110
unordered_map< string, pair< string, bool > > parameterDescriptor
Stores detailed description of every parameter of this Scenario and whether the parameter is mandator...
Definition: Scenario.h:146
const vector< string > alternateNames
A vector containing all names for this Scenario, beyond scenarioName.
Definition: Scenario.h:127
void addParameter(string paramName, string description, bool mandatory=true)
Defined a new input parameter with the name 'paramName' the description 'description'.
Definition: Scenario.cpp:164