reg_s11n_traits_template1.hpp

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

Generated on Sat Mar 20 12:29:24 2010 for libs11n-1.2.10 by  doxygen 1.6.1