00001 // $Id: Converter.h,v 1.1.1.1 2005/10/17 06:11:40 maqm Exp $ 00002 // 00003 // Original author: Sawyer Gillespie 00004 // hgillesp@u.washington.edu 00005 // 00006 00007 #ifndef _H_Converter_facilities_ 00008 #define _H_Converter_facilities_ 00009 00010 // class Converter 00011 // Template class to define the converter behavior. This is really just 00012 // specifying a pattern. 00013 // 00014 template <class Ty1, class Ty2> 00015 class Converter { 00016 public: 00017 // type declarations 00018 typedef Ty1 source; 00019 typedef Ty2 destination; 00020 00021 // declare the forward method 00022 inline destination* operator (const source&) const; 00023 00024 protected: 00025 // do the actual conversion here 00026 virtual destination* convert (const source&) const = 0; 00027 }; 00028 00029 // inline declarations 00030 00031 template <class Ty1, class Ty2> 00032 inline Converter<Ty1,Ty2>::destination* 00033 Converter<Ty1,Ty2>::operator () (const Converter<Ty1,Ty2>::source& s) const 00034 { 00035 return convert (s); 00036 } 00037 00038 #endif // _H_Converter_facilities_