From 166e885cf6ea7ff4b56d860bc6449c02d03ef5de Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 31 Jan 2016 21:45:00 +0100 Subject: Replace quite a few 'new' with make_shared --- src/DabModulator.cpp | 82 +++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 46 deletions(-) (limited to 'src/DabModulator.cpp') diff --git a/src/DabModulator.cpp b/src/DabModulator.cpp index 5219ac4..61e5ce8 100644 --- a/src/DabModulator.cpp +++ b/src/DabModulator.cpp @@ -160,23 +160,20 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut) //////////////////////////////////////////////////////////////// // CIF data initialisation //////////////////////////////////////////////////////////////// - shared_ptr cifPrbs(new PrbsGenerator(864 * 8, 0x110)); - shared_ptr cifMux( - new FrameMultiplexer(myFicSizeOut + 864 * 8, - &myEtiReader.getSubchannels())); + auto cifPrbs = make_shared(864 * 8, 0x110); + auto cifMux = make_shared( + myFicSizeOut + 864 * 8, &myEtiReader.getSubchannels()); - shared_ptr cifPart( - new BlockPartitioner(mode, myEtiReader.getFp())); + auto cifPart = make_shared(mode, myEtiReader.getFp()); - shared_ptr cifMap(new QpskSymbolMapper(myNbCarriers)); - shared_ptr cifRef(new PhaseReference(mode)); - shared_ptr cifFreq(new FrequencyInterleaver(mode)); - shared_ptr cifDiff( - new DifferentialModulator(myNbCarriers)); + auto cifMap = make_shared(myNbCarriers); + auto cifRef = make_shared(mode); + auto cifFreq = make_shared(mode); + auto cifDiff = make_shared(myNbCarriers); - shared_ptr cifNull(new NullSymbol(myNbCarriers)); - shared_ptr cifSig(new SignalMultiplexer( - (1 + myNbSymbols) * myNbCarriers * sizeof(complexf))); + auto cifNull = make_shared(myNbCarriers); + auto cifSig = make_shared( + (1 + myNbSymbols) * myNbCarriers * sizeof(complexf)); // TODO this needs a review bool useCicEq = false; @@ -194,9 +191,9 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut) } } - shared_ptr cifCicEq(new CicEqualizer(myNbCarriers, - (float)mySpacing * (float)myOutputRate / 2048000.0f, - cic_ratio)); + auto cifCicEq = make_shared( + myNbCarriers, + (float)mySpacing * (float)myOutputRate / 2048000.0f, cic_ratio); shared_ptr tii; try { @@ -207,28 +204,27 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut) etiLog.level(error) << "Could not initialise TII: " << e.what(); } - shared_ptr cifOfdm( - new OfdmGenerator((1 + myNbSymbols), myNbCarriers, mySpacing)); + auto cifOfdm = make_shared( + (1 + myNbSymbols), myNbCarriers, mySpacing); - shared_ptr cifGain( - new GainControl(mySpacing, myGainMode, myDigGain, myNormalise)); + auto cifGain = make_shared( + mySpacing, myGainMode, myDigGain, myNormalise); cifGain->enrol_at(*myRCs); - shared_ptr cifGuard( - new GuardIntervalInserter(myNbSymbols, mySpacing, - myNullSize, mySymSize)); + auto cifGuard = make_shared( + myNbSymbols, mySpacing, myNullSize, mySymSize); shared_ptr cifFilter; if (myFilterTapsFilename != "") { cifFilter = make_shared(myFilterTapsFilename); cifFilter->enrol_at(*myRCs); } - shared_ptr myOutput(new OutputMemory(dataOut)); + auto myOutput = make_shared(dataOut); - Resampler* cifRes = NULL; + shared_ptr cifRes; if (myOutputRate != 2048000) { - cifRes = new Resampler(2048000, myOutputRate, mySpacing); + cifRes = make_shared(2048000, myOutputRate, mySpacing); } else { fprintf(stderr, "No resampler\n"); } @@ -254,13 +250,13 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut) PDEBUG(" Framesize: %zu\n", fic->getFramesize()); // Configuring prbs generator - shared_ptr ficPrbs(new PrbsGenerator(myFicSizeIn, 0x110)); + auto ficPrbs = make_shared(myFicSizeIn, 0x110); // Configuring convolutionnal encoder - shared_ptr ficConv(new ConvEncoder(myFicSizeIn)); + auto ficConv = make_shared(myFicSizeIn); // Configuring puncturing encoder - shared_ptr ficPunc(new PuncturingEncoder()); + auto ficPunc = make_shared(); for (const auto *rule : fic->get_rules()) { PDEBUG(" Adding rule:\n"); PDEBUG(" Length: %zu\n", rule->length()); @@ -311,16 +307,13 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut) subchannel->protectionOption()); // Configuring prbs genrerator - shared_ptr subchPrbs( - new PrbsGenerator(subchSizeIn, 0x110)); + auto subchPrbs = make_shared(subchSizeIn, 0x110); // Configuring convolutionnal encoder - shared_ptr subchConv( - new ConvEncoder(subchSizeIn)); + auto subchConv = make_shared(subchSizeIn); // Configuring puncturing encoder - shared_ptr subchPunc( - new PuncturingEncoder()); + auto subchPunc = make_shared(); for (const auto& rule : subchannel->get_rules()) { PDEBUG(" Adding rule:\n"); @@ -332,8 +325,7 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut) subchPunc->append_tail_rule(PuncturingRule(3, 0xcccccc)); // Configuring time interleaver - shared_ptr subchInterleaver( - new TimeInterleaver(subchSizeOut)); + auto subchInterleaver = make_shared(subchSizeOut); myFlowgraph->connect(subchannel, subchPrbs); myFlowgraph->connect(subchPrbs, subchConv); @@ -364,19 +356,17 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut) if (cifFilter) { myFlowgraph->connect(cifGuard, cifFilter); - if (cifRes != NULL) { - shared_ptr res(cifRes); - myFlowgraph->connect(cifFilter, res); - myFlowgraph->connect(res, myOutput); + if (cifRes) { + myFlowgraph->connect(cifFilter, cifRes); + myFlowgraph->connect(cifRes, myOutput); } else { myFlowgraph->connect(cifFilter, myOutput); } } else { //no filtering - if (cifRes != NULL) { - shared_ptr res(cifRes); - myFlowgraph->connect(cifGuard, res); - myFlowgraph->connect(res, myOutput); + if (cifRes) { + myFlowgraph->connect(cifGuard, cifRes); + myFlowgraph->connect(cifRes, myOutput); } else { myFlowgraph->connect(cifGuard, myOutput); } -- cgit v1.2.3