]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/identifier.hh
release: 1.3.93
[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 Output_def_identifier;
19 class Score_identifier;
20 class Duration_identifier;
21
22
23
24 #define IDACCESSOR(Class)\
25 virtual Class *  access_content_ ## Class (bool) const { error (#Class  + String ("_identifier")); return 0; }\
26
27
28 /**
29    A declarable data structure in mudela.
30
31    TODO: use SMOBS for the union type, and junk all derived classes.
32    */
33 struct Identifier : public Input {
34
35   bool init_b_;
36   bool accessed_b_;
37   int token_code_i_;
38   Identifier (Identifier const&);    
39   Identifier (int code) ;
40
41   void print() const;
42   
43   void error (String) const;
44   String str () const;
45   IDACCESSOR(Music_output_def)
46   IDACCESSOR(Score)
47   IDACCESSOR(Duration)
48   VIRTUAL_COPY_CONS(Identifier);
49
50   DECLARE_SMOBS(Identifier, foo);
51 protected:
52
53   virtual String do_str () const;
54 };
55
56 #define DECLARE_ID_CLASS(Class) \
57 struct Class ## _identifier : Identifier {\
58                              Class *data_p_;                 \
59                               \
60                              Class ## _identifier (Class ## _identifier const&);\
61                              Class ## _identifier (Class*st, int code);\
62                              VIRTUAL_COPY_CONS(Identifier);\
63                              virtual Class* access_content_ ## Class (bool copy_b) const;\
64                              ~Class ## _identifier();\
65                             \
66                              virtual String do_str () const; \
67 }\
68
69
70 DECLARE_ID_CLASS(Duration);
71 DECLARE_ID_CLASS(Score);
72 DECLARE_ID_CLASS(Music_output_def);
73
74 Identifier * unsmob_identifier (SCM);
75 SCM smobify (Identifier*);
76
77 #endif // IDENTIFIER_HH
78