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