src/work/alpar/named-param-test4.cc
changeset 1365 c280de819a73
parent 1364 ee5959aa4410
child 1366 d00b85f8be45
     1.1 --- a/src/work/alpar/named-param-test4.cc	Sun Apr 17 18:57:22 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,158 +0,0 @@
     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 -  int _intAdat;
    1.66 -public:
    1.67 -  Algorithm() {};
    1.68 -  Algorithm(const T &tt) : T(tt) {};
    1.69 -
    1.70 -  template<class X> class _SetAdat : public T {
    1.71 -    protected:
    1.72 -    X adat;
    1.73 -    public:
    1.74 -    typedef X Adat;
    1.75 -    _SetAdat() {}; //"Algorithm<>::_SetAdat<double> b;"-hez kell!!!!
    1.76 -                   // De az is rossz!!!!!
    1.77 -    _SetAdat(const T &t,const X& x) : T(t), adat(x) {};
    1.78 -  };
    1.79 -  
    1.80 - ///\name Funtion Named Parameters
    1.81 -  
    1.82 -  ///@{
    1.83 -
    1.84 -  ///\e
    1.85 -  
    1.86 -  ///\e
    1.87 -  ///
    1.88 -  template<class X>
    1.89 -  Algorithm<_SetAdat<X> > setAdat(const X &x) {
    1.90 -    return Algorithm<_SetAdat<X> >(_SetAdat<X>(*this,x));
    1.91 -  }
    1.92 -
    1.93 -  ///@}
    1.94 -  ///\name Named Parameters
    1.95 -  
    1.96 -  ///@{
    1.97 -
    1.98 -  ///\e
    1.99 -  
   1.100 -  ///\e
   1.101 -  ///
   1.102 -  template<class X>
   1.103 -  class SetAdat :
   1.104 -    public Algorithm<AlgorithmDefaultDataFields<
   1.105 -    typename T::TypeTraits::template SetAdat<X> > >
   1.106 -  {};
   1.107 -  
   1.108 -  ///@}  
   1.109 -
   1.110 -///\e
   1.111 -
   1.112 -///\e
   1.113 -///
   1.114 -  Algorithm &setIntAdat(int i) {_intAdat=i;return *this;}
   1.115 -  //vagy:
   1.116 -///Vagy
   1.117 -
   1.118 -///Vagy...
   1.119 -///
   1.120 -  Algorithm &intAdat(int i) {_intAdat=i;return *this;}
   1.121 -  
   1.122 -  //Maga az algoritmus!!!!!!!
   1.123 -///\e
   1.124 -
   1.125 -///\e
   1.126 -///
   1.127 -  typename T::Adat run()
   1.128 -  {
   1.129 -    //Itt csinalunk valamit
   1.130 -    return adat;    
   1.131 -  }
   1.132 -
   1.133 -  ~Algorithm()
   1.134 -  {
   1.135 -    //Itt nem csinalunk semmit
   1.136 -  }
   1.137 -};
   1.138 -
   1.139 -///\e
   1.140 -
   1.141 -///\e
   1.142 -///
   1.143 -Algorithm<> algorithm() 
   1.144 -{
   1.145 -  return Algorithm<>();
   1.146 -}
   1.147 -
   1.148 -int main() 
   1.149 -{
   1.150 -  Algorithm<> a;
   1.151 -  a.run();
   1.152 -
   1.153 -//   Algorithm<>::_SetAdat<double> b; b=b;//Ez itt nem az, amit szeretnenk!!! 
   1.154 -//   //  b.run();
   1.155 -  
   1.156 -  Algorithm<>::SetAdat<double> c; //Algorithm<>::Adat<double> c; jobb vo'na
   1.157 -  c.run();
   1.158 -
   1.159 -  algorithm().run();
   1.160 -  algorithm().setAdat(5.2).run();
   1.161 -}