diff --git a/DeviceAdapters/QCam/QICamera.cpp b/DeviceAdapters/QCam/QICamera.cpp index a22dedb94..20d580575 100644 --- a/DeviceAdapters/QCam/QICamera.cpp +++ b/DeviceAdapters/QCam/QICamera.cpp @@ -668,7 +668,7 @@ int QICamera::Initialize() } // init the driver - m_driverAccess = auto_ptr(new QIDriver::Access); + m_driverAccess = unique_ptr(new QIDriver::Access); if (!*m_driverAccess) { REPORT_QERR(m_driverAccess->Status()); return DEVICE_NATIVE_MODULE_FAILED; diff --git a/DeviceAdapters/QCam/QICamera.h b/DeviceAdapters/QCam/QICamera.h index abc713b26..28e47fa06 100644 --- a/DeviceAdapters/QCam/QICamera.h +++ b/DeviceAdapters/QCam/QICamera.h @@ -294,7 +294,7 @@ class QICamera : public CCameraBase #endif int SendSettingsToCamera(QCam_Settings* settings); - std::auto_ptr m_driverAccess; + std::unique_ptr m_driverAccess; bool m_isInitialized; // Has the camera been initialized (setup)? QCam_Handle m_camera; // handle to the camera. Used by all QCam_* functions diff --git a/DeviceAdapters/SerialManager/SerialManager.cpp b/DeviceAdapters/SerialManager/SerialManager.cpp index 1b9ec8eb2..ecd3090b1 100644 --- a/DeviceAdapters/SerialManager/SerialManager.cpp +++ b/DeviceAdapters/SerialManager/SerialManager.cpp @@ -130,7 +130,7 @@ void SerialPortLister::ListPorts(std::vector &availablePorts) #ifdef WIN32 availablePorts.clear(); - std::auto_ptr allDeviceNames (new B100000()); + std::unique_ptr allDeviceNames (new B100000()); // on Windows the serial ports are devices that begin with "COM" int ret = QueryDosDevice( 0, allDeviceNames->buffer, MaxBuf); diff --git a/DeviceAdapters/SutterLambda/SutterLambda.cpp b/DeviceAdapters/SutterLambda/SutterLambda.cpp index fb2726afc..3aa875fa7 100644 --- a/DeviceAdapters/SutterLambda/SutterLambda.cpp +++ b/DeviceAdapters/SutterLambda/SutterLambda.cpp @@ -1572,7 +1572,7 @@ bool ShutterOnTenDashTwo::Busy() { { - std::auto_ptr pg ( new MMThreadGuard(*(::gplocks_[port_]))); + std::unique_ptr pg ( new MMThreadGuard(*(::gplocks_[port_]))); if(::g_Busy[port_]) return true; } diff --git a/DeviceAdapters/TwainCamera/TwainDevice.cpp b/DeviceAdapters/TwainCamera/TwainDevice.cpp index 9afc629f5..2a4fc2157 100644 --- a/DeviceAdapters/TwainCamera/TwainDevice.cpp +++ b/DeviceAdapters/TwainCamera/TwainDevice.cpp @@ -804,7 +804,7 @@ class TwImpl twCap.Cap = cap; twCap.ConType = TWON_ONEVALUE; - std::auto_ptr handle( new TW_ONEVALUE); + std::unique_ptr handle( new TW_ONEVALUE); twCap.hContainer = handle.get(); //twCap.hContainer = (void *) malloc(sizeof(TW_ONEVALUE)); @@ -1260,7 +1260,7 @@ class TwImpl // cap.Cap = Cap; // cap.ConType = TWON_ONEVALUE; - // std::auto_ptr pcontainer (new TW_ONEVALUEFIX32); + // std::unique_ptr pcontainer (new TW_ONEVALUEFIX32); // cap.hContainer = pcontainer.get(); // pcontainer->ItemType = TWTY_FIX32; diff --git a/DeviceAdapters/UserDefinedSerial/ResponseDetector.cpp b/DeviceAdapters/UserDefinedSerial/ResponseDetector.cpp index a6fd60d60..f61b67b67 100644 --- a/DeviceAdapters/UserDefinedSerial/ResponseDetector.cpp +++ b/DeviceAdapters/UserDefinedSerial/ResponseDetector.cpp @@ -28,10 +28,10 @@ #include -std::auto_ptr +std::unique_ptr ResponseDetector::NewByName(const std::string& name) { - std::auto_ptr newDetector; + std::unique_ptr newDetector; newDetector = IgnoringResponseDetector::NewByName(name); if (newDetector.get()) @@ -49,14 +49,14 @@ ResponseDetector::NewByName(const std::string& name) if (newDetector.get()) return newDetector; - return std::auto_ptr(); + return std::unique_ptr(); } -std::auto_ptr +std::unique_ptr IgnoringResponseDetector::NewByName(const std::string& name) { - std::auto_ptr ret; + std::unique_ptr ret; if (name == g_PropValue_ResponseIgnore) ret.reset(new IgnoringResponseDetector()); return ret; @@ -86,10 +86,10 @@ IgnoringResponseDetector::RecvAlternative(MM::Core*, MM::Device*, } -std::auto_ptr +std::unique_ptr TerminatorResponseDetector::NewByName(const std::string& name) { - std::auto_ptr ret; + std::unique_ptr ret; if (name == g_PropValue_ResponseCRLFTerminated) ret.reset(new TerminatorResponseDetector("\r\n", "CRLF")); else if (name == g_PropValue_ResponseCRTerminated) @@ -240,10 +240,10 @@ BinaryResponseDetector::Recv(MM::Core* core, MM::Device* device, } -std::auto_ptr +std::unique_ptr FixedLengthResponseDetector::NewByName(const std::string& name) { - std::auto_ptr ret; + std::unique_ptr ret; const std::string prefix(g_PropValuePrefix_ResponseFixedByteCount); if (name.substr(0, prefix.size()) == prefix) { @@ -322,10 +322,10 @@ FixedLengthResponseDetector::RecvAlternative(MM::Core* core, } -std::auto_ptr +std::unique_ptr VariableLengthResponseDetector::NewByName(const std::string& name) { - std::auto_ptr ret; + std::unique_ptr ret; if (name == g_PropValue_ResponseVariableByteCount) ret.reset(new VariableLengthResponseDetector()); return ret; diff --git a/DeviceAdapters/UserDefinedSerial/ResponseDetector.h b/DeviceAdapters/UserDefinedSerial/ResponseDetector.h index f73f24e67..84d958395 100644 --- a/DeviceAdapters/UserDefinedSerial/ResponseDetector.h +++ b/DeviceAdapters/UserDefinedSerial/ResponseDetector.h @@ -42,7 +42,7 @@ class ResponseDetector : boost::noncopyable * NewByName() functions to create the appropriate instance. If name is not * a known name, returns null. */ - static std::auto_ptr NewByName(const std::string& name); + static std::unique_ptr NewByName(const std::string& name); virtual ~ResponseDetector() {} @@ -78,7 +78,7 @@ class ResponseDetector : boost::noncopyable class IgnoringResponseDetector : public ResponseDetector { public: - static std::auto_ptr NewByName(const std::string& name); + static std::unique_ptr NewByName(const std::string& name); virtual std::string GetMethodName() const; virtual int RecvExpected(MM::Core* core, MM::Device* device, @@ -101,7 +101,7 @@ class TerminatorResponseDetector : public ResponseDetector std::string terminatorName_; public: - static std::auto_ptr NewByName(const std::string& name); + static std::unique_ptr NewByName(const std::string& name); virtual std::string GetMethodName() const; virtual int RecvExpected(MM::Core* core, MM::Device* device, @@ -138,7 +138,7 @@ class FixedLengthResponseDetector : public BinaryResponseDetector size_t byteCount_; public: - static std::auto_ptr NewByName(const std::string& name); + static std::unique_ptr NewByName(const std::string& name); virtual std::string GetMethodName() const; virtual int RecvExpected(MM::Core* core, MM::Device* device, @@ -160,7 +160,7 @@ class FixedLengthResponseDetector : public BinaryResponseDetector class VariableLengthResponseDetector : public BinaryResponseDetector { public: - static std::auto_ptr NewByName(const std::string& name); + static std::unique_ptr NewByName(const std::string& name); virtual std::string GetMethodName() const; virtual int RecvExpected(MM::Core* core, MM::Device* device, diff --git a/DeviceAdapters/UserDefinedSerial/UserDefinedSerial.h b/DeviceAdapters/UserDefinedSerial/UserDefinedSerial.h index 1fe74ce08..ce36c7589 100644 --- a/DeviceAdapters/UserDefinedSerial/UserDefinedSerial.h +++ b/DeviceAdapters/UserDefinedSerial/UserDefinedSerial.h @@ -104,7 +104,7 @@ class UserDefSerialBase : public TBasicDevice bool binaryMode_; std::string asciiTerminator_; - std::auto_ptr responseDetector_; + std::unique_ptr responseDetector_; std::vector initializeCommand_; std::vector initializeResponse_; diff --git a/DeviceAdapters/UserDefinedSerial/UserDefinedSerialImpl.h b/DeviceAdapters/UserDefinedSerial/UserDefinedSerialImpl.h index 5a099c99e..215a49652 100644 --- a/DeviceAdapters/UserDefinedSerial/UserDefinedSerialImpl.h +++ b/DeviceAdapters/UserDefinedSerial/UserDefinedSerialImpl.h @@ -272,11 +272,11 @@ OnResponseDetectionMethod(MM::PropertyBase* pProp, MM::ActionType eAct) { std::string s; pProp->Get(s); - std::auto_ptr newDetector = + std::unique_ptr newDetector = ResponseDetector::NewByName(s); if (!newDetector.get()) return DEVICE_INVALID_PROPERTY_VALUE; - responseDetector_ = newDetector; + responseDetector_ = std::move(newDetector); } return DEVICE_OK; } diff --git a/MMCore/Error.cpp b/MMCore/Error.cpp index ef327d873..0c7c286df 100644 --- a/MMCore/Error.cpp +++ b/MMCore/Error.cpp @@ -28,15 +28,13 @@ CMMError::CMMError(const std::string& msg, Code code) : message_(msg), - code_(code), - underlying_(0) + code_(code) {} CMMError::CMMError(const char* msg, Code code) : message_(msg ? msg : "(null message)"), - code_(code), - underlying_(0) + code_(code) {} @@ -70,8 +68,7 @@ CMMError::CMMError(const char* msg, const CMMError& underlyingError) : CMMError::CMMError(const CMMError& other) : message_(other.message_), - code_(other.code_), - underlying_(0) + code_(other.code_) { if (other.getUnderlyingError()) underlying_.reset(new CMMError(*(other.getUnderlyingError()))); diff --git a/MMCore/Error.h b/MMCore/Error.h index aaa0bf889..0e78bce86 100644 --- a/MMCore/Error.h +++ b/MMCore/Error.h @@ -153,12 +153,12 @@ class CMMError : public std::exception virtual const CMMError* getUnderlyingError() const; private: - // Prohibit assignment. + // Prohibit assignment. (BUG: Assignment should behave like copy ctor.) CMMError& operator=(const CMMError&); std::string message_; Code code_; - std::auto_ptr underlying_; + std::unique_ptr underlying_; }; #endif //_ERROR_H_