#ifndef IDENTIFIER_HH
#define IDENTIFIER_HH
#include "identparent.hh"
+#include "symtable.hh"
#include "inputstaff.hh"
#include "inputmusic.hh"
#define make_id_class(Idclass, Class, accessor) \
struct Idclass : Identifier {\
Idclass(String s, Class*st):Identifier(s) { data = st; }\
- virtual Class* accessor() { return (Class*) data; }\
+ virtual Class* accessor(bool copy=false) {\
+ if (copy)\
+ return new Class(* (Class*) data);\
+ else\
+ return (Class*) data;\
+ }\
~Idclass() { delete accessor(); }\
}\
-
+make_id_class(Lookup_id, Lookup, lookup);
+make_id_class(Symtables_id, Symtables, symtables);
make_id_class(Staff_id, Input_staff, staff);
make_id_class(M_chord_id, Music_general_chord, mchord);
make_id_class(M_voice_id, Music_voice, mvoice);
Identifier(String n) : name(n) { }
virtual ~Identifier() {}
- virtual Input_staff * staff() { assert(false); }
- virtual Voice_list * voices() { assert(false); }
- virtual Horizontal_music*hmusic() { assert(false); }
- virtual Vertical_music*vmusic() { assert(false); }
- virtual Music_voice *mvoice() { assert(false); }
- virtual Music_general_chord *mchord() { assert(false); }
+
+ virtual Input_staff * staff(bool = false) { assert(false); }
+ virtual Horizontal_music*hmusic(bool = false) { assert(false); }
+ virtual Vertical_music*vmusic(bool = false) { assert(false); }
+ virtual Music_voice *mvoice(bool = false) { assert(false); }
+ virtual Symtables *symtables(bool = false) { assert(false); }
+ virtual Music_general_chord *mchord(bool = false) { assert(false); }
+ virtual Lookup*lookup(bool = false) { assert(false); }
};
#endif // IDENTPARENT_HH
#include "real.hh"
#include "symbol.hh"
#include "assoc.hh"
+#include "associter.hh"
#include "symtable.hh"
+Symtables::Symtables()
+{
+}
+
+Symtables::Symtables(Symtables const &s)
+{
+ for (Assoc_iter<String, Symtable*> i(s); i.ok(); i++) {
+ add(i.key(), new Symtable(*i.val()));
+ }
+}
+Symtables::~Symtables()
+{
+ for (Assoc_iter<String, Symtable*> i(*this); i.ok(); i++) {
+ delete i.val();
+ }
+}
Symbol
Symtable::lookup(String s) const
{
return Assoc<String, Symtable*>::operator[](s);
}
-
-void
-Symtables::read(Text_db &symini)
-{
- while (!symini.eof()) {
- Text_record r(symini++);
- if (r[0] == "end" )
- return;
- assert (r[0] == "table");
-
- String tabnam = r[1];
- Symtable * sp = new Symtable;
- while (!symini.eof()){
- r = symini++;
- if (r[0] == "end")
- break;
-
- if (r.sz() != 6)
- error("Not enough fields in symbol init");
-
- int i=0;
- String id=r[i++];
- String tex=r[i++];
- svec<Real> dims;
- for (int j=0; j < 4; j++)
- dims.add( parse_dimen(r[i++]));
-
- Symbol s(tex, Box(dims));
- (*sp)[id] = s;
- }
- (*this)[tabnam] = sp;
- }
-}