Otawa  0.10
AbstractIdentifier.h
Go to the documentation of this file.
1 /*
2  * OTAWA -- WCET computation framework
3  * Copyright (C) 2007-09 IRIT - UPS <casse@irit.fr>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.package ojawa;
18  */
19 #ifndef OTAWA_PROP_ABSTRACT_IDENTIFIER_H
20 #define OTAWA_PROP_ABSTRACT_IDENTIFIER_H
21 
22 #include <elm/assert.h>
23 #include <elm/string.h>
24 #include <elm/io.h>
25 #include <elm/util/VarArg.h>
26 #include <otawa/base.h>
27 #include <otawa/prop/PropList.h>
28 
29 namespace otawa {
30 
31 // Identifier class
34 
35 public:
36  static AbstractIdentifier *find(const string& name);
37 
38  AbstractIdentifier(void);
41  virtual ~AbstractIdentifier(void) { }
42 
43  inline const string name(void) const { return nam; }
44  void print(elm::io::Output& out) const;
45 
46  virtual void print(elm::io::Output& output, const Property *prop) const;
47  inline void print(elm::io::Output& output, const Property& prop) const { print(output, &prop); }
48  virtual void printFormatted(io::Output& out, const Property *prop) const;
49  inline void printFormatted(elm::io::Output& output, const Property& prop) const { printFormatted(output, &prop); }
50 
51  virtual const Type& type(void) const;
52  virtual void fromString(PropList& props, const string& str) const;
53 
54  virtual bool equals(const Property *prop1, const Property *prop2) const;
55  virtual Property *copy(Property& prop) const;
56  inline Property *copy(Property *prop) const { return copy(*prop); }
57 
58  // serialization
59  virtual void serialize(Property *prop, elm::serial2::Serializer& serializer);
60  virtual Property *unserialize(elm::serial2::Unserializer& unserializer);
61 
62 protected:
63  void initProps(Property *prop, VarArg& args);
64 
65 private:
66  string nam;
67  void initialize(void);
68 };
69 
70 
71 // DuplicateIdentifierException class
73 public:
75 };
76 
77 
79  { id.print(out); return out; }
81  { ASSERT(id); return out << *id; }
82 
83 } //otawa
84 
85 #endif // OTAWA_PROP_ABSTRACT_IDENTIFIER_H
virtual bool equals(const Property *prop1, const Property *prop2) const
Test if two properties are equal.
Definition: prop_AbstractIdentifier.cpp:317
const string name(void) const
Get the string name of the identifier.
Definition: AbstractIdentifier.h:43
void print(elm::io::Output &out) const
Print the identifier.
Definition: prop_AbstractIdentifier.cpp:168
AbstractIdentifier(void)
Build an anonymous identifier.
Definition: prop_AbstractIdentifier.cpp:103
elm::io::Output & operator<<(elm::io::Output &out, Address addr)
Definition: base.cpp:188
Represents a unique identifier used by the annotation system.
Definition: AbstractIdentifier.h:32
Base class of Otawa exceptions.
Definition: base.h:168
virtual void fromString(PropList &props, const string &str) const
Get value of an identifier from a string and store it in the given property list. ...
Definition: prop_AbstractIdentifier.cpp:229
virtual Property * unserialize(elm::serial2::Unserializer &unserializer)
Unserialize the workspace to the current unserializer.
Definition: prop_AbstractIdentifier.cpp:357
DuplicateIdentifierException(String &name)
Build a new exception.
Definition: prop_AbstractIdentifier.cpp:45
Property * copy(Property *prop) const
Definition: AbstractIdentifier.h:56
void print(elm::io::Output &output, const Property &prop) const
Definition: AbstractIdentifier.h:47
string nam
Definition: AbstractIdentifier.h:66
void initialize(void)
For internal use only.
Definition: prop_AbstractIdentifier.cpp:237
virtual ~AbstractIdentifier(void)
Definition: AbstractIdentifier.h:41
void printFormatted(elm::io::Output &output, const Property &prop) const
Definition: AbstractIdentifier.h:49
Definition: PropList.h:28
sys::SystemOutStream & out
virtual void serialize(Property *prop, elm::serial2::Serializer &serializer)
Serialize the workspace to the current serializer.
Definition: prop_AbstractIdentifier.cpp:346
This exception is thrown when two identifier with the same name are declared.
Definition: AbstractIdentifier.h:72
static AbstractIdentifier * find(const string &name)
Find an abstract identifier by its name.
Definition: prop_AbstractIdentifier.cpp:95
virtual Property * copy(Property &prop) const
Build a copy of the given property.
Definition: prop_AbstractIdentifier.cpp:327
cstring name
Definition: odisasm.cpp:107
This a list of properties.
Definition: PropList.h:63
void initProps(Property *prop, VarArg &args)
Add the properties found in the arguments (list of Property * ended by null) to the identifier proper...
Definition: prop_AbstractIdentifier.cpp:149
virtual const Type & type(void) const
Get the identifier of data linked with this property.
Definition: prop_AbstractIdentifier.cpp:218
virtual void printFormatted(io::Output &out, const Property *prop) const
Print the value of the given property in a formatted way, that is, possibly to perform re-scanning af...
Definition: prop_AbstractIdentifier.cpp:197
A property associates a data with an identifier.
Definition: PropList.h:42
This class describes the type of the data in the program.
Definition: type.h:39