box_terms.hh

00001 #ifndef __BOX_TERMS_HH
00002 # define __BOX_TERMS_HH
00003 
00004 # include "../terms/list_terms.hh"
00005 
00006 namespace aurelia {
00007 
00008   struct box;
00009   struct vbox_constr {};
00010   struct hbox_constr {};
00011   struct hvbox_constr {};
00012   struct string_box_constr {};
00013 
00014   pattern_generator<vbox_constr> vbox;
00015   pattern_generator<hbox_constr> hbox;
00016   pattern_generator<hvbox_constr> hvbox;
00017   pattern_generator<string_box_constr> string_box;
00018 
00019   //hs, vs, is
00020   typedef std::tuple<unsigned, unsigned, unsigned> box_conf;
00021 
00022   template <>
00023   struct get_tuple<box, vbox_constr> {
00024     typedef std::tuple<box_conf, list<box> > tuple;
00025   };
00026 
00027   template <>
00028   struct get_tuple<box, hbox_constr> {
00029     typedef std::tuple<box_conf, list<box> > tuple;
00030   };
00031 
00032   template <>
00033   struct get_tuple<box, hvbox_constr> {
00034     typedef std::tuple<box_conf, list<box> > tuple;
00035   };
00036 
00037   template <>
00038   struct get_tuple<box, string_box_constr> {
00039     typedef std::tuple<std::string> tuple;
00040   };
00041 
00042   struct box: public term<box,
00043                           vbox_constr,
00044                           hbox_constr,
00045                           hvbox_constr,
00046                           string_box_constr> {
00047     typedef term<box,
00048                  vbox_constr,
00049                  hbox_constr,
00050                  hvbox_constr,
00051                  string_box_constr> super;
00052     box() = default;
00053     box(const super& other): super(other) {}
00054     box(super&& other): super(std::move(other)) {}
00055   };
00056 
00057   struct vbox_term: public std_term<vbox_term, vbox_constr, box> {
00058     typedef std_term<vbox_term, vbox_constr, box> super;
00059     vbox_term(box_conf c, list<box> l): super(typename super::tuple(c, l)) {}
00060     vbox_term(const vbox_term& other): super(other) {}
00061   };
00062 
00063   template <>
00064   struct build_type<box, vbox_constr> {
00065     typedef vbox_term type;
00066   };
00067 
00068   struct hbox_term: public std_term<hbox_term, hbox_constr, box> {
00069     typedef std_term<hbox_term, hbox_constr, box> super;
00070     hbox_term(box_conf c, list<box> l): super(typename super::tuple(c, l)) {}
00071     hbox_term(const hbox_term& other): super(other) {}
00072   };
00073 
00074   template <>
00075   struct build_type<box, hbox_constr> {
00076     typedef hbox_term type;
00077   };
00078 
00079   struct hvbox_term: public std_term<hvbox_term, hvbox_constr, box> {
00080     typedef std_term<hvbox_term, hvbox_constr, box> super;
00081     hvbox_term(box_conf c, list<box> l): super(typename super::tuple(c, l)) {}
00082     hvbox_term(const hvbox_term& other): super(other) {}
00083   };
00084 
00085   template <>
00086   struct build_type<box, hvbox_constr> {
00087     typedef hvbox_term type;
00088   };
00089 
00090   struct string_box_term: public std_term<string_box_term, string_box_constr, box> {
00091     typedef std_term<string_box_term, string_box_constr, box> super;
00092     string_box_term(std::string s): super(typename super::tuple(s)) {}
00093     string_box_term(const string_box_term& other): super(other) {}
00094   };
00095 
00096   template <>
00097   struct build_type<box, string_box_constr> {
00098     typedef string_box_term type;
00099   };
00100 
00101   template <>
00102   struct term_model<box> {
00103     struct model {
00104       typedef box type;
00105     };
00106   };
00107 
00108 }
00109 
00110 #endif