Otawa  0.10
Feature.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * feature module interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2005-08, 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_PROC_FEATURE_H
23 #define OTAWA_PROC_FEATURE_H
24 
25 #include <elm/string.h>
27 #include <otawa/prop/info.h>
28 
29 namespace otawa {
30 
31 using namespace elm;
32 class WorkSpace;
33 
34 
35 class FeatureDependency;
36 
37 // default_handler_t structure
38 typedef struct default_handler_t {
39  static inline void check(WorkSpace *fw) { }
40  static inline void clean(WorkSpace *ws) { };
42 
43 
44 // Feature class
45 template <class T, class C = default_handler_t>
46 class Feature: public AbstractFeature {
47 public:
48  Feature(CString name = "");
49  virtual void process(WorkSpace *fw,
50  const PropList& props = PropList::EMPTY) const;
51 
52  // Abstract feature overload
53  virtual void check(WorkSpace *fw) const { C::check(fw); }
54  virtual void clean(WorkSpace *ws) const { C::clean(ws); }
55 };
56 
57 
58 // identifier property
59 extern Identifier<const AbstractFeature *> DEF_BY;
60 inline Property *defBy(const AbstractFeature *feature)
61  { return make(DEF_BY, feature); }
62 
63 
64 // Inline
65 template <class T, class C>
67 }
68 
69 template <class T, class C>
70 void Feature<T, C>::process(WorkSpace *fw, const PropList& props) const {
71  Processor *proc = (*this)(props);
72  if(proc)
73  proc->process(fw, props);
74  else {
75  T proc;
76  proc.process(fw, props);
77  }
78 }
79 
80 } // otawa
81 
82 #endif /* OTAWA_PROC_FEATURE_H */
static void clean(WorkSpace *ws)
Definition: Feature.h:40
virtual void process(WorkSpace *fw, const PropList &props=PropList::EMPTY) const
This method is called, when a feature is not available, to provided a default implementation of the f...
Definition: Feature.h:70
static void check(WorkSpace *fw)
Definition: Feature.h:39
static const PropList EMPTY
This is an empty proplist for convenience.
Definition: PropList.h:66
struct otawa::default_handler_t default_handler_t
StringOption proc(command, 'p',"processor","used processor","path","")
void process(WorkSpace *ws, const PropList &props=PropList::EMPTY)
Execute the code processor on the given framework.
Definition: proc_Processor.cpp:418
The processor class is implemented by all code processor.
Definition: Processor.h:49
Property * defBy(const AbstractFeature *feature)
Definition: Feature.h:60
Definition: Feature.h:38
virtual void clean(WorkSpace *ws) const
This method is called each time a feature is invalidated.
Definition: Feature.h:54
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
Identifier< const AbstractFeature * > DEF_BY
Identifier for identifier property providing ownerness of an identifier.
Property * make(const Identifier< T > &id, const T &v)
Definition: info.h:31
Feature(CString name="")
Definition: Feature.h:66
cstring name
Definition: odisasm.cpp:107
See Feature.
Definition: AbstractFeature.h:36
This a list of properties.
Definition: PropList.h:63
virtual void check(WorkSpace *fw) const
Check if the framework really implement the current feature.
Definition: Feature.h:53
A property associates a data with an identifier.
Definition: PropList.h:42
A feature is a set of facilities, usually provided using properties, available on a framework...
Definition: Feature.h:46