Otawa  0.10
DynIdentifier.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * DynIdentifier class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2010, 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_DYNIDENTIFIER_H_
23 #define OTAWA_PROC_DYNIDENTIFIER_H_
24 
26 #include <otawa/prop/Identifier.h>
27 
28 namespace otawa {
29 
30 // DynIdentifier class
31 template <class T>
33 public:
34  inline DynIdentifier(cstring name): _name(name), _id(0) { }
35  inline cstring name(void) const { return _name; }
36 
37  const T &operator()(const PropList &props) const { return id()(props); }
38  const T &operator()(const PropList *props) const { return id()(props); }
39  Ref<T, Identifier<T> > operator()(PropList &props) const { return id()(props); }
40  Ref<T, Identifier<T> > operator()(PropList *props) const { return id()(props); }
41 
42 private:
43  inline Identifier<T>& id(void) const {
44  if(!_id)
46  ASSERTP(_id, _ << "identifier " << _name << " cannot be found.");
47  return *_id;
48  }
49 
51  mutable Identifier<T> *_id;
52 };
53 
54 } // otawa
55 
56 #endif /* OTAWA_PROC_DYNIDENTIFIER_H_ */
cstring _name
Definition: DynIdentifier.h:50
static AbstractIdentifier * getIdentifier(cstring name)
Find an identifier by its name possibly loading a plugin to get it.
Definition: proc_ProcessorPlugin.cpp:227
An identifier dynamically resolved.
Definition: DynIdentifier.h:32
Identifier< T > & id(void) const
Definition: DynIdentifier.h:43
Identifier< T > * _id
Definition: DynIdentifier.h:51
AutoStringStartup & _
cstring name(void) const
Get the full-qualified C++ name of the identifier.
Definition: DynIdentifier.h:35
const T & operator()(const PropList &props) const
Definition: DynIdentifier.h:37
Ref< T, Identifier< T > > operator()(PropList *props) const
Definition: DynIdentifier.h:40
This class represents identifier with a typed associated value.
Definition: Identifier.h:51
const T & operator()(const PropList *props) const
Definition: DynIdentifier.h:38
This a list of properties.
Definition: PropList.h:63
Ref< T, Identifier< T > > operator()(PropList &props) const
Definition: DynIdentifier.h:39
DynIdentifier(cstring name)
Build a dynamic identifier.
Definition: DynIdentifier.h:34