1.1 --- a/src/work/alpar/named-param-test4.cc Mon Mar 07 07:53:20 2005 +0000
1.2 +++ b/src/work/alpar/named-param-test4.cc Mon Mar 07 07:57:06 2005 +0000
1.3 @@ -1,24 +1,61 @@
1.4 +///\file
1.5 +///Named template study
1.6 +
1.7 +///\e
1.8 +
1.9 +///\e
1.10 +///
1.11 class AlgorithmDefaultTypes
1.12 {
1.13 public:
1.14 +///\e
1.15 +
1.16 +///\e
1.17 +///
1.18 typedef int Adat;
1.19 };
1.20
1.21 +///\e
1.22 +
1.23 +///\e
1.24 +///
1.25 template<class T = AlgorithmDefaultTypes>
1.26 class AlgorithmTypes : public T
1.27 {
1.28 public:
1.29 +///\e
1.30 +
1.31 +///\e
1.32 +///
1.33 template<class X>
1.34 class SetAdat : public T { X Adat; };
1.35 };
1.36
1.37 +///\e
1.38 +
1.39 +///\e
1.40 +///
1.41 template<class T = AlgorithmTypes<> >
1.42 class AlgorithmDefaultDataFields : public T
1.43 {
1.44 protected:
1.45 +///\e
1.46 +
1.47 +///\e
1.48 +///
1.49 + typedef T TypeTraits; //Jo ez a nev?
1.50 +protected:
1.51 +///\e
1.52 +
1.53 +///\e
1.54 +///
1.55 typename T::Adat adat;
1.56 };
1.57
1.58 +///\e
1.59 +
1.60 +///\e
1.61 +///
1.62 template<class T = AlgorithmDefaultDataFields<> >
1.63 class Algorithm : public T
1.64 {
1.65 @@ -31,31 +68,75 @@
1.66 protected:
1.67 X adat;
1.68 public:
1.69 + typedef X Adat;
1.70 _SetAdat() {}; //"Algorithm<>::_SetAdat<double> b;"-hez kell!!!!
1.71 // De az is rossz!!!!!
1.72 _SetAdat(const T &t,const X& x) : T(t), adat(x) {};
1.73 };
1.74
1.75 + ///\name Funtion Named Parameters
1.76 +
1.77 + ///@{
1.78 +
1.79 + ///\e
1.80 +
1.81 + ///\e
1.82 + ///
1.83 template<class X>
1.84 Algorithm<_SetAdat<X> > setAdat(const X &x) {
1.85 return Algorithm<_SetAdat<X> >(_SetAdat<X>(*this,x));
1.86 }
1.87 +
1.88 + ///@}
1.89 + ///\name Named Parameters
1.90
1.91 + ///@{
1.92 +
1.93 + ///\e
1.94 +
1.95 + ///\e
1.96 + ///
1.97 + template<class X>
1.98 + class SetAdat :
1.99 + public Algorithm<AlgorithmDefaultDataFields<
1.100 + typename T::TypeTraits::template SetAdat<X> > >
1.101 + {};
1.102 +
1.103 + ///@}
1.104 +
1.105 +///\e
1.106 +
1.107 +///\e
1.108 +///
1.109 Algorithm &setIntAdat(int i) {_intAdat=i;return *this;}
1.110 //vagy:
1.111 +///Vagy
1.112 +
1.113 +///Vagy...
1.114 +///
1.115 Algorithm &intAdat(int i) {_intAdat=i;return *this;}
1.116
1.117 + //Maga az algoritmus!!!!!!!
1.118 +///\e
1.119 +
1.120 +///\e
1.121 +///
1.122 typename T::Adat run()
1.123 {
1.124 //Itt csinalunk valamit
1.125 - return typename T::Adat();
1.126 + return adat;
1.127 }
1.128 +
1.129 ~Algorithm()
1.130 {
1.131 //Itt nem csinalunk semmit
1.132 }
1.133 };
1.134
1.135 +///\e
1.136 +
1.137 +///\e
1.138 +///
1.139 Algorithm<> algorithm()
1.140 {
1.141 return Algorithm<>();
1.142 @@ -64,15 +145,14 @@
1.143 int main()
1.144 {
1.145 Algorithm<> a;
1.146 + a.run();
1.147
1.148 - Algorithm<>::_SetAdat<double> b; b=b;//Ez itt nem az, amit szeretnenk!!!
1.149 +// Algorithm<>::_SetAdat<double> b; b=b;//Ez itt nem az, amit szeretnenk!!!
1.150 +// // b.run();
1.151 +
1.152 + Algorithm<>::SetAdat<double> c; //Algorithm<>::Adat<double> c; jobb vo'na
1.153 + c.run();
1.154
1.155 - Algorithm<>::SetAdat<double> c; c=c; //Ez itt nem az, amit szeretnenk!!!
1.156 -
1.157 - a.run();
1.158 - // b.run();
1.159 - // c.run();
1.160 -
1.161 algorithm().run();
1.162 algorithm().setAdat(5.2).run();
1.163 }