| 1 |
/* |
| 2 |
* attributes and attribute sets |
| 3 |
*/ |
| 4 |
|
| 5 |
#ifndef ATTR_H |
| 6 |
#define ATTR_H |
| 7 |
|
| 8 |
#include <string> |
| 9 |
#include <map> |
| 10 |
|
| 11 |
#include "lsys.h" |
| 12 |
#include "util.h" |
| 13 |
#include "matrix.h" |
| 14 |
|
| 15 |
using namespace std; |
| 16 |
|
| 17 |
struct attribute_set : public shared<module_map> { |
| 18 |
const module *operator ()(const string &attr) const t_no |
| 19 |
{ const_iterator i; return (i = obj->find (attr)) == end () ? 0 : &i->second; } |
| 20 |
string operator ()(const string &attr, const string &def) const t_no |
| 21 |
{ const_iterator i; return (i = obj->find (attr)) == end () ? def : i->second.first ().str; } |
| 22 |
double operator ()(const string &attr, double def) const t_err |
| 23 |
{ const_iterator i; return (i = obj->find (attr)) == end () ? def : eval_expr (i->second); } |
| 24 |
vec operator ()(const string &attr, const vec &def) const t_err; |
| 25 |
|
| 26 |
const_iterator find (const string &s) const t_no { return obj->find (s); }; |
| 27 |
|
| 28 |
const module &operator [](const string &s) const t_no { return (*obj)[s]; }; |
| 29 |
module &operator [](const string &s) t_no { unshare (); return (*obj)[s]; }; |
| 30 |
}; |
| 31 |
|
| 32 |
#endif |