summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-31 21:45:00 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-31 21:45:00 +0100
commit166e885cf6ea7ff4b56d860bc6449c02d03ef5de (patch)
treed5999d2a45e19db11dedc71b310e1aa765d00cad
parent15de0c12ca6393a8c8c849f25a4d016abef0056b (diff)
downloaddabmod-166e885cf6ea7ff4b56d860bc6449c02d03ef5de.tar.gz
dabmod-166e885cf6ea7ff4b56d860bc6449c02d03ef5de.tar.bz2
dabmod-166e885cf6ea7ff4b56d860bc6449c02d03ef5de.zip
Replace quite a few 'new' with make_shared
-rw-r--r--src/DabMod.cpp4
-rw-r--r--src/DabModulator.cpp82
-rw-r--r--src/EtiReader.cpp3
-rw-r--r--src/Flowgraph.cpp8
4 files changed, 43 insertions, 54 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 982a1ee..f250850 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -164,7 +164,7 @@ int launch_modulator(int argc, char* argv[])
unsigned tist_delay_stages = 0;
double tist_offset_s = 0.0;
- shared_ptr<Flowgraph> flowgraph(new Flowgraph());
+ auto flowgraph = make_shared<Flowgraph>();
shared_ptr<FormatConverter> format_converter;
shared_ptr<ModOutput> output;
@@ -174,7 +174,7 @@ int launch_modulator(int argc, char* argv[])
InputFileReader inputFileReader;
#if defined(HAVE_ZEROMQ)
- shared_ptr<InputZeroMQReader> inputZeroMQReader(new InputZeroMQReader());
+ auto inputZeroMQReader = make_shared<InputZeroMQReader>();
#endif
struct sigaction sa;
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<PrbsGenerator> cifPrbs(new PrbsGenerator(864 * 8, 0x110));
- shared_ptr<FrameMultiplexer> cifMux(
- new FrameMultiplexer(myFicSizeOut + 864 * 8,
- &myEtiReader.getSubchannels()));
+ auto cifPrbs = make_shared<PrbsGenerator>(864 * 8, 0x110);
+ auto cifMux = make_shared<FrameMultiplexer>(
+ myFicSizeOut + 864 * 8, &myEtiReader.getSubchannels());
- shared_ptr<BlockPartitioner> cifPart(
- new BlockPartitioner(mode, myEtiReader.getFp()));
+ auto cifPart = make_shared<BlockPartitioner>(mode, myEtiReader.getFp());
- shared_ptr<QpskSymbolMapper> cifMap(new QpskSymbolMapper(myNbCarriers));
- shared_ptr<PhaseReference> cifRef(new PhaseReference(mode));
- shared_ptr<FrequencyInterleaver> cifFreq(new FrequencyInterleaver(mode));
- shared_ptr<DifferentialModulator> cifDiff(
- new DifferentialModulator(myNbCarriers));
+ auto cifMap = make_shared<QpskSymbolMapper>(myNbCarriers);
+ auto cifRef = make_shared<PhaseReference>(mode);
+ auto cifFreq = make_shared<FrequencyInterleaver>(mode);
+ auto cifDiff = make_shared<DifferentialModulator>(myNbCarriers);
- shared_ptr<NullSymbol> cifNull(new NullSymbol(myNbCarriers));
- shared_ptr<SignalMultiplexer> cifSig(new SignalMultiplexer(
- (1 + myNbSymbols) * myNbCarriers * sizeof(complexf)));
+ auto cifNull = make_shared<NullSymbol>(myNbCarriers);
+ auto cifSig = make_shared<SignalMultiplexer>(
+ (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<CicEqualizer> cifCicEq(new CicEqualizer(myNbCarriers,
- (float)mySpacing * (float)myOutputRate / 2048000.0f,
- cic_ratio));
+ auto cifCicEq = make_shared<CicEqualizer>(
+ myNbCarriers,
+ (float)mySpacing * (float)myOutputRate / 2048000.0f, cic_ratio);
shared_ptr<TII> 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<OfdmGenerator> cifOfdm(
- new OfdmGenerator((1 + myNbSymbols), myNbCarriers, mySpacing));
+ auto cifOfdm = make_shared<OfdmGenerator>(
+ (1 + myNbSymbols), myNbCarriers, mySpacing);
- shared_ptr<GainControl> cifGain(
- new GainControl(mySpacing, myGainMode, myDigGain, myNormalise));
+ auto cifGain = make_shared<GainControl>(
+ mySpacing, myGainMode, myDigGain, myNormalise);
cifGain->enrol_at(*myRCs);
- shared_ptr<GuardIntervalInserter> cifGuard(
- new GuardIntervalInserter(myNbSymbols, mySpacing,
- myNullSize, mySymSize));
+ auto cifGuard = make_shared<GuardIntervalInserter>(
+ myNbSymbols, mySpacing, myNullSize, mySymSize);
shared_ptr<FIRFilter> cifFilter;
if (myFilterTapsFilename != "") {
cifFilter = make_shared<FIRFilter>(myFilterTapsFilename);
cifFilter->enrol_at(*myRCs);
}
- shared_ptr<OutputMemory> myOutput(new OutputMemory(dataOut));
+ auto myOutput = make_shared<OutputMemory>(dataOut);
- Resampler* cifRes = NULL;
+ shared_ptr<Resampler> cifRes;
if (myOutputRate != 2048000) {
- cifRes = new Resampler(2048000, myOutputRate, mySpacing);
+ cifRes = make_shared<Resampler>(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<PrbsGenerator> ficPrbs(new PrbsGenerator(myFicSizeIn, 0x110));
+ auto ficPrbs = make_shared<PrbsGenerator>(myFicSizeIn, 0x110);
// Configuring convolutionnal encoder
- shared_ptr<ConvEncoder> ficConv(new ConvEncoder(myFicSizeIn));
+ auto ficConv = make_shared<ConvEncoder>(myFicSizeIn);
// Configuring puncturing encoder
- shared_ptr<PuncturingEncoder> ficPunc(new PuncturingEncoder());
+ auto ficPunc = make_shared<PuncturingEncoder>();
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<PrbsGenerator> subchPrbs(
- new PrbsGenerator(subchSizeIn, 0x110));
+ auto subchPrbs = make_shared<PrbsGenerator>(subchSizeIn, 0x110);
// Configuring convolutionnal encoder
- shared_ptr<ConvEncoder> subchConv(
- new ConvEncoder(subchSizeIn));
+ auto subchConv = make_shared<ConvEncoder>(subchSizeIn);
// Configuring puncturing encoder
- shared_ptr<PuncturingEncoder> subchPunc(
- new PuncturingEncoder());
+ auto subchPunc = make_shared<PuncturingEncoder>();
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<TimeInterleaver> subchInterleaver(
- new TimeInterleaver(subchSizeOut));
+ auto subchInterleaver = make_shared<TimeInterleaver>(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<Resampler> 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<Resampler> 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);
}
diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp
index 3171a91..16272e3 100644
--- a/src/EtiReader.cpp
+++ b/src/EtiReader.cpp
@@ -174,8 +174,7 @@ int EtiReader::process(const Buffer* dataIn)
mySources.clear();
for (unsigned i = 0; i < eti_fc.NST; ++i) {
- mySources.push_back(shared_ptr<SubchannelSource>(
- new SubchannelSource(eti_stc[i])));
+ mySources.push_back(make_shared<SubchannelSource>(eti_stc[i]));
PDEBUG("Sstc %u:\n", i);
PDEBUG(" Stc%i.scid: %i\n", i, eti_stc[i].SCID);
PDEBUG(" Stc%i.sad: %u\n", i, eti_stc[i].getStartAddress());
diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp
index e4c6a30..8e76cae 100644
--- a/src/Flowgraph.cpp
+++ b/src/Flowgraph.cpp
@@ -77,7 +77,7 @@ Edge::Edge(shared_ptr<Node>& srcNode, shared_ptr<Node>& dstNode) :
dstNode->plugin()->name(), dstNode.get(),
this);
- myBuffer = shared_ptr<Buffer>(new Buffer());
+ myBuffer = make_shared<Buffer>();
srcNode->myOutputBuffers.push_back(myBuffer);
dstNode->myInputBuffers.push_back(myBuffer);
}
@@ -177,7 +177,7 @@ void Flowgraph::connect(shared_ptr<ModPlugin> input, shared_ptr<ModPlugin> outpu
}
}
if (inputNode == nodes.end()) {
- inputNode = nodes.insert(nodes.end(), shared_ptr<Node>(new Node(input)));
+ inputNode = nodes.insert(nodes.end(), make_shared<Node>(input));
}
for (outputNode = nodes.begin(); outputNode != nodes.end(); ++outputNode) {
@@ -186,7 +186,7 @@ void Flowgraph::connect(shared_ptr<ModPlugin> input, shared_ptr<ModPlugin> outpu
}
}
if (outputNode == nodes.end()) {
- outputNode = nodes.insert(nodes.end(), shared_ptr<Node>(new Node(output)));
+ outputNode = nodes.insert(nodes.end(), make_shared<Node>(output));
for (inputNode = nodes.begin(); inputNode != nodes.end(); ++inputNode) {
if ((*inputNode)->plugin() == input) {
break;
@@ -206,7 +206,7 @@ void Flowgraph::connect(shared_ptr<ModPlugin> input, shared_ptr<ModPlugin> outpu
assert((*inputNode)->plugin() == input);
assert((*outputNode)->plugin() == output);
- edges.push_back(shared_ptr<Edge>(new Edge(*inputNode, *outputNode)));
+ edges.push_back(make_shared<Edge>(*inputNode, *outputNode));
}