22 #ifndef OTAWA_PROP_IDENTIFIER_H
23 #define OTAWA_PROP_IDENTIFIER_H
32 #include <elm/sys/Path.h>
37 using namespace elm::io;
45 template <
class T>
inline void print(
Output&
out, T *p) {
if(!p) out <<
"<null>";
else out << p; }
61 { VARARG_BEGIN(args, prop); initProps(prop, args); VARARG_END }
70 inline void add(
PropList& list,
const T& value)
const;
71 inline void set(
PropList& list,
const T& value)
const;
73 inline const T&
get(
const PropList& list,
const T& def)
const;
78 inline void remove(
PropList& list)
const { list.removeProp(
this); }
87 inline const T&
get(
const PropList *list,
const T& def)
const {
return get(*list, def); }
92 inline void remove(
PropList *list)
const { list->removeProp(
this); }
97 inline const T&
get(
const Property *prop)
const
111 {
p::print(out, !prop ? def :
get(*prop)); }
113 {
p::print(out, !prop ? def :
get(*prop)); }
114 virtual const Type&
type(
void)
const {
return otawa::type<T>(); }
115 virtual void fromString(
PropList& props,
const string& str)
const;
125 inline bool ended(
void)
const {
return getter.ended(); }
126 inline void next(
void) { getter.next(); }
133 inline const T&
get(
const Property& prop)
const;
210 return _prop->
value();
226 T *ptr = args.
next<T *>();
232 T ptr = args.
next<T>();
265 #endif // OTAWA_PROP_IDENTIFIER_H
static void scan(const Identifier< T > &id, PropList &props, VarArg &args)
Definition: Identifier.h:224
void set(PropList *list, const T &value) const
Set the value of a generic property with the current identifier to the given list.
Definition: Identifier.h:85
Identifier(cstring name, const T &default_value, Property *prop, VarArg &args)
Definition: Identifier.h:63
virtual const Type & type(void) const
Get the identifier of data linked with this property.
Definition: Identifier.h:114
const T & defaultValue(void) const
Definition: Identifier.h:67
bool ended(void) const
Definition: Identifier.h:125
This class is used for accessing all properties of property list with a given identifier.
Definition: PropList.h:111
PropList::Getter getter
Definition: Identifier.h:128
const T & value(const PropList *list) const
For internal use only.
Definition: Identifier.h:90
Getter(const PropList *list, Identifier< T > &id)
Definition: Identifier.h:122
const T & operator()(const PropList *props) const
Read the value in a functional way.
Definition: Identifier.h:104
This generic class allows attaching any type of data to a property.
Definition: Property.h:20
Getter(const PropList &list, Identifier< T > &id)
Definition: Identifier.h:123
const T & use(const PropList *list) const
Get the value matching the current identifier in the given list.
Definition: Identifier.h:89
const T & operator()(Property *prop) const
Definition: Identifier.h:107
void next(void)
Definition: Identifier.h:126
Represents a unique identifier used by the annotation system.
Definition: AbstractIdentifier.h:32
T def
Definition: Identifier.h:132
Identifier(cstring name)
Build a new generic identifier.
Definition: Identifier.h:55
Definition: Identifier.h:120
const T & use(const PropList &list) const
Get the value matching the current identifier in the given list.
Definition: Identifier.h:184
value_t value(CString name, int value)
void set(Property *prop, const T &value) const
Definition: Identifier.h:99
Definition: Identifier.h:135
T & ref(PropList *list) const
Definition: Identifier.h:88
Ref< T, Identifier< T > > value(PropList *list) const
For internal use only.
Definition: Identifier.h:91
bool exists(PropList &list) const
Test if the given list contains a property with the current identifier.
Definition: Identifier.h:79
const T & value(const PropList &list) const
For internal use only.
Definition: Identifier.h:191
Identifier(cstring name, const T &default_value, Property *prop,...)
Definition: Identifier.h:59
const int use
Definition: Registration.h:46
void set(PropList &list, const T &value) const
Set the value of a generic property with the current identifier to the given list.
Definition: Identifier.h:157
bool exists(PropList *list) const
Test if the given list contains a property with the current identifier.
Definition: Identifier.h:93
virtual void print(elm::io::Output &out, const Property *prop) const
Print the value of the given property (accordint the property matches the given identifier).
Definition: Identifier.h:110
Definition: Identifier.h:139
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: Identifier.h:248
void addProp(Property *prop)
Add property to the list without checking of duplication.
Definition: prop_PropList.cpp:537
elm::Option< T > get(const PropList &list) const
Definition: Identifier.h:166
sys::SystemOutStream & out
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: Identifier.h:112
void add(PropList &list, const T &value) const
Add a generic property to the given list with the current identifier.
Definition: Identifier.h:147
Ref< T, Identifier< T > > operator()(PropList &props) const
Read or write a property value in a functional way.
Definition: Identifier.h:105
inst add(int d, int a, int b)
Definition: inst.h:163
This class represents identifier with a typed associated value.
Definition: Identifier.h:51
virtual Property * copy(Property &prop) const
Build a copy of the given property.
Definition: Identifier.h:116
void copy(PropList &list, Property *prop)
Definition: Identifier.h:80
cstring name
Definition: odisasm.cpp:107
void copy(PropList *list, Property *prop)
Definition: Identifier.h:94
T & ref(PropList &list) const
Definition: Identifier.h:204
static void scan(const Identifier< T > &id, PropList &props, VarArg &args)
Definition: Identifier.h:231
void add(PropList *list, const T &value) const
Add a generic property to the given list with the current identifier.
Definition: Identifier.h:84
const T & value(void) const
Get the value of the property.
Definition: Property.h:33
const T & item(void) const
Definition: Identifier.h:124
This a list of properties.
Definition: PropList.h:63
const T & operator()(const PropList &props) const
Read the value in a functional way.
Definition: Identifier.h:103
Property * getProp(const AbstractIdentifier *id) const
Find a property by its identifier.
Definition: prop_PropList.cpp:357
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
static GenericProperty< T > * make(const AbstractIdentifier *id, const T &value)
Build a new generic property with the given data.
Definition: Property.h:31
void print(Output &out, const T &v)
Definition: Identifier.h:44
Ref< T, Identifier< T > > operator()(PropList *props) const
Read or write a property value in a functional way.
Definition: Identifier.h:106
Identifier(cstring name, const T &default_value)
Build a new generic identifier.
Definition: Identifier.h:56