00001 #ifndef DCHAIN_MAKERTRAIT_H 00002 #define DCHAIN_MAKERTRAIT_H 00003 // -*- C++ -*- 00004 // 00005 // Package: <DChain> 00006 // Module: MakerTrait 00007 // 00016 // 00017 // Author: Chris D Jones 00018 // Created: Thu Jan 5 15:37:46 EST 2006 00019 // $Id: MakerTrait.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $ 00020 // 00021 // Revision history 00022 // 00023 // $Log: MakerTrait.h,v $ 00024 // Revision 1.1.1.1 2009/03/03 06:06:56 maqm 00025 // first import of DecayChain 00026 // 00027 // Revision 1.1 2006/01/11 20:28:09 cdj 00028 // massive class renaming, addition of [] for selection and unit tests 00029 // 00030 00031 // system include files 00032 00033 // user include files 00034 00035 // forward declarations 00036 namespace dchain { 00037 template<class T> 00038 struct NewMaker { 00039 00040 typedef ReferenceHolderBase<T*, T&> result_type; 00041 00042 template<class U> 00043 result_type operator()(const U& iU) const { 00044 return result_type(new T(iU)); 00045 } 00046 }; 00047 00048 template<class T> 00049 struct MakerTrait { 00050 typedef NewMaker<T> maker_type; 00051 }; 00052 00053 template<class T> 00054 struct ResultTypeTrait { 00055 typedef typename T::result_type type; 00056 }; 00057 00058 template<class TReturn, class TArg> 00059 struct ResultTypeTrait< TReturn (*)(const TArg&)> { 00060 typedef TReturn type; 00061 }; 00062 00063 } 00064 // inline function definitions 00065 00066 00067 #endif /* DCHAIN_MAKERTRAIT_H */