reg_node_type.hpp

Go to the documentation of this file.
00001 #if 0 // this file is obsolete, as of version 0.9.14
00002 ////////////////////////////////////////////////////////////////////////
00003 // "supermacro" code for registering a Data Node type with
00004 // the built-in Serializers.
00005 //
00006 // License: Public Domain
00007 // Author: stephan@s11n.net
00008 ////////////////////////////////////////////////////////////////////////
00009 // Example usage:
00010 // 
00011 // #define S11N_NODE_TYPE my::node_type
00012 // #define S11N_NODE_TYPE_NAME "my::node_type"
00013 // #include <s11n.net/s11n/reg_node_type.hpp>
00014 //
00015 ////////////////////////////////////////////////////////////////////////
00016 // NOTE: this file does not use a conventional BLAH_H_INCLUDED guard.
00017 // Yes, that's on purpose.
00018 ////////////////////////////////////////////////////////////////////////
00019 
00020 
00021 #ifndef S11N_NODE_TYPE
00022 #    error "S11N_NODE_TYPE is not set. Set it to the type you want to proxy before including this file!"
00023 #endif
00024 
00025 #ifndef S11N_NODE_TYPE_NAME
00026 #    error "S11N_NODE_TYPE_NAME is not set. Set it to the string form of S11N_NODE_TYPE!"
00027 #endif
00028 
00029 
00030 #define S11N_DEFAULT_BASE_SERIALIZER s11n::io::serializer< S11N_NODE_TYPE >
00031 
00032 #define SERIALIZER_TYPE S11N_DEFAULT_BASE_SERIALIZER
00033 #define SERIALIZER_BASE S11N_DEFAULT_BASE_SERIALIZER
00034 #define SERIALIZER_ABSTRACT 1
00035 #define SERIALIZER_NAME ("s11n::io::serializer<" S11N_NODE_TYPE_NAME ">")
00036 #include <s11n.net/s11n/proxy/reg_serializer.hpp>
00037 
00038 #ifndef s11n_REG_NODE_TYPE_FORCE_INSTANTIATION
00039 #define s11n_REG_NODE_TYPE_FORCE_INSTANTIATION 1
00040 
00041 namespace s11n { namespace internal {
00042         /**
00043            This function exists to force instantiations of all
00044            "known" Serializers.  We do this because if they
00045            are registered via client-included header files
00046            they add a huge amount of time to compiles.
00047            Registrations for all Serializers for one NodeType
00048            add about 23 seconds on my 2GHz PC!
00049            
00050            Having this here allows us to compile these at library
00051            compilation time, instead of cutting in to client-side
00052            compilation times.
00053         */
00054         template <typename NodeT>
00055         void serializer_registration_init()
00056         {
00057 
00058 #define SERINST(SerT,CLNM,ALIAS)                                 \
00059                 ::s11n::io::register_serializer< SerT< NodeT > >( CLNM, ALIAS );
00060                 // Set up the built-in Serializers for NodeT...
00061 //                 SERINST(::s11n::io::funxml_serializer,"s11n::io::funxml_serializer","funxml");
00062 //                 SERINST(::s11n::io::parens_serializer,"s11n::io::parens_serializer","parens");
00063 //                 SERINST(::s11n::io::compact_serializer,"s11n::io::compact_serializer","compact");
00064 //                 SERINST(::s11n::io::funtxt_serializer,"s11n::io::funtxt_serializer","funtxt");
00065 //                 SERINST(::s11n::io::simplexml_serializer,"s11n::io::simplexml_serializer","simplexml");
00066 // #if s11n_HAVE_LIBEXPAT
00067 //                 SERINST(::s11n::io::expat_serializer,"s11n::io::expat_serializer","expat");
00068 // #endif
00069 
00070 #undef SERINST
00071         }
00072 
00073 } } // namespace s11n::internal
00074 
00075 namespace {
00076         /**
00077            Acts as a per-NodeType placeholder, to avoid ODR violations.
00078         */
00079         template <typename T>
00080         struct bogus_serializer_placeholder {
00081                 static int placeholder;
00082         };
00083 }
00084 
00085 #endif // s11n_REG_NODE_TYPE_FORCE_INSTANTIATION
00086 
00087 namespace {
00088         int bogus_serializer_placeholder< S11N_NODE_TYPE >::placeholder = 
00089                 ( s11n::internal::serializer_registration_init< S11N_NODE_TYPE > (), 0 );
00090 
00091 }
00092 
00093 
00094 
00095 #undef S11N_NODE_TYPE
00096 #undef S11N_NODE_TYPE_NAME
00097 #undef S11N_DEFAULT_BASE_SERIALIZER
00098 
00099 #endif

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