00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __SEQ_HH
00018 # define __SEQ_HH
00019
00020 # include "../strategies.hh"
00021
00022 namespace aurelia {
00023
00024 template <typename Strat1, typename Strat2>
00025 struct seq_strategy;
00026
00030 template <typename Strat1, typename Strat2, typename T>
00031 struct strategy_model<seq_strategy<Strat1, Strat2>, T, false> {
00032 struct model {
00033 typedef typename strategy_model<Strat1, T>::model model1;
00034 typedef typename strategy_model<Strat2, typename model1::output>::model
00035 model2;
00036
00037 typedef typename strategy_concept<model1>::check require1;
00038 typedef typename strategy_concept<model2>::check require2;
00039
00040 typedef seq_strategy<Strat1, Strat2> strat;
00041 typedef T input;
00042 typedef typename model2::output output;
00043 };
00044 };
00045
00048 template <typename Strat1, typename Strat2>
00049 struct seq_strategy {
00050 private:
00051 Strat1 s1;
00052 Strat2 s2;
00053 public:
00054 seq_strategy(const Strat1& s1, const Strat2& s2): s1(s1), s2(s2) {
00055 }
00056
00057 template <typename T>
00058 typename strategy_model<seq_strategy<Strat1, Strat2>, T>::model::output
00059 operator()(const T& term) const {
00060 return s2(s1(term));
00061 }
00062 };
00063
00068 template <typename Strat1, typename Strat2>
00069 seq_strategy<Strat1, Strat2> operator<(const Strat1& s1, const Strat2& s2) {
00070 return seq_strategy<Strat1, Strat2>(s1, s2);
00071 }
00072
00073 }
00074
00075 #endif