reg_serializer.h
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
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #include <stdlib.h>
00052
00053 #define DEBUG_REG 0
00054 #if DEBUG_REG
00055 # include <s11n/debuggering_macros.h>
00056 #endif
00057
00058
00059 #ifndef SERIALIZER_TYPE
00060 # error "SERIALIZER_TYPE is not set. Set it to the type you want to proxy before including this file!"
00061 #endif
00062
00063 #ifndef SERIALIZER_NAME
00064 # error "SERIALIZER_NAME must be set to the string form of SERIALIZER_TYPE"
00065 #endif
00066
00067 #ifndef SERIALIZER_BASE
00068 # error "SERIALIZER_BASE must be the base-most type of SERIALIZER_TYPE (may be the same)."
00069 #endif
00070
00071
00072
00073 namespace {
00074
00075
00076
00077
00078 template <> struct class_name< SERIALIZER_TYPE > {
00079 static const char * name()
00080 {
00081 return SERIALIZER_NAME;
00082 }
00083 };
00084
00085
00086
00087 #ifndef s11n_SERIALIZER_REG_CONTEXT_DEFINED
00088 #define s11n_SERIALIZER_REG_CONTEXT_DEFINED 1
00089
00090
00091
00092
00093
00094
00095
00096 template <typename Context>
00097 struct serializer_reg_context
00098 {
00099 typedef Context context;
00100 static bool placeholder;
00101 static void reg()
00102 {
00103 CERR << "ACHTUNG: << " << ::classname< serializer_reg_context<context> >()
00104 << " is not specialized, which means that registration hasn't been done.\n"
00105 << "For instructions see: " << __FILE__ << "\n";
00106 abort();
00107 }
00108 };
00109 template <typename Context> bool serializer_reg_context<Context>::placeholder = false;
00110 #endif
00111
00112
00113
00114 template <>
00115 struct serializer_reg_context< SERIALIZER_TYPE >
00116 {
00117 typedef SERIALIZER_TYPE context;
00118 static bool placeholder;
00119 static void reg()
00120 {
00121 #if DEBUG_REG
00122 CERR << "\nRegistering Serializer: " << SERIALIZER_NAME << "\n"
00123 << "classname() says: " << ::classname< SERIALIZER_TYPE >() << "\n"
00124 # ifdef SERIALIZER_MAGIC_COOKIE
00125 << "cookie="<< SERIALIZER_MAGIC_COOKIE << "\n"
00126 # endif
00127 # ifdef SERIALIZER_ALIAS
00128 << "alias="<< SERIALIZER_ALIAS << "\n"
00129 # endif
00130 ;
00131 #endif // DEBUG_REG
00132
00133 #ifdef SERIALIZER_ABSTRACT
00134 cllite::register_abstract_base< SERIALIZER_BASE >( ::classname< context >() );
00135 # undef SERIALIZER_ABSTRACT
00136 #else
00137 cllite::register_factory< SERIALIZER_BASE, SERIALIZER_TYPE >( ::classname< context >() );
00138 cllite::register_factory< SERIALIZER_TYPE, SERIALIZER_TYPE >( ::classname< context >() );
00139 #endif
00140 #ifdef SERIALIZER_MAGIC_COOKIE
00141 cllite::alias< SERIALIZER_BASE >( SERIALIZER_MAGIC_COOKIE, ::classname< context >() );
00142 cllite::alias< SERIALIZER_TYPE >( SERIALIZER_MAGIC_COOKIE, ::classname< context >() );
00143 # undef SERIALIZER_MAGIC_COOKIE
00144 #endif
00145 #ifdef SERIALIZER_ALIAS
00146 cllite::alias< SERIALIZER_BASE >( SERIALIZER_ALIAS, ::classname< context >() );
00147 cllite::alias< SERIALIZER_TYPE >( SERIALIZER_ALIAS, ::classname< context >() );
00148 # undef SERIALIZER_ALIAS
00149 #endif
00150 }
00151 };
00152
00153 bool serializer_reg_context< SERIALIZER_TYPE >::placeholder = (
00154 serializer_reg_context< SERIALIZER_TYPE >::reg()
00155 ,
00156 true
00157 );
00158
00159 }
00160
00161
00162
00163
00164 #undef SERIALIZER_TYPE
00165 #undef SERIALIZER_NAME
00166 #undef DEBUG_REG
00167
00168
Generated on Tue Jul 20 10:46:48 2004 for s11n by
1.3.7