Otawa  0.10
Accessor.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * AbstractAccessor and Accessor classes interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2005-10, 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_ACCESSOR_H_
23 #define OTAWA_PROC_ACCESSOR_H_
24 
26 
27 namespace otawa {
28 
29 class WorkSpace;
30 
32 public:
34 };
35 
36 template <class T>
37 class Accessor: public AbstractAccessor {
38 public:
40  virtual T get(WorkSpace *ws) const = 0;
41 };
42 
43 template <class T>
44 class FunAccessor: public Accessor<T> {
45 public:
46  typedef T (*fun_t)(WorkSpace *ws);
47  inline FunAccessor(fun_t _f, cstring name = ""): Accessor<T>(name), f(_f) { }
48  virtual T get(WorkSpace *ws) const { return f(ws); }
49 private:
51 };
52 
53 } // otawa
54 
55 #endif /* OTAWA_PROC_ACCESSOR_H_ */
Definition: Accessor.h:31
Accessor(cstring name="")
Definition: Accessor.h:39
T(* fun_t)(WorkSpace *ws)
Definition: Accessor.h:46
fun_t f
Definition: Accessor.h:50
const string name(void) const
Get the string name of the identifier.
Definition: AbstractIdentifier.h:43
Definition: Accessor.h:37
Represents a unique identifier used by the annotation system.
Definition: AbstractIdentifier.h:32
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
AbstractAccessor(cstring name="")
Definition: Accessor.h:33
FunAccessor(fun_t _f, cstring name="")
Definition: Accessor.h:47
Definition: Accessor.h:44