From: Mukund Sivaraman Date: Tue, 27 Nov 2012 04:27:19 +0000 (+0530) Subject: [2497] Add a new RdataFactory class which includes the new create() impl X-Git-Tag: bind10-1.0.0-beta-release~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=331d377c8fc5f5a1876cbe52ca714b2a002bb103;p=thirdparty%2Fkea.git [2497] Add a new RdataFactory class which includes the new create() impl Also code to gen-rdatacode.py to optionally use the new RdataFactory for some types if configured to do so. --- diff --git a/src/lib/dns/gen-rdatacode.py.in b/src/lib/dns/gen-rdatacode.py.in index e389da2146..9f2258206a 100755 --- a/src/lib/dns/gen-rdatacode.py.in +++ b/src/lib/dns/gen-rdatacode.py.in @@ -28,6 +28,7 @@ re_typecode = re.compile('([\da-z]+)_(\d+)') classcode2txt = {} typecode2txt = {} typeandclass = [] +new_rdatafactory_users = [] generic_code = 65536 # something larger than any code value rdata_declarations = '' class_definitions = '' @@ -271,15 +272,24 @@ def generate_rrparam(fileprefix, basemtime): class_utxt = class_tuple[1].upper() indent = ' ' * 8 typeandclassparams += indent + + # By default, we use OldRdataFactory (see bug #2497). If you + # want to pick RdataFactory for a particular type, add it to + # new_rdatafactory_users. + if type_txt in new_rdatafactory_users: + rdf_class = 'RdataFactory' + else: + rdf_class = 'OldRdataFactory' + if class_tuple[1] != 'generic': typeandclassparams += 'add("' + type_utxt + '", ' typeandclassparams += str(type_code) + ', "' + class_utxt typeandclassparams += '", ' + str(class_code) - typeandclassparams += ', RdataFactoryPtr(new OldRdataFactory<' + typeandclassparams += ', RdataFactoryPtr(new ' + rdf_class + '<' typeandclassparams += class_txt + '::' + type_utxt + '>()));\n' else: typeandclassparams += 'add("' + type_utxt + '", ' + str(type_code) - typeandclassparams += ', RdataFactoryPtr(new OldRdataFactory<' + typeandclassparams += ', RdataFactoryPtr(new ' + rdf_class + '<' typeandclassparams += class_txt + '::' + type_utxt + '>()));\n' rrparam_temp = open(placeholder, 'r') diff --git a/src/lib/dns/rrparamregistry-placeholder.cc b/src/lib/dns/rrparamregistry-placeholder.cc index f3d2b06525..b242d16eeb 100644 --- a/src/lib/dns/rrparamregistry-placeholder.cc +++ b/src/lib/dns/rrparamregistry-placeholder.cc @@ -181,6 +181,19 @@ public: } }; +template +class RdataFactory : public OldRdataFactory { +public: + using OldRdataFactory::create; + + virtual RdataPtr create(MasterLexer& lexer, const Name* origin, + MasterLoader::Options options, + MasterLoaderCallbacks& callbacks) const { + return (RdataPtr(new T(dynamic_cast(lexer, origin, options, + callbacks)))); + } +}; + /// /// \brief The \c RRParamRegistryImpl class is the actual implementation of /// \c RRParamRegistry.