Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

reg_s11n_traits_template2.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 two parameterized types. Works
00004 // with std::map and std::pair-like types, with the appropriate
00005 // proxies. See the various proxy files, like std/map.hpp and
00006 // std/pair.hpp, for how to use it.
00007 //
00008 // Achtung: only suitable for monomorphic or base-most template types.
00009 ////////////////////////////////////////////////////////////////////////
00010 
00011 #ifndef S11N_TEMPLATE_TYPE
00012 #error "You must define S11N_TEMPLATE_TYPE before including this file. e.g., to std::map or std::multimap."
00013 #endif
00014 
00015 #ifndef S11N_TEMPLATE_TYPE_NAME
00016 #error "You must define S11N_TEMPLATE_TYPE_NAME before including this file. e.g., to \"map\" or \"multimap\"."
00017 #endif
00018 
00019 #ifndef S11N_TEMPLATE_TYPE_PROXY
00020 #  error "You must define S11N_TEMPLATE_TYPE_PROXY before including this file. e.g., ::s11n::map::map_serializable_proxy"
00021 #endif
00022 
00023 #ifndef S11N_TEMPLATE_TYPE_DESER_PROXY
00024 #  define S11N_TEMPLATE_TYPE_DESER_PROXY S11N_TEMPLATE_TYPE_PROXY
00025 #endif
00026 
00027 #define S11N_TEMPLATE_TYPE_Q S11N_TEMPLATE_TYPE< KeyT, ValT >
00028 
00029 namespace s11n {
00030 
00031         /**
00032            s11n_traits<> specialization for template types taking two
00033            template parameters, like std::map and std::pair
00034            types. (Yes, std::map can take more, but it is not commonly
00035            used that way.)
00036         */
00037         template <typename KeyT, typename ValT>
00038         struct S11N_EXPORT_API s11n_traits < S11N_TEMPLATE_TYPE_Q >
00039         {
00040                 typedef S11N_TEMPLATE_TYPE_Q serializable_type;
00041                 typedef S11N_TEMPLATE_TYPE_PROXY serialize_functor;
00042                 typedef S11N_TEMPLATE_TYPE_DESER_PROXY deserialize_functor;
00043         typedef ::s11n::default_cleanup_functor< S11N_TEMPLATE_TYPE_Q > cleanup_functor;
00044                 typedef ::s11n::cl::object_factory<serializable_type> factory_type;
00045         static bool cl_reg_placeholder; 
00046         static const std::string class_name( const serializable_type * instance_hint )
00047         {
00048             if( cl_reg_placeholder == true ); // just to reference it. w/o this cl reg never happens :(
00049             return S11N_TEMPLATE_TYPE_NAME;
00050         }
00051         };
00052     template <
00053         typename KeyT,
00054         typename ValT
00055         >
00056     bool s11n_traits<
00057         S11N_TEMPLATE_TYPE_Q
00058         >::cl_reg_placeholder = (
00059                      ::s11n::cl::classloader_register_base< S11N_TEMPLATE_TYPE_Q >(S11N_TEMPLATE_TYPE_NAME),
00060                       true
00061                       );
00062 
00063 
00064 } // namespace s11n
00065 
00066 
00067 #undef S11N_TEMPLATE_TYPE_Q
00068 #undef S11N_TEMPLATE_TYPE_PROXY
00069 #undef S11N_TEMPLATE_TYPE_DESER_PROXY
00070 #undef S11N_TEMPLATE_TYPE_NAME
00071 #undef S11N_TEMPLATE_TYPE

Generated on Sun Dec 25 20:34:56 2005 for libs11n-1.2.3 by  doxygen 1.4.4