Go to Overview over all GrAL packages.
Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Container/function-adapter.h

Go to the documentation of this file.
00001 #ifndef NMWR_GB_FUNCTION_ADAPTER_H
00002 #define NMWR_GB_FUNCTION_ADAPTER_H
00003 
00004 
00005 // $LICENSE
00006 
00007 #include "Utility/pre-post-conditions.h"
00008 
00044 template<class F>
00045 class unary_fct_ref {
00046 private:
00047   const F* f;
00048 public:
00049   typedef typename F::argument_type argument_type;
00050   typedef typename F::result_type   result_type;
00051 
00052   unary_fct_ref() :            f(0) {}
00053   unary_fct_ref(const F& ff) : f(&ff) {}
00054 
00055   result_type operator()(const argument_type& x) const  { 
00056     REQUIRE((f != 0), "No function!\n",1);
00057     return (*f)(x);
00058   }
00059 };
00060 
00064 template<class F>
00065 inline unary_fct_ref<F> make_unary_fct_ref(const F& f) 
00066 { return unary_fct_ref<F>(f); }
00067 
00068 
00079 template<class M1, class M2>
00080 class unary_map_composition {
00081 private:
00082   M1 const* m1;
00083   M2 const* m2;
00084 
00085 public:
00086   typedef typename M2::argument_type argument_type;
00087   typedef typename M1::result_type   result_type;
00088   typedef typename M2::domain_type   domain_type;
00089   typedef typename M1::range_type    range_type;
00090 
00092   unary_map_composition(M1 const& mm1,M2 const& mm2) : m1(&mm1), m2(&mm2) {}
00093 
00095   result_type operator()(argument_type const& x) const { return (*m1)((*m2)(x));}
00096 
00102   domain_type const& domain() const { return m2->domain();}
00103   
00105   range_type  const& range()  const { return m1->range();}
00106 };
00107 
00108 
00112 template<class M1, class M2>
00113 inline
00114 unary_map_composition<M1,M2>
00115 compose_map( M1 const& m1, M2 const& m2)
00116 { return unary_map_composition<M1,M2>(m1,m2);}
00117  
00118 
00119 /*
00120 template<class Map>
00121 class set_value_mutator {
00122 private:
00123   typedef typename Map::value_type value_type;
00124   typedef typename Map::index_type index_type;
00125   Map* m;
00126   value_type t;
00127   
00128 public:
00129   set_value_mutator(Map& mm, const value_type& tt) : m(&mm), t(tt) {}
00130   void operator()(const index_type& i) { (*m)[i] = t;}
00131 };
00132 */
00133 
00134 #endif
00135 

Copyright (c) Guntram Berti 1997-2002. See the GrAL Homepage for up-to-date information.

Generated at Tue Feb 26 15:57:14 2002 for Sequence by doxygen 1.2.11-20011104 written by Dimitri van Heesch, © 1997-2000