Otawa  0.10
NamedObject.h
Go to the documentation of this file.
1 /*
2  * NamedObject interface
3  * Copyright (c) 2012, IRIT UPS <casse@irit.fr>
4  *
5  * LBlockBuilder class interface
6  * This file is part of OTAWA
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 Foobar; 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_NAMEDOBJECT_H_
23 #define OTAWA_SCRIPT_NAMEDOBJECT_H_
24 
25 #include <elm/genstruct/AVLMap.h>
26 #include <elm/serial2/macros.h>
27 
28 namespace otawa { namespace script {
29 
30 using namespace elm;
31 
32 class NamedObject {
33 private:
34  SERIALIZABLE(NamedObject, DFIELD(name, string("")));
35 public:
36  static void declare(NamedObject *object);
37  static NamedObject *get(string name);
38 
39  inline NamedObject(void) { }
40  NamedObject(string _name);
41  virtual ~NamedObject(void);
42  inline string getName(void) const { return name; }
43  template <class T> bool implements(void) const
44  { return T::__class.baseOf(this->__getSerialClass()); }
45 
46 private:
48  string name;
49 };
50 
51 } } // otawa::script
52 
53 #endif /* OTAWA_SCRIPT_NAMEDOBJECT_H_ */
Named are used by script to locate a data structure passed as argument to a code processor.
Definition: NamedObject.h:32
NamedObject(void)
Anonymous named object constructor.
Definition: NamedObject.h:39
string name
Definition: NamedObject.h:48
static genstruct::AVLMap< string, NamedObject * > objects
Known named objects.
Definition: NamedObject.h:47
cstring name
Definition: odisasm.cpp:107
bool implements(void) const
Definition: NamedObject.h:43
string getName(void) const
Get the name of the object.
Definition: NamedObject.h:42