Otawa  0.10
DynFeature.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * DynFeature class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2009, 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 OTAW_PROC_DYNFEATURE_H_
23 #define OTAW_PROC_DYNFEATURE_H_
24 
25 #include <otawa/proc/Feature.h>
26 
27 namespace otawa {
28 
29 // FeatureNotFound exception
31 public:
32  FeatureNotFound(string name);
33  inline const string& name(void) const { return _name; }
34 
35 private:
36  string _name;
37 };
38 
39 // DynFeature class
40 class DynFeature {
41 public:
42  DynFeature(string name);
43  inline operator AbstractFeature *(void) const throw(FeatureNotFound)
44  { if(!feature) init(); return feature; }
45  inline AbstractFeature *operator*(void) const throw(FeatureNotFound)
46  { if(!feature) init(); return feature; }
47  inline operator AbstractFeature&(void) const throw(FeatureNotFound)
48  { if(!feature) init(); return *feature; }
49 
50 private:
52  string _name;
53  void init(void) const throw(FeatureNotFound);
54 };
55 
56 } // otawa
57 
58 #endif /* OTAW_PROC_ DYNFEATURE_H_ */
AbstractFeature * feature
Definition: DynFeature.h:51
Definition: DynFeature.h:30
string _name
Definition: DynFeature.h:36
string _name
Definition: DynFeature.h:52
Base class of Otawa exceptions.
Definition: base.h:168
void init(void) const
Bind the feature.
Definition: proc_DynFeature.cpp:120
const string & name(void) const
Get the name of the feature that has caused this exception.
Definition: DynFeature.h:33
FeatureNotFound(string name)
Build the exception.
Definition: proc_DynFeature.cpp:89
AbstractFeature * operator*(void) const
if not already done, bind the feature and return a pointer to.
Definition: DynFeature.h:45
cstring name
Definition: odisasm.cpp:107
See Feature.
Definition: AbstractFeature.h:36
DynFeature(string name)
Build the dynamic featue.
Definition: proc_DynFeature.cpp:112
This class is used to resolve feature found in plugins using ProcessorPlugin::getFeature() method...
Definition: DynFeature.h:40