]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/identifier.hh
02587ce9788138e74c767052f1a8f2c22cf8cec4
[lilypond.git] / lily / include / identifier.hh
1 /*
2   identifier.hh -- part of GNU LilyPond
3
4   (c) 1996--2000 Han-Wen Nienhuys
5 */
6
7 #ifndef IDENTIFIER_HH
8 #define IDENTIFIER_HH
9
10 #include "lily-proto.hh"
11 #include "lily-guile.hh"
12 #include "string.hh"
13 #include "input.hh"
14 #include "virtual-methods.hh"
15 #include "smobs.hh"
16
17
18 class Translator_group_identifier;
19 class Output_def_identifier;
20 class Score_identifier;
21 class Duration_identifier;
22
23
24
25 #define IDACCESSOR(Class)\
26 virtual Class *  access_content_ ## Class (bool) const { error (#Class  + String ("_identifier")); return 0; }\
27
28
29 /**
30    A declarable data structure in mudela.
31
32    TODO: use SMOBS for the union type, and junk all derived classes.
33    */
34 struct Identifier : public Input {
35
36   bool init_b_;
37   bool accessed_b_;
38   int token_code_i_;
39   Identifier (Identifier const&);    
40   Identifier (int code) ;
41
42   void print() const;
43   
44   void error (String) const;
45   String str () const;
46   IDACCESSOR(Translator_group)
47   IDACCESSOR(Music_output_def)
48   IDACCESSOR(Score)
49   IDACCESSOR(Duration)
50   VIRTUAL_COPY_CONS(Identifier);
51
52   DECLARE_SMOBS(Identifier, foo);
53 protected:
54   virtual void do_print () const;
55   virtual String do_str () const;
56 };
57
58 #define DECLARE_ID_CLASS(Class) \
59 struct Class ## _identifier : Identifier {\
60                              Class *data_p_;                 \
61                               \
62                              Class ## _identifier (Class ## _identifier const&);\
63                              Class ## _identifier (Class*st, int code);\
64                              VIRTUAL_COPY_CONS(Identifier);\
65                              virtual Class* access_content_ ## Class (bool copy_b) const;\
66                              ~Class ## _identifier();\
67                              virtual void do_print () const; \
68                              virtual String do_str () const; \
69 }\
70
71
72 DECLARE_ID_CLASS(Translator_group);
73 DECLARE_ID_CLASS(Duration);
74 DECLARE_ID_CLASS(Score);
75 DECLARE_ID_CLASS(Music_output_def);
76
77 Identifier * unsmob_identifier (SCM);
78 SCM smobify (Identifier*);
79
80 #endif // IDENTIFIER_HH
81