reg_s11n_traits_template4.hpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////
00002 // A supermacro to generate some partial template specializations for
00003 // s11n-proxying class templates taking four parameterized types.
00004 // See the various proxy files, like std/map.hpp and
00005 // std/pair.hpp, for how to use it.
00006 //
00007 // Achtung: only suitable for monomorphic or base-most template types.
00008 ////////////////////////////////////////////////////////////////////////
00009 
00010 #ifndef S11N_TEMPLATE_TYPE
00011 #error "You must define S11N_TEMPLATE_TYPE before including this file. e.g., to std::map or std::multimap."
00012 #endif
00013 
00014 #ifndef S11N_TEMPLATE_TYPE_NAME
00015 #error "You must define S11N_TEMPLATE_TYPE_NAME before including this file. e.g., to \"map\" or \"multimap\"."
00016 #endif
00017 
00018 #ifndef S11N_TEMPLATE_TYPE_PROXY
00019 #  error "You must define S11N_TEMPLATE_TYPE_PROXY before including this file. e.g., ::s11n::map::map_serializable_proxy"
00020 #endif
00021 
00022 #ifndef S11N_TEMPLATE_TYPE_DESER_PROXY
00023 #  define S11N_TEMPLATE_TYPE_DESER_PROXY S11N_TEMPLATE_TYPE_PROXY
00024 #endif
00025 
00026 ////////////////////////////////////////////////////////////////////////
00027 // The S11N_TEMPLATE_TYPENAME_Tn macros are used when one or more of
00028 // the template parameters are concrete types, as opposed to typenames.
00029 // Define any of S11N_TEMPLATE_TYPENAME_Tn to a type name, e.g.:
00030 // #  define S11N_TEMPLATE_TYPENAME_T3 unsigned int
00031 ////////////////////////////////////////////////////////////////////////
00032 
00033 #ifndef S11N_TEMPLATE_TYPENAME_T1
00034 #  define S11N_TEMPLATE_TYPENAME_T1 typename
00035 #endif
00036 
00037 #ifndef S11N_TEMPLATE_TYPENAME_T2
00038 #  define S11N_TEMPLATE_TYPENAME_T2 typename
00039 #endif
00040 
00041 #ifndef S11N_TEMPLATE_TYPENAME_T3
00042 #  define S11N_TEMPLATE_TYPENAME_T3 typename
00043 #endif
00044 
00045 #ifndef S11N_TEMPLATE_TYPENAME_T4
00046 #  define S11N_TEMPLATE_TYPENAME_T4 typename
00047 #endif
00048 
00049 #define S11N_TEMPLATE_TYPE_Q S11N_TEMPLATE_TYPE< T1, T2, T3, T4 >
00050 
00051 namespace s11n {
00052 
00053         /**
00054            s11n_traits<> specialization for template types taking four
00055            template parameters.
00056         */
00057         template <S11N_TEMPLATE_TYPENAME_T1 T1, S11N_TEMPLATE_TYPENAME_T2 T2, S11N_TEMPLATE_TYPENAME_T3 T3, S11N_TEMPLATE_TYPENAME_T4 T4>
00058         struct S11N_EXPORT_API s11n_traits < S11N_TEMPLATE_TYPE_Q >
00059         {
00060                 typedef S11N_TEMPLATE_TYPE_Q serializable_type;
00061                 typedef S11N_TEMPLATE_TYPE_PROXY serialize_functor;
00062                 typedef S11N_TEMPLATE_TYPE_DESER_PROXY deserialize_functor;
00063         typedef ::s11n::default_cleanup_functor< S11N_TEMPLATE_TYPE_Q > cleanup_functor;
00064                 typedef ::s11n::cl::object_factory<serializable_type> factory_type;
00065         static bool cl_reg_placeholder; 
00066         static const std::string class_name( const serializable_type * instance_hint )
00067         {
00068             if( cl_reg_placeholder == true ); // just to reference it. w/o this cl reg never happens :(
00069             return S11N_TEMPLATE_TYPE_NAME;
00070         }
00071         };
00072     template <
00073         S11N_TEMPLATE_TYPENAME_T1 T1,
00074         S11N_TEMPLATE_TYPENAME_T2 T2,
00075         S11N_TEMPLATE_TYPENAME_T3 T3,
00076         S11N_TEMPLATE_TYPENAME_T4 T4
00077         >
00078     bool s11n_traits<
00079         S11N_TEMPLATE_TYPE_Q
00080         >::cl_reg_placeholder = (
00081                      ::s11n::cl::classloader_register_base< S11N_TEMPLATE_TYPE_Q >(S11N_TEMPLATE_TYPE_NAME),
00082                       true
00083                       );
00084 
00085 } // namespace s11n
00086 
00087 
00088 #undef S11N_TEMPLATE_TYPE_Q
00089 #undef S11N_TEMPLATE_TYPE_PROXY
00090 #undef S11N_TEMPLATE_TYPE_DESER_PROXY
00091 #undef S11N_TEMPLATE_TYPE_NAME
00092 #undef S11N_TEMPLATE_TYPE
00093 #undef S11N_TEMPLATE_TYPENAME_T1
00094 #undef S11N_TEMPLATE_TYPENAME_T2
00095 #undef S11N_TEMPLATE_TYPENAME_T3
00096 #undef S11N_TEMPLATE_TYPENAME_T4

Generated on Sun Apr 27 13:16:04 2008 for libs11n by  doxygen 1.5.3