00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <stdlib.h>
00035
00036 #define DEBUG_REG 0
00037 #if DEBUG_REG
00038 # include <s11n.net/s11n/s11n_debuggering_macros.hpp>
00039 #endif
00040
00041
00042 #ifndef SERIALIZER_TYPE
00043 # error "SERIALIZER_TYPE is not set. Set it to the type you want to proxy before including this file!"
00044 #endif
00045
00046 #ifndef SERIALIZER_NAME
00047 # error "SERIALIZER_NAME must be set to the string form of SERIALIZER_TYPE"
00048 #endif
00049
00050 #ifndef SERIALIZER_BASE
00051 # error "SERIALIZER_BASE must be the base-most type of SERIALIZER_TYPE (may be the same)."
00052 #endif
00053
00054 #include <s11n.net/s11n/classload.hpp>
00055
00056 namespace {
00057
00058
00059
00060 #ifndef s11n_SERIALIZER_REG_CONTEXT_DEFINED
00061 #define s11n_SERIALIZER_REG_CONTEXT_DEFINED 1
00062
00063
00064
00065
00066
00067
00068
00069 template <typename Context>
00070 struct serializer_reg_context
00071 {
00072 typedef Context context;
00073 static bool placeholder;
00074 static void reg()
00075 {
00076 CERR << "ACHTUNG: serializer_reg_context<context> >()"
00077 << " is not specialized, which means that registration hasn't been done.\n"
00078 << "For instructions see: " << __FILE__ << "\n";
00079 abort();
00080 }
00081 };
00082 template <typename Context> bool serializer_reg_context<Context>::placeholder = false;
00083 #endif
00084
00085
00086
00087 template <>
00088 struct serializer_reg_context< SERIALIZER_TYPE >
00089 {
00090 typedef SERIALIZER_TYPE context;
00091 static bool placeholder;
00092 static void reg()
00093 {
00094 std::string cname = SERIALIZER_NAME;
00095 #if DEBUG_REG
00096 CERR << "\nRegistering Serializer: " << cname << "\n"
00097 # ifdef SERIALIZER_MAGIC_COOKIE
00098 << "cookie="<< SERIALIZER_MAGIC_COOKIE << "\n"
00099 # endif
00100 # ifdef SERIALIZER_ALIAS
00101 << "alias="<< SERIALIZER_ALIAS << "\n"
00102 # endif
00103 ;
00104 #endif // DEBUG_REG
00105
00106 #ifdef SERIALIZER_ABSTRACT
00107 ::s11n::cl::classloader_register_abstract< SERIALIZER_BASE >( cname );
00108 # undef SERIALIZER_ABSTRACT
00109 #else
00110 ::s11n::cl::classloader_register< SERIALIZER_BASE, SERIALIZER_TYPE >( cname );
00111 #endif
00112 #ifdef SERIALIZER_MAGIC_COOKIE
00113 ::s11n::cl::classloader_alias< SERIALIZER_BASE >( SERIALIZER_MAGIC_COOKIE, cname );
00114 # undef SERIALIZER_MAGIC_COOKIE
00115 #endif
00116 #ifdef SERIALIZER_ALIAS
00117 ::s11n::cl::classloader_alias< SERIALIZER_BASE >( SERIALIZER_ALIAS, cname );
00118 # undef SERIALIZER_ALIAS
00119 #endif
00120 }
00121 };
00122
00123 bool serializer_reg_context< SERIALIZER_TYPE >::placeholder = (
00124 serializer_reg_context< SERIALIZER_TYPE >::reg()
00125 ,
00126 true
00127 );
00128
00129 }
00130
00131
00132
00133
00134 #undef SERIALIZER_TYPE
00135 #undef SERIALIZER_NAME
00136 #undef DEBUG_REG