Otawa  0.10
Script.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * Script processor interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2009-12, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef OTAWA_SCRIPT_SCRIPT_H_
23 #define OTAWA_SCRIPT_SCRIPT_H_
24 
25 #include <elm/system/Path.h>
26 #include <otawa/proc/Processor.h>
27 #include <elm/util/ErrorHandler.h>
28 
29 namespace elm { namespace xom {
30  class Node;
31  class Element;
32  class XSLTransform;
33 } }
34 
35 namespace otawa { namespace script {
36 
37 // ScriptItem class
38 class ScriptItem {
39 public:
40  typedef enum {
41  T_BOOL = 0,
42  T_INT = 1,
43  T_STRING = 2,
44  T_RANGE = 3,
45  T_ENUM = 4,
46  T_MAX = 5
47  } type_t;
48 
49  static cstring type_labels[];
50 
51  static ScriptItem *parse(xom::Element& elt);
52 
53  virtual ~ScriptItem(void);
54  virtual string makeParam(const string& value);
55 
56  string name;
58  string deflt;
59  string label;
60  string help;
61  bool multi;
62 
63 protected:
65 };
66 
67 
68 // Script class
69 class Script: public Processor, public ErrorHandler {
70 public:
71 
72  Script(void);
73  virtual void configure (const PropList &props);
75 
76  virtual void onError(error_level_t level, const string &message);
77 
78  class ItemIter: public genstruct::Vector<ScriptItem *>::Iterator {
79  public:
80  inline ItemIter(Script& script)
81  : genstruct::Vector<ScriptItem *>::Iterator(script.items) { }
82  };
83 
84 protected:
85  virtual void processWorkSpace(WorkSpace *fw);
86 
87 private:
88  void work(WorkSpace *ws);
89  void declareGlobals(xom::XSLTransform& trans);
90  void onError(xom::Node *node, const string& msg);
91  void onWarning(xom::Node *node, const string& msg);
92  void makeConfig(xom::Element *elem, PropList& props);
93  elm::system::Path path;
97 };
98 
99 // script path
106 
107 } } // otawa::script
108 
109 #endif /* OTAWA_SCRIPT_SCRIPT_H_ */
static cstring type_labels[]
Label matching the scripts (as passed in XML item elements).
Definition: Script.h:49
virtual string makeParam(const string &value)
Called to generate the string of parameter value before passing it to the XSLT processor.
Definition: script_Script.cpp:141
Definition: Script.h:44
genstruct::Vector< ScriptItem * > items
Definition: Script.h:95
Definition: Script.h:41
Definition: Script.h:78
error_level_t
Identifier< xom::Element * > SCRIPT
Put by the Script intrepreter in the configuration properties launching the processor.
Definition: Script.h:45
string name
Definition: Script.h:56
Definition: Registration.h:138
void declareGlobals(xom::XSLTransform &trans)
Declare global variables on the given transformation.
Definition: script_Script.cpp:670
ScriptItem(type_t t, xom::Element &elt)
Protected constructor.
Definition: script_Script.cpp:149
string help
Definition: Script.h:60
A script processor allows to interpret a file that performs a WCET computation.
Definition: Script.h:69
void makeConfig(xom::Element *elem, PropList &props)
Scan the configuration properties in the given element and fill the given property list...
Definition: script_Script.cpp:611
WorkSpace * ws
Definition: Processor.h:185
PropList props
Definition: Script.h:94
Identifier< bool > ONLY_CONFIG
This property informs the script to stop its work just after parsing the configuration items...
ItemIter(Script &script)
Definition: Script.h:80
void work(WorkSpace *ws)
Do the real work.
Definition: script_Script.cpp:353
Identifier< xom::Element * > PLATFORM
Put by the Script intrepreter in the configuration properties launching the processor.
Definition: Script.h:42
Identifier< Pair< string, string > > PARAM
This identifier configures the Script to use the argument (identifier, value) as a parameter...
The processor class is implemented by all code processor.
Definition: Processor.h:49
string deflt
Definition: Script.h:58
virtual void onError(error_level_t level, const string &message)
Definition: script_Script.cpp:661
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
elm::system::Path path
Definition: Script.h:93
virtual void processWorkSpace(WorkSpace *fw)
Process the given framework.
Definition: script_Script.cpp:333
bool timed
Definition: Script.h:96
Identifier< elm::system::Path > PATH
This identifier configures the Script to use the given path.
virtual ~ScriptItem(void)
Definition: script_Script.cpp:172
type_t type
Definition: Script.h:57
Definition: Script.h:46
static Registration< Script > reg
Definition: Script.h:74
virtual void configure(const PropList &props)
This method may be called for configuring a processor thanks to information passed in the property li...
Definition: script_Script.cpp:322
These objects represents the item of the configuration of a script.
Definition: Script.h:38
This class represents identifier with a typed associated value.
Definition: Identifier.h:51
Identifier< bool > TIME_STAT
This property asks the script to time the performed steps.
Script(void)
Definition: script_Script.cpp:316
bool multi
Definition: Script.h:61
bool only_config
Definition: Script.h:96
This a list of properties.
Definition: PropList.h:63
string label
Definition: Script.h:59
static ScriptItem * parse(xom::Element &elt)
Parse an XML element to build the matching script item.
Definition: script_Script.cpp:253
void onWarning(xom::Node *node, const string &msg)
Handle an error.
Definition: script_Script.cpp:600
type_t
Definition: Script.h:40