From 31edd6a85f52c855d54594dc9f8ceda694d3ebea Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 1 Aug 2015 17:18:24 +0200 Subject: Switch to C++11, remove boost::shared_ptr --- configure.ac | 10 ++++++---- src/DabMod.cpp | 5 ++--- src/DabModulator.cpp | 6 +++--- src/DabModulator.h | 2 +- src/EtiReader.cpp | 5 +++-- src/EtiReader.h | 6 +++--- src/FIRFilter.cpp | 13 ++++++------- src/FIRFilter.h | 6 +++--- src/Flowgraph.cpp | 4 ++-- src/Flowgraph.h | 29 ++++++++++++++--------------- src/FrameMultiplexer.cpp | 7 +++---- src/FrameMultiplexer.h | 6 +++--- src/InputReader.h | 6 +++--- src/InputZeroMQReader.cpp | 7 +++---- src/OutputUHD.cpp | 3 +-- src/OutputUHD.h | 8 ++++---- src/RemoteControl.h | 2 -- src/TimestampDecoder.cpp | 6 ++---- src/TimestampDecoder.h | 4 ++-- 19 files changed, 64 insertions(+), 71 deletions(-) diff --git a/configure.ac b/configure.ac index 0de0b22..21e5a44 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,8 @@ AC_PROG_INSTALL AC_PROG_CPP AC_PROG_MKDIR_P +AX_CXX_COMPILE_STDCXX_11(noext,mandatory) + EXTRA="" AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Enable debugger symbols])], @@ -94,8 +96,8 @@ AS_IF([test "x$enable_zeromq" = "xyes"], [AC_DEFINE(HAVE_ZEROMQ, [1], [Define if ZeroMQ is enabled]) , AC_CHECK_LIB(zmq, zmq_init, ZMQ_LIBS="-lzmq" ,[AC_MSG_ERROR([ZeroMQ libzmq is required])])]) AS_IF([test "x$enable_debug" = "xno"], - [OPTIM="-O2" DEBUG="" EXTRA="$EXTRA -DNDEBUG"], - [OPTIM="-O0" DEBUG="-ggdb" EXTRA="$EXTRA"]) + [EXTRA="$EXTRA -DNDEBUG"], + [EXTRA="$EXTRA"]) AS_IF([test "x$enable_prof" != "xno"], [EXTRA="$EXTRA -pg"]) @@ -114,8 +116,8 @@ AS_IF([test "x$enable_fftw" = "xyes"], AX_PTHREAD([], AC_MSG_ERROR([requires pthread])) -AC_SUBST([CFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS $PTHREAD_CFLAGS"]) -AC_SUBST([CXXFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS $PTHREAD_CFLAGS"]) +AC_SUBST([CFLAGS], ["$EXTRA $FFTW_CFLAGS $PTHREAD_CFLAGS"]) +AC_SUBST([CXXFLAGS], ["$CXXFLAGS $EXTRA $FFTW_CFLAGS $PTHREAD_CFLAGS"]) AC_SUBST([LIBS], ["$FFTW_LIBS $PTHREAD_LIBS $ZMQ_LIBS"]) # Checks for UHD. diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 95fa603..6d67dc4 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -46,8 +46,7 @@ #include "FIRFilter.h" #include "RemoteControl.h" -#include -#include +#include #include #include #include @@ -75,7 +74,7 @@ typedef std::complex complexf; -using namespace boost; +using namespace std; volatile sig_atomic_t running = 1; diff --git a/src/DabModulator.cpp b/src/DabModulator.cpp index 8a52401..92f0acb 100644 --- a/src/DabModulator.cpp +++ b/src/DabModulator.cpp @@ -26,7 +26,7 @@ */ #include -#include +#include #include "DabModulator.h" #include "PcDebug.h" @@ -54,8 +54,6 @@ #include "RemoteControl.h" #include "Log.h" -using namespace boost; - DabModulator::DabModulator( double tist_offset_s, unsigned tist_delay_stages, RemoteControllers* rcs, @@ -143,6 +141,8 @@ void DabModulator::setMode(unsigned mode) int DabModulator::process(Buffer* const dataIn, Buffer* dataOut) { + using namespace std; + PDEBUG("DabModulator::process(dataIn: %p, dataOut: %p)\n", dataIn, dataOut); diff --git a/src/DabModulator.h b/src/DabModulator.h index cee066a..9150f5c 100644 --- a/src/DabModulator.h +++ b/src/DabModulator.h @@ -34,7 +34,7 @@ #include #include -#include +#include #include "ModCodec.h" #include "EtiReader.h" diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp index f584275..500101b 100644 --- a/src/EtiReader.cpp +++ b/src/EtiReader.cpp @@ -30,11 +30,12 @@ #include "TimestampDecoder.h" #include +#include #include #include #include -using namespace boost; +using namespace std; enum ETI_READER_STATE { EtiReaderStateNbFrame, @@ -101,7 +102,7 @@ unsigned EtiReader::getFp() } -const std::vector >& EtiReader::getSubchannels() +const std::vector >& EtiReader::getSubchannels() { return mySources; } diff --git a/src/EtiReader.h b/src/EtiReader.h index 84ad9b4..a8fc8f0 100644 --- a/src/EtiReader.h +++ b/src/EtiReader.h @@ -39,9 +39,9 @@ #include "TimestampDecoder.h" #include +#include #include #include -#include class EtiReader @@ -58,7 +58,7 @@ public: FicSource* getFic(); unsigned getMode(); unsigned getFp(); - const std::vector >& getSubchannels(); + const std::vector >& getSubchannels(); int process(const Buffer* dataIn); void calculateTimestamp(struct frame_timestamp& ts) @@ -84,7 +84,7 @@ protected: eti_EOF eti_eof; eti_TIST eti_tist; FicSource* myFicSource; - std::vector > mySources; + std::vector > mySources; TimestampDecoder myTimestampDecoder; private: diff --git a/src/FIRFilter.cpp b/src/FIRFilter.cpp index b1ce618..9ef49c5 100644 --- a/src/FIRFilter.cpp +++ b/src/FIRFilter.cpp @@ -35,8 +35,7 @@ #include #include - -#include +#include #ifdef __AVX__ # include @@ -60,10 +59,10 @@ void FIRFilterWorker::process(struct FIRFilterWorkerData *fwd) // the incoming buffer while(running) { - boost::shared_ptr dataIn; + std::shared_ptr dataIn; fwd->input_queue.wait_and_pop(dataIn); - boost::shared_ptr dataOut = boost::make_shared(); + std::shared_ptr dataOut = make_shared(); dataOut->setLength(dataIn->getLength()); PDEBUG("FIRFilterWorker: dataIn->getLength() %zu\n", dataIn->getLength()); @@ -393,13 +392,13 @@ int FIRFilter::process(Buffer* const dataIn, Buffer* dataOut) // This thread creates the dataIn buffer, and deletes // the outgoing buffer - boost::shared_ptr inbuffer = - boost::make_shared(dataIn->getLength(), dataIn->getData()); + std::shared_ptr inbuffer = + make_shared(dataIn->getLength(), dataIn->getData()); firwd.input_queue.push(inbuffer); if (number_of_runs > 2) { - boost::shared_ptr outbuffer; + std::shared_ptr outbuffer; firwd.output_queue.wait_and_pop(outbuffer); dataOut->setData(outbuffer->getData(), outbuffer->getLength()); diff --git a/src/FIRFilter.h b/src/FIRFilter.h index 751be91..28b2f4a 100644 --- a/src/FIRFilter.h +++ b/src/FIRFilter.h @@ -30,7 +30,6 @@ #endif #include -#include #include "RemoteControl.h" #include "ModCodec.h" @@ -43,6 +42,7 @@ #include #include #include +#include #define FIRFILTER_PIPELINE_DELAY 1 @@ -52,8 +52,8 @@ struct FIRFilterWorkerData { /* Thread-safe queues to give data to and get data from * the worker */ - ThreadsafeQueue > input_queue; - ThreadsafeQueue > output_queue; + ThreadsafeQueue > input_queue; + ThreadsafeQueue > output_queue; /* Remote-control can change the taps while the filter * runs. This lock makes sure nothing bad happens when diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp index 3844e86..e36c1f4 100644 --- a/src/Flowgraph.cpp +++ b/src/Flowgraph.cpp @@ -26,7 +26,7 @@ #include "Flowgraph.h" #include "PcDebug.h" - +#include #if HAVE_DECL__MM_MALLOC # include @@ -43,7 +43,7 @@ #include #endif -using namespace boost; +using namespace std; typedef std::vector >::iterator NodeIterator; typedef std::vector >::iterator EdgeIterator; diff --git a/src/Flowgraph.h b/src/Flowgraph.h index 1129668..9c6c2d8 100644 --- a/src/Flowgraph.h +++ b/src/Flowgraph.h @@ -34,24 +34,23 @@ #include "porting.h" #include "ModPlugin.h" - +#include #include #include -#include class Node { public: - Node(boost::shared_ptr plugin); + Node(std::shared_ptr plugin); ~Node(); Node(const Node&); Node& operator=(const Node&); - boost::shared_ptr plugin() { return myPlugin; } + std::shared_ptr plugin() { return myPlugin; } - std::vector > myInputBuffers; - std::vector > myOutputBuffers; + std::vector > myInputBuffers; + std::vector > myOutputBuffers; int process(); time_t processTime() { return myProcessTime; } @@ -60,7 +59,7 @@ public: } protected: - boost::shared_ptr myPlugin; + std::shared_ptr myPlugin; time_t myProcessTime; }; @@ -68,15 +67,15 @@ protected: class Edge { public: - Edge(boost::shared_ptr& src, boost::shared_ptr& dst); + Edge(std::shared_ptr& src, std::shared_ptr& dst); ~Edge(); Edge(const Edge&); Edge& operator=(const Edge&); protected: - boost::shared_ptr mySrcNode; - boost::shared_ptr myDstNode; - boost::shared_ptr myBuffer; + std::shared_ptr mySrcNode; + std::shared_ptr myDstNode; + std::shared_ptr myBuffer; }; @@ -88,13 +87,13 @@ public: Flowgraph(const Flowgraph&); Flowgraph& operator=(const Flowgraph&); - void connect(boost::shared_ptr input, - boost::shared_ptr output); + void connect(std::shared_ptr input, + std::shared_ptr output); bool run(); protected: - std::vector > nodes; - std::vector > edges; + std::vector > nodes; + std::vector > edges; time_t myProcessTime; }; diff --git a/src/FrameMultiplexer.cpp b/src/FrameMultiplexer.cpp index 843f72d..efd43f3 100644 --- a/src/FrameMultiplexer.cpp +++ b/src/FrameMultiplexer.cpp @@ -25,16 +25,15 @@ #include #include #include +#include #include #include typedef std::complex complexf; -using namespace boost; - FrameMultiplexer::FrameMultiplexer( size_t framesize, - const std::vector >* subchannels) : + const std::vector >* subchannels) : ModMux(ModFormat(framesize), ModFormat(framesize)), d_frameSize(framesize), mySubchannels(subchannels) @@ -79,7 +78,7 @@ int FrameMultiplexer::process(std::vector dataIn, Buffer* dataOut) ++in; // Write subchannel assert(mySubchannels->size() == dataIn.size() - 1); - std::vector >::const_iterator subchannel = + std::vector >::const_iterator subchannel = mySubchannels->begin(); while (in != dataIn.end()) { assert((*subchannel)->framesizeCu() * 8 == (*in)->getLength()); diff --git a/src/FrameMultiplexer.h b/src/FrameMultiplexer.h index ba571f6..b32a0d7 100644 --- a/src/FrameMultiplexer.h +++ b/src/FrameMultiplexer.h @@ -29,7 +29,7 @@ #include "ModMux.h" #include "SubchannelSource.h" -#include +#include #include @@ -38,7 +38,7 @@ class FrameMultiplexer : public ModMux { public: FrameMultiplexer(size_t frameSize, - const std::vector >* subchannels); + const std::vector >* subchannels); virtual ~FrameMultiplexer(); FrameMultiplexer(const FrameMultiplexer&); FrameMultiplexer& operator=(const FrameMultiplexer&); @@ -49,7 +49,7 @@ public: protected: size_t d_frameSize; - const std::vector >* mySubchannels; + const std::vector >* mySubchannels; }; #endif // FRAME_MULTIPLEXER_H diff --git a/src/InputReader.h b/src/InputReader.h index b262cc9..b8c4fae 100644 --- a/src/InputReader.h +++ b/src/InputReader.h @@ -32,7 +32,7 @@ #include #include -#include +#include #if defined(HAVE_ZEROMQ) # include "zmq.hpp" # include "ThreadsafeQueue.h" @@ -147,7 +147,7 @@ struct zmq_input_overflow : public std::exception struct InputZeroMQThreadData { - ThreadsafeQueue > > *in_messages; + ThreadsafeQueue > > *in_messages; std::string uri; unsigned max_queued_frames; @@ -206,7 +206,7 @@ class InputZeroMQReader : public InputReader std::string uri_; InputZeroMQWorker worker_; - ThreadsafeQueue > > in_messages_; + ThreadsafeQueue > > in_messages_; struct InputZeroMQThreadData workerdata_; }; diff --git a/src/InputZeroMQReader.cpp b/src/InputZeroMQReader.cpp index 36d4e4b..70b0afc 100644 --- a/src/InputZeroMQReader.cpp +++ b/src/InputZeroMQReader.cpp @@ -37,7 +37,6 @@ #include #include "zmq.hpp" #include -#include #include "porting.h" #include "InputReader.h" #include "PcDebug.h" @@ -85,7 +84,7 @@ int InputZeroMQReader::GetNextFrame(void* buffer) { const size_t framesize = 6144; - boost::shared_ptr > incoming; + std::shared_ptr > incoming; /* Do some prebuffering because reads will happen in bursts * (4 ETI frames in TM1) and we should make sure that @@ -168,8 +167,8 @@ void InputZeroMQWorker::RecvProcess(struct InputZeroMQThreadData* workerdata) // TODO error handling } else { - boost::shared_ptr > buf = - boost::make_shared >(6144, 0x55); + std::shared_ptr > buf = + std::make_shared >(6144, 0x55); const int framesize = dab_msg->buflen[i]; diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index adc7b9a..e71a625 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -46,7 +46,6 @@ #include #include -using namespace boost; using namespace std; typedef std::complex complexf; @@ -226,7 +225,7 @@ OutputUHD::OutputUHD( SetDelayBuffer(myConf.dabMode); - shared_ptr b(new barrier(2)); + auto b = std::make_shared(2); mySyncBarrier = b; uwd.sync_barrier = b; diff --git a/src/OutputUHD.h b/src/OutputUHD.h index 8234340..88be215 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -49,8 +49,8 @@ DESCRIPTION: #include #include #include -#include #include +#include #include #include "Log.h" @@ -127,7 +127,7 @@ struct UHDWorkerData { bool muting; // A barrier to synchronise the two threads - boost::shared_ptr sync_barrier; + std::shared_ptr sync_barrier; // What to do when the reference clock PLL loses lock refclk_lock_loss_behaviour_t refclk_lock_loss_behaviour; @@ -247,7 +247,7 @@ class OutputUHD: public ModOutput, public RemoteControllable { EtiReader *myEtiReader; OutputUHDConfig myConf; uhd::usrp::multi_usrp::sptr myUsrp; - boost::shared_ptr mySyncBarrier; + std::shared_ptr mySyncBarrier; UHDWorker worker; bool first_run; bool gps_fix_verified; @@ -281,7 +281,7 @@ class OutputUHD: public ModOutput, public RemoteControllable { static const int initial_gps_fix_wait = 180; // Interval for checking the GPS at runtime - static const double gps_fix_check_interval = 10.0; // seconds + static constexpr double gps_fix_check_interval = 10.0; // seconds void check_gps(); diff --git a/src/RemoteControl.h b/src/RemoteControl.h index 0a4848f..b94ed6c 100644 --- a/src/RemoteControl.h +++ b/src/RemoteControl.h @@ -42,8 +42,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/src/TimestampDecoder.cpp b/src/TimestampDecoder.cpp index 5044366..2cfb281 100644 --- a/src/TimestampDecoder.cpp +++ b/src/TimestampDecoder.cpp @@ -28,8 +28,6 @@ #include #include #include -#include -#include #include #include "PcDebug.h" #include "TimestampDecoder.h" @@ -42,8 +40,8 @@ void TimestampDecoder::calculateTimestamp(struct frame_timestamp& ts) { - boost::shared_ptr ts_queued = - boost::make_shared(); + std::shared_ptr ts_queued = + std::make_shared(); /* Push new timestamp into queue */ ts_queued->timestamp_valid = full_timestamp_received_mnsc; diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h index d8ab633..9420506 100644 --- a/src/TimestampDecoder.h +++ b/src/TimestampDecoder.h @@ -28,7 +28,7 @@ #define TIMESTAMP_DECODER_H #include -#include +#include #include #include #include @@ -192,7 +192,7 @@ class TimestampDecoder : public RemoteControllable * synchronise two modulators if only one uses (for instance) the * FIRFilter (1 stage pipeline) */ - std::queue > queue_timestamps; + std::queue > queue_timestamps; }; -- cgit v1.2.3