/* * attributes and attribute sets */ #ifndef ATTR_H #define ATTR_H #include #include #include "lsys.h" #include "util.h" #include "matrix.h" using namespace std; struct attribute_set : public shared { const module *operator ()(const string &attr) const t_no { const_iterator i; return (i = obj->find (attr)) == end () ? 0 : &i->second; } string operator ()(const string &attr, const string &def) const t_no { const_iterator i; return (i = obj->find (attr)) == end () ? def : i->second.first ().str; } double operator ()(const string &attr, double def) const t_err { const_iterator i; return (i = obj->find (attr)) == end () ? def : eval_expr (i->second); } vec operator ()(const string &attr, const vec &def) const t_err; const_iterator find (const string &s) const t_no { return obj->find (s); }; const module &operator [](const string &s) const t_no { return (*obj)[s]; }; module &operator [](const string &s) t_no { unshare (); return (*obj)[s]; }; }; #endif