From 7606a03bc48d57dee1187ce6f33a280be86d1b9d Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Fri, 8 Dec 2023 16:24:39 -0600 Subject: [PATCH 1/7] MMDevice: Avoid using namespace std --- DeviceAdapters/Andor/SRRFControl.cpp | 1 + MMDevice/Debayer.cpp | 5 +-- MMDevice/Debayer.h | 3 ++ MMDevice/ImgBuffer.cpp | 16 ++++---- MMDevice/ImgBuffer.h | 4 +- MMDevice/Property.cpp | 58 ++++++++++++++-------------- MMDevice/Property.h | 2 - 7 files changed, 44 insertions(+), 45 deletions(-) diff --git a/DeviceAdapters/Andor/SRRFControl.cpp b/DeviceAdapters/Andor/SRRFControl.cpp index eddb62163..13b95cc3c 100644 --- a/DeviceAdapters/Andor/SRRFControl.cpp +++ b/DeviceAdapters/Andor/SRRFControl.cpp @@ -1,6 +1,7 @@ #include "SRRFControl.h" #include #include "boost/date_time/posix_time/posix_time.hpp" +#include "DeviceUtils.h" #include "ImgBuffer.h" #ifdef WIN32 diff --git a/MMDevice/Debayer.cpp b/MMDevice/Debayer.cpp index 3c9cefdd9..2cf606494 100644 --- a/MMDevice/Debayer.cpp +++ b/MMDevice/Debayer.cpp @@ -24,9 +24,8 @@ /////////////////////////////////////////////////////////////////////////////// #include "Debayer.h" -#include -#include -using namespace std; + +#include /////////////////////////////////////////////////////////////////////////////// // Debayer class implementation diff --git a/MMDevice/Debayer.h b/MMDevice/Debayer.h index 84365bf9f..80550bd72 100644 --- a/MMDevice/Debayer.h +++ b/MMDevice/Debayer.h @@ -28,6 +28,9 @@ #include "ImgBuffer.h" +#include +#include + /** * Utility class to build color image from the Bayer grayscale image * Based on the Debayer_Image plugin for ImageJ, by Jennifer West, University of Manitoba diff --git a/MMDevice/ImgBuffer.cpp b/MMDevice/ImgBuffer.cpp index ae67c6809..5c48a74b7 100644 --- a/MMDevice/ImgBuffer.cpp +++ b/MMDevice/ImgBuffer.cpp @@ -19,9 +19,9 @@ // NOTE: Imported from ADVI for use in Micro-Manager /////////////////////////////////////////////////////////////////////////////// #include "ImgBuffer.h" -#include -#include -using namespace std; + +#include +#include /////////////////////////////////////////////////////////////////////////////// // ImgBuffer class @@ -31,7 +31,7 @@ ImgBuffer::ImgBuffer(unsigned xSize, unsigned ySize, unsigned pixDepth) : { pixels_ = new unsigned char[xSize * ySize * pixDepth]; assert(pixels_); - memset(pixels_, 0, xSize * ySize * pixDepth); + std::memset(pixels_, 0, xSize * ySize * pixDepth); } ImgBuffer::ImgBuffer() : @@ -65,7 +65,7 @@ unsigned char* ImgBuffer::GetPixelsRW() void ImgBuffer::SetPixels(const void* pix) { - memcpy((void*)pixels_, pix, width_ * height_ * pixDepth_); + std::memcpy((void*)pixels_, pix, width_ * height_ * pixDepth_); } // Set pixels, from a source that has extra bytes at the end of each scanline @@ -78,7 +78,7 @@ void ImgBuffer::SetPixelsPadded(const void* pixArray, int paddingBytesPerLine) for(size_t i = 0; i < height_; i++) { - memcpy(dst, src, lineSize); + std::memcpy(dst, src, lineSize); src += lineSize + paddingBytesPerLine; dst += lineSize; } @@ -87,7 +87,7 @@ void ImgBuffer::SetPixelsPadded(const void* pixArray, int paddingBytesPerLine) void ImgBuffer::ResetPixels() { if (pixels_) - memset(pixels_, 0, width_ * height_ * pixDepth_); + std::memset(pixels_, 0, width_ * height_ * pixDepth_); } bool ImgBuffer::Compatible(const ImgBuffer& img) const @@ -127,7 +127,7 @@ void ImgBuffer::Resize(unsigned xSize, unsigned ySize) width_ = xSize; height_ = ySize; - memset(pixels_, 0, width_ * height_ * pixDepth_); + std::memset(pixels_, 0, width_ * height_ * pixDepth_); } void ImgBuffer::Copy(const ImgBuffer& right) diff --git a/MMDevice/ImgBuffer.h b/MMDevice/ImgBuffer.h index f53c417dd..ce31dd11e 100644 --- a/MMDevice/ImgBuffer.h +++ b/MMDevice/ImgBuffer.h @@ -24,9 +24,7 @@ #define _IMG_BUFFER_ #include -#include -#include -#include "MMDevice.h" + #include "ImageMetadata.h" /////////////////////////////////////////////////////////////////////////////// diff --git a/MMDevice/Property.cpp b/MMDevice/Property.cpp index 1e7a3b5a1..b7f807ccd 100644 --- a/MMDevice/Property.cpp +++ b/MMDevice/Property.cpp @@ -21,18 +21,18 @@ #include "Property.h" +#include +#include +#include #include -#include - -using namespace std; -const int BUFSIZE = 60; // For number-to-string conversion +static const int BUFSIZE = 60; // For number-to-string conversion -vector MM::Property::GetAllowedValues() const +std::vector MM::Property::GetAllowedValues() const { - vector vals; - map::const_iterator it; + std::vector vals; + std::map::const_iterator it; for (it=values_.begin(); it != values_.end(); it++) vals.push_back(it->first); return vals; @@ -40,13 +40,13 @@ vector MM::Property::GetAllowedValues() const void MM::Property::AddAllowedValue(const char* value) { - values_.insert(make_pair(value, 0L)); + values_.insert(std::make_pair(value, 0L)); limits_ = false; } void MM::Property::AddAllowedValue(const char* value, long data) { - values_.insert(make_pair(value, data)); + values_.insert(std::make_pair(value, data)); hasData_ = true; limits_ = false; } @@ -57,7 +57,7 @@ bool MM::Property::IsAllowed(const char* value) const if (values_.size() == 0) return true; // any value is allowed - map::const_iterator it = values_.find(value); + std::map::const_iterator it = values_.find(value); if (it == values_.end()) return false; // not found else @@ -69,7 +69,7 @@ bool MM::Property::GetData(const char* value, long& data) const if (!hasData_) return false; - map::const_iterator it = values_.find(value); + std::map::const_iterator it = values_.find(value); if (it == values_.end()) return false; // not found else @@ -93,7 +93,7 @@ void MM::Property::SetSequenceable(long sequenceMaxSize) bool MM::StringProperty::Set(double val) { char buf[BUFSIZE]; - snprintf(buf, BUFSIZE, "%.2g", val); + std::snprintf(buf, BUFSIZE, "%.2g", val); value_ = buf; return true; } @@ -101,7 +101,7 @@ bool MM::StringProperty::Set(double val) bool MM::StringProperty::Set(long val) { char buf[BUFSIZE]; - snprintf(buf, BUFSIZE, "%ld", val); + std::snprintf(buf, BUFSIZE, "%ld", val); value_ = buf; return true; } @@ -114,13 +114,13 @@ bool MM::StringProperty::Set(const char* val) bool MM::StringProperty::Get(double& val) const { - val = atof(value_.c_str()); + val = std::atof(value_.c_str()); return true; } bool MM::StringProperty::Get(long& val) const { - val = atol(value_.c_str()); + val = std::atol(value_.c_str()); return true; } @@ -138,19 +138,19 @@ bool MM::StringProperty::Get(std::string& strVal) const double MM::FloatProperty::Truncate(double dVal) { if (dVal >= 0) - return floor(dVal * reciprocalMinimalStep_ + 0.5) / reciprocalMinimalStep_; + return std::floor(dVal * reciprocalMinimalStep_ + 0.5) / reciprocalMinimalStep_; else - return ceil(dVal * reciprocalMinimalStep_ - 0.5) / reciprocalMinimalStep_; + return std::ceil(dVal * reciprocalMinimalStep_ - 0.5) / reciprocalMinimalStep_; } double MM::FloatProperty::TruncateDown(double dVal) { - return floor(dVal * reciprocalMinimalStep_) / reciprocalMinimalStep_; + return std::floor(dVal * reciprocalMinimalStep_) / reciprocalMinimalStep_; } double MM::FloatProperty::TruncateUp(double dVal) { - return ceil(dVal * reciprocalMinimalStep_) / reciprocalMinimalStep_; + return std::ceil(dVal * reciprocalMinimalStep_) / reciprocalMinimalStep_; } bool MM::FloatProperty::Set(double dVal) @@ -191,8 +191,8 @@ bool MM::FloatProperty::Get(std::string& strVal) const { char fmtStr[20]; char buf[BUFSIZE]; - sprintf(fmtStr, "%%.%df", decimalPlaces_); - snprintf(buf, BUFSIZE, fmtStr, value_); + std::sprintf(fmtStr, "%%.%df", decimalPlaces_); + std::snprintf(buf, BUFSIZE, fmtStr, value_); strVal = buf; return true; } @@ -225,7 +225,7 @@ bool MM::IntegerProperty::Set(long lVal) bool MM::IntegerProperty::Set(const char* pszVal) { - return Set(atol(pszVal)); + return Set(std::atol(pszVal)); } bool MM::IntegerProperty::Get(double& dVal) const @@ -243,7 +243,7 @@ bool MM::IntegerProperty::Get(long& lVal) const bool MM::IntegerProperty::Get(std::string& strVal) const { char pszBuf[BUFSIZE]; - snprintf(pszBuf, BUFSIZE, "%ld", value_); + std::snprintf(pszBuf, BUFSIZE, "%ld", value_); strVal = pszBuf; return true; } @@ -286,7 +286,7 @@ int MM::PropertyCollection::Set(const char* pszPropName, const char* pszValue) return DEVICE_INVALID_PROPERTY_VALUE; } -int MM::PropertyCollection::Get(const char* pszPropName, string& strValue) const +int MM::PropertyCollection::Get(const char* pszPropName, std::string& strValue) const { MM::Property* pProp = Find(pszPropName); if (!pProp) @@ -310,9 +310,9 @@ MM::Property* MM::PropertyCollection::Find(const char* pszName) const return it->second; } -vector MM::PropertyCollection::GetNames() const +std::vector MM::PropertyCollection::GetNames() const { - vector nameList; + std::vector nameList; CPropArray::const_iterator it; for (it = properties_.begin(); it != properties_.end(); it++) @@ -363,7 +363,7 @@ int MM::PropertyCollection::CreateProperty(const char* pszName, const char* pszV return DEVICE_OK; } -int MM::PropertyCollection::SetAllowedValues(const char* pszName, vector& values) +int MM::PropertyCollection::SetAllowedValues(const char* pszName, std::vector& values) { MM::Property* pProp = Find(pszName); if (!pProp) @@ -425,7 +425,7 @@ int MM::PropertyCollection::GetCurrentPropertyData(const char* name, long& data) if (!pProp) return DEVICE_INVALID_PROPERTY; // name not found - string value; + std::string value; pProp->Get(value); if (!pProp->GetData(value.c_str(), data)) return DEVICE_NO_PROPERTY_DATA; @@ -433,7 +433,7 @@ int MM::PropertyCollection::GetCurrentPropertyData(const char* name, long& data) return DEVICE_OK; } -bool MM::PropertyCollection::GetName(unsigned uIdx, string& strName) const +bool MM::PropertyCollection::GetName(unsigned uIdx, std::string& strName) const { if (uIdx >= properties_.size()) return false; // unknown index diff --git a/MMDevice/Property.h b/MMDevice/Property.h index cbc669822..bc2acfb0f 100644 --- a/MMDevice/Property.h +++ b/MMDevice/Property.h @@ -25,8 +25,6 @@ #include "MMDeviceConstants.h" -#include -#include #include #include #include From 31d87dfcf9ccf364528ace558426d7adecc1289f Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Fri, 8 Dec 2023 16:36:19 -0600 Subject: [PATCH 2/7] MMDevice: Use #pragma once consistently --- MMDevice/Debayer.h | 6 +----- MMDevice/DeviceBase.h | 9 +-------- MMDevice/DeviceUtils.h | 9 ++------- MMDevice/ImageMetadata.h | 10 +++------- MMDevice/ImgBuffer.h | 6 +----- MMDevice/MMDevice.h | 10 +--------- MMDevice/MMDeviceConstants.h | 7 +------ MMDevice/ModuleInterface.h | 6 +----- MMDevice/Property.h | 5 +---- 9 files changed, 12 insertions(+), 56 deletions(-) diff --git a/MMDevice/Debayer.h b/MMDevice/Debayer.h index 80550bd72..69a1b6013 100644 --- a/MMDevice/Debayer.h +++ b/MMDevice/Debayer.h @@ -21,10 +21,8 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. // -/////////////////////////////////////////////////////////////////////////////// -#if !defined(_DEBAYER_) -#define _DEBAYER_ +#pragma once #include "ImgBuffer.h" @@ -74,5 +72,3 @@ class Debayer int orderIndex; int algoIndex; }; - -#endif // !defined(_DEBAYER_) diff --git a/MMDevice/DeviceBase.h b/MMDevice/DeviceBase.h index 4321f5945..fc3d80c68 100644 --- a/MMDevice/DeviceBase.h +++ b/MMDevice/DeviceBase.h @@ -20,12 +20,8 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. // -// - -#ifndef _DEVICE_BASE_H_ -#define _DEVICE_BASE_H_ - +#pragma once #include "MMDevice.h" #include "MMDeviceConstants.h" @@ -2500,6 +2496,3 @@ class CStateDeviceBase : public CDeviceBase _end_time = GetCurrentMMTime(); \ LogTimeDiff(_start_time,_end_time, true); \ } - -#endif //_DEVICE_BASE_H_ - diff --git a/MMDevice/DeviceUtils.h b/MMDevice/DeviceUtils.h index 8d5e1ac0f..bee2f5ce1 100644 --- a/MMDevice/DeviceUtils.h +++ b/MMDevice/DeviceUtils.h @@ -17,13 +17,10 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. // -// CVS: $Id$ -// -#ifndef _DEVICEUTILS_H_ -#define _DEVICEUTILS_H_ +#pragma once -#include "../MMDevice/MMDeviceConstants.h" +#include "MMDeviceConstants.h" #include #include #ifdef _WIN32 @@ -69,5 +66,3 @@ class CDeviceUtils private: static char m_pszBuffer[MM::MaxStrLength]; }; - -#endif //_DEVICEUTILS_H_ diff --git a/MMDevice/ImageMetadata.h b/MMDevice/ImageMetadata.h index 651d74c28..73f375e92 100644 --- a/MMDevice/ImageMetadata.h +++ b/MMDevice/ImageMetadata.h @@ -19,10 +19,8 @@ // IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. -// CVS: $Id: Configuration.h 2 2007-02-27 23:33:17Z nenad $ -// -#ifndef _IMAGE_METADATA_H_ -#define _IMAGE_METADATA_H_ + +#pragma once #ifdef WIN32 // disable exception scpecification warnings in MSVC @@ -494,6 +492,4 @@ class Metadata std::map tags_; typedef std::map::iterator TagIter; typedef std::map::const_iterator TagConstIter; -}; - -#endif //_IMAGE_METADATA_H_ \ No newline at end of file +}; \ No newline at end of file diff --git a/MMDevice/ImgBuffer.h b/MMDevice/ImgBuffer.h index ce31dd11e..6c3badac8 100644 --- a/MMDevice/ImgBuffer.h +++ b/MMDevice/ImgBuffer.h @@ -18,10 +18,8 @@ // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. // // NOTE: Imported from ADVI for use in Micro-Manager -/////////////////////////////////////////////////////////////////////////////// -#if !defined(_IMG_BUFFER_) -#define _IMG_BUFFER_ +#pragma once #include @@ -71,5 +69,3 @@ class ImgBuffer std::string name_; Metadata metadata_; }; - -#endif // !defined(_IMG_BUFFER_) diff --git a/MMDevice/MMDevice.h b/MMDevice/MMDevice.h index 6b53c047b..e4be5ebe3 100644 --- a/MMDevice/MMDevice.h +++ b/MMDevice/MMDevice.h @@ -22,6 +22,7 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. +#pragma once /////////////////////////////////////////////////////////////////////////////// // Header version @@ -30,7 +31,6 @@ #define DEVICE_INTERFACE_VERSION 71 /////////////////////////////////////////////////////////////////////////////// - // N.B. // // Never add parameters or return values that are not POD @@ -39,11 +39,6 @@ // is not acceptable (use const char*). This is to prevent inter-DLL // incompatibilities. - -#pragma once -#ifndef MMMMDEVICE_H -#define MMMMDEVICE_H - #include "MMDeviceConstants.h" #include "DeviceUtils.h" #include "ImageMetadata.h" @@ -1364,6 +1359,3 @@ namespace MM { }; } // namespace MM - -#endif //MMMMDEVICE_H - diff --git a/MMDevice/MMDeviceConstants.h b/MMDevice/MMDeviceConstants.h index 058572b91..23c8cbc18 100644 --- a/MMDevice/MMDeviceConstants.h +++ b/MMDevice/MMDeviceConstants.h @@ -18,11 +18,8 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. // -// CVS: $Id$ -// -#ifndef _MMDEVICE_CONSTANTS_H_ -#define _MMDEVICE_CONSTANTS_H_ +#pragma once /////////////////////////////////////////////////////////////////////////////// // Global error codes @@ -267,5 +264,3 @@ namespace MM { }; } // namespace MM - -#endif //_MMDEVICE_CONSTANTS_H_ diff --git a/MMDevice/ModuleInterface.h b/MMDevice/ModuleInterface.h index 465f56afb..5faef75f6 100644 --- a/MMDevice/ModuleInterface.h +++ b/MMDevice/ModuleInterface.h @@ -25,8 +25,7 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. -#ifndef _MODULE_INTERFACE_H_ -#define _MODULE_INTERFACE_H_ +#pragma once #include "MMDevice.h" @@ -136,6 +135,3 @@ extern "C" { * \see InitializeModuleData() */ void RegisterDevice(const char* deviceName, MM::DeviceType deviceType, const char* description); - - -#endif //_MODULE_INTERFACE_H_ diff --git a/MMDevice/Property.h b/MMDevice/Property.h index bc2acfb0f..24c1a8920 100644 --- a/MMDevice/Property.h +++ b/MMDevice/Property.h @@ -17,11 +17,9 @@ // IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. -// CVS: $Id$ // -#ifndef _MMPROPERTY_H_ -#define _MMPROPERTY_H_ +#pragma once #include "MMDeviceConstants.h" @@ -465,4 +463,3 @@ class PropertyCollection } // namespace MM -#endif //_MMPROPERTY_H_ From 4b88884f946ef748ce2b11adf54d14fc14a2a76e Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Fri, 8 Dec 2023 17:01:24 -0600 Subject: [PATCH 3/7] MMCore: Avoid 'using namespace' Mostly by adding 'std::', but as an exception, 'endl' has been replaced with \n (which is exactly equivalent but without flushing). --- MMCore/Configuration.cpp | 28 +++-- MMCore/CoreProperty.cpp | 40 +++---- MMCore/LogManager.cpp | 64 +++++------ MMCore/MMCore.cpp | 240 +++++++++++++++++++-------------------- 4 files changed, 183 insertions(+), 189 deletions(-) diff --git a/MMCore/Configuration.cpp b/MMCore/Configuration.cpp index 87ae0b1ee..32c8fa8ae 100644 --- a/MMCore/Configuration.cpp +++ b/MMCore/Configuration.cpp @@ -21,17 +21,15 @@ #include "Configuration.h" #include "../MMDevice/MMDevice.h" #include "Error.h" -#include -#include -#include + #include #include +#include +#include -using namespace std; - -string PropertySetting::generateKey(const char* device, const char* prop) +std::string PropertySetting::generateKey(const char* device, const char* prop) { - string key(device); + std::string key(device); key += "-"; key += prop; return key; @@ -40,9 +38,9 @@ string PropertySetting::generateKey(const char* device, const char* prop) /** * Returns verbose description of the object's contents. */ -string PropertySetting::getVerbose() const +std::string PropertySetting::getVerbose() const { - ostringstream txt; + std::ostringstream txt; txt << deviceLabel_ << ":" << propertyName_ << "=" << value_; return txt.str(); } @@ -93,7 +91,7 @@ PropertySetting Configuration::getSetting(size_t index) const throw (CMMError) bool Configuration::isPropertyIncluded(const char* device, const char* prop) { - map::iterator it = index_.find(PropertySetting::generateKey(device, prop)); + std::map::iterator it = index_.find(PropertySetting::generateKey(device, prop)); if (it != index_.end()) return true; else @@ -106,7 +104,7 @@ bool Configuration::isPropertyIncluded(const char* device, const char* prop) PropertySetting Configuration::getSetting(const char* device, const char* prop) { - map::iterator it = index_.find(PropertySetting::generateKey(device, prop)); + std::map::iterator it = index_.find(PropertySetting::generateKey(device, prop)); if (it == index_.end()) { std::ostringstream errTxt; @@ -128,7 +126,7 @@ PropertySetting Configuration::getSetting(const char* device, const char* prop) bool Configuration::isSettingIncluded(const PropertySetting& ps) { - map::iterator it = index_.find(ps.getKey()); + std::map::iterator it = index_.find(ps.getKey()); if (it != index_.end() && settings_[it->second].getPropertyValue().compare(ps.getPropertyValue()) == 0) return true; else @@ -143,7 +141,7 @@ bool Configuration::isSettingIncluded(const PropertySetting& ps) bool Configuration::isConfigurationIncluded(const Configuration& cfg) { - vector::const_iterator it; + std::vector::const_iterator it; for (it=cfg.settings_.begin(); it!=cfg.settings_.end(); ++it) if (!isSettingIncluded(*it)) return false; @@ -156,7 +154,7 @@ bool Configuration::isConfigurationIncluded(const Configuration& cfg) */ void Configuration::addSetting(const PropertySetting& setting) { - map::iterator it = index_.find(setting.getKey()); + std::map::iterator it = index_.find(setting.getKey()); if (it != index_.end()) { // replace @@ -175,7 +173,7 @@ void Configuration::addSetting(const PropertySetting& setting) */ void Configuration::deleteSetting(const char* device, const char* prop) { - map::iterator it = index_.find(PropertySetting::generateKey(device, prop)); + std::map::iterator it = index_.find(PropertySetting::generateKey(device, prop)); if (it == index_.end()) { std::ostringstream errTxt; diff --git a/MMCore/CoreProperty.cpp b/MMCore/CoreProperty.cpp index ad08fb44d..ce5a43f5d 100644 --- a/MMCore/CoreProperty.cpp +++ b/MMCore/CoreProperty.cpp @@ -29,14 +29,14 @@ #include "MMCore.h" #include "Error.h" #include "../MMDevice/DeviceUtils.h" -#include -#include -using namespace std; -vector CoreProperty::GetAllowedValues() const +#include +#include + +std::vector CoreProperty::GetAllowedValues() const { - vector allowedVals; - for (set::const_iterator it=values_.begin(); it!=values_.end(); ++it) + std::vector allowedVals; + for (std::set::const_iterator it=values_.begin(); it!=values_.end(); ++it) allowedVals.push_back(*it); return allowedVals; } @@ -51,7 +51,7 @@ bool CoreProperty::IsAllowed(const char* value) const if (values_.size() == 0) return true; - set::const_iterator it; + std::set::const_iterator it; if (values_.find(value) == values_.end()) return false; else @@ -67,14 +67,14 @@ bool CoreProperty::Set(const char* value) return true; } -string CoreProperty::Get() const +std::string CoreProperty::Get() const { return value_; } void CorePropertyCollection::Set(const char* propName, const char* value) { - map::iterator it = properties_.find(propName); + std::map::iterator it = properties_.find(propName); if (it == properties_.end()) throw CMMError("Cannot set invalid Core property (" + ToString(propName) + ") to value \"" + ToString(value) + "\"", @@ -173,9 +173,9 @@ void CorePropertyCollection::Execute(const char* propName, const char* value) } } -string CorePropertyCollection::Get(const char* propName) const +std::string CorePropertyCollection::Get(const char* propName) const { - map::const_iterator it = properties_.find(propName); + std::map::const_iterator it = properties_.find(propName); if (it == properties_.end()) throw CMMError("Cannot get value of invalid Core property (" + ToString(propName) + ")", @@ -186,17 +186,17 @@ string CorePropertyCollection::Get(const char* propName) const bool CorePropertyCollection::Has(const char* propName) const { - map::const_iterator it = properties_.find(propName); + std::map::const_iterator it = properties_.find(propName); if (it == properties_.end()) return false; // not defined return true; } -vector CorePropertyCollection::GetNames() const +std::vector CorePropertyCollection::GetNames() const { - vector names; - for (map::const_iterator it=properties_.begin(); it!=properties_.end(); ++it) + std::vector names; + for (std::map::const_iterator it=properties_.begin(); it!=properties_.end(); ++it) names.push_back(it->first); return names; } @@ -245,7 +245,7 @@ void CorePropertyCollection::Refresh() bool CorePropertyCollection::IsReadOnly(const char* propName) const { - map::const_iterator it = properties_.find(propName); + std::map::const_iterator it = properties_.find(propName); if (it == properties_.end()) throw CMMError("Invalid Core property (" + ToString(propName) + ")", MMERR_InvalidCoreProperty); @@ -253,9 +253,9 @@ bool CorePropertyCollection::IsReadOnly(const char* propName) const return it->second.IsReadOnly(); } -vector CorePropertyCollection::GetAllowedValues(const char* propName) const +std::vector CorePropertyCollection::GetAllowedValues(const char* propName) const { - map::const_iterator it = properties_.find(propName); + std::map::const_iterator it = properties_.find(propName); if (it == properties_.end()) throw CMMError("Invalid Core property (" + ToString(propName) + ")", MMERR_InvalidCoreProperty); @@ -265,7 +265,7 @@ vector CorePropertyCollection::GetAllowedValues(const char* propName) co void CorePropertyCollection::ClearAllowedValues(const char* propName) { - map::iterator it = properties_.find(propName); + std::map::iterator it = properties_.find(propName); if (it == properties_.end()) throw CMMError("Invalid Core property (" + ToString(propName) + ")", MMERR_InvalidCoreProperty); @@ -275,7 +275,7 @@ void CorePropertyCollection::ClearAllowedValues(const char* propName) void CorePropertyCollection::AddAllowedValue(const char* propName, const char* value) { - map::iterator it = properties_.find(propName); + std::map::iterator it = properties_.find(propName); if (it == properties_.end()) throw CMMError("Invalid Core property (" + ToString(propName) + ")", MMERR_InvalidCoreProperty); diff --git a/MMCore/LogManager.cpp b/MMCore/LogManager.cpp index 2b2ae5ca3..bee41e1a2 100644 --- a/MMCore/LogManager.cpp +++ b/MMCore/LogManager.cpp @@ -11,21 +11,19 @@ namespace mm { -using namespace mm::logging; - namespace { -const char* StringForLogLevel(LogLevel level) +const char* StringForLogLevel(logging::LogLevel level) { switch (level) { - case LogLevelTrace: return "trace"; - case LogLevelDebug: return "debug"; - case LogLevelInfo: return "info"; - case LogLevelWarning: return "warning"; - case LogLevelError: return "error"; - case LogLevelFatal: return "fatal"; + case logging::LogLevelTrace: return "trace"; + case logging::LogLevelDebug: return "debug"; + case logging::LogLevelInfo: return "info"; + case logging::LogLevelWarning: return "warning"; + case logging::LogLevelError: return "error"; + case logging::LogLevelFatal: return "fatal"; default: return "(unknown)"; } } @@ -35,9 +33,9 @@ const char* StringForLogLevel(LogLevel level) const logging::SinkMode LogManager::PrimarySinkMode = logging::SinkModeAsynchronous; LogManager::LogManager() : - loggingCore_(std::make_shared()), + loggingCore_(std::make_shared()), internalLogger_(loggingCore_->NewLogger("LogManager")), - primaryLogLevel_(LogLevelInfo), + primaryLogLevel_(logging::LogLevelInfo), usingStdErr_(false), nextSecondaryHandle_(0) {} @@ -56,9 +54,9 @@ LogManager::SetUseStdErr(bool flag) { if (!stdErrSink_) { - stdErrSink_ = std::make_shared(); + stdErrSink_ = std::make_shared(); stdErrSink_->SetFilter( - std::make_shared(primaryLogLevel_)); + std::make_shared(primaryLogLevel_)); } loggingCore_->AddSink(stdErrSink_, PrimarySinkMode); @@ -102,12 +100,12 @@ LogManager::SetPrimaryLogFilename(const std::string& filename, bool truncate) return; } - std::shared_ptr newSink; + std::shared_ptr newSink; try { - newSink = std::make_shared(primaryFilename_, !truncate); + newSink = std::make_shared(primaryFilename_, !truncate); } - catch (const CannotOpenFileException&) + catch (const logging::CannotOpenFileException&) { LOG_ERROR(internalLogger_) << "Failed to open file " << filename << " as primary log file"; @@ -121,7 +119,7 @@ LogManager::SetPrimaryLogFilename(const std::string& filename, bool truncate) throw CMMError("Cannot open file " + ToQuotedString(filename)); } - newSink->SetFilter(std::make_shared(primaryLogLevel_)); + newSink->SetFilter(std::make_shared(primaryLogLevel_)); if (!primaryFileSink_) { @@ -137,8 +135,8 @@ LogManager::SetPrimaryLogFilename(const std::string& filename, bool truncate) // rotation. LOG_INFO(internalLogger_) << "Switching primary log file"; - std::vector< std::pair, SinkMode> > toRemove; - std::vector< std::pair, SinkMode> > toAdd; + std::vector, logging::SinkMode>> toRemove; + std::vector, logging::SinkMode>> toAdd; toRemove.push_back( std::make_pair(primaryFileSink_, PrimarySinkMode)); toAdd.push_back(std::make_pair(newSink, PrimarySinkMode)); @@ -169,26 +167,26 @@ LogManager::IsUsingPrimaryLogFile() const void -LogManager::SetPrimaryLogLevel(LogLevel level) +LogManager::SetPrimaryLogLevel(logging::LogLevel level) { std::lock_guard lock(mutex_); if (level == primaryLogLevel_) return; - LogLevel oldLevel = primaryLogLevel_; + logging::LogLevel oldLevel = primaryLogLevel_; primaryLogLevel_ = level; LOG_INFO(internalLogger_) << "Switching primary log level from " << StringForLogLevel(oldLevel) << " to " << StringForLogLevel(level); - std::shared_ptr filter = - std::make_shared(level); + std::shared_ptr filter = + std::make_shared(level); std::vector< std::pair< - std::pair, SinkMode>, - std::shared_ptr + std::pair, logging::SinkMode>, + std::shared_ptr > > changes; if (stdErrSink_) @@ -211,7 +209,7 @@ LogManager::SetPrimaryLogLevel(LogLevel level) } -LogLevel +logging::LogLevel LogManager::GetPrimaryLogLevel() const { std::lock_guard lock(mutex_); @@ -220,24 +218,24 @@ LogManager::GetPrimaryLogLevel() const LogManager::LogFileHandle -LogManager::AddSecondaryLogFile(LogLevel level, - const std::string& filename, bool truncate, SinkMode mode) +LogManager::AddSecondaryLogFile(logging::LogLevel level, + const std::string& filename, bool truncate, logging::SinkMode mode) { std::lock_guard lock(mutex_); - std::shared_ptr sink; + std::shared_ptr sink; try { - sink = std::make_shared(filename, !truncate); + sink = std::make_shared(filename, !truncate); } - catch (const CannotOpenFileException&) + catch (const logging::CannotOpenFileException&) { LOG_ERROR(internalLogger_) << "Failed to open file " << filename << " as secondary log file"; throw CMMError("Cannot open file " + ToQuotedString(filename)); } - sink->SetFilter(std::make_shared(level)); + sink->SetFilter(std::make_shared(level)); LogFileHandle handle = nextSecondaryHandle_++; secondaryLogFiles_.insert(std::make_pair(handle, @@ -273,7 +271,7 @@ LogManager::RemoveSecondaryLogFile(LogManager::LogFileHandle handle) } -Logger +logging::Logger LogManager::NewLogger(const std::string& label) { return loggingCore_->NewLogger(label); diff --git a/MMCore/MMCore.cpp b/MMCore/MMCore.cpp index e2c7107f6..5d01bf21b 100644 --- a/MMCore/MMCore.cpp +++ b/MMCore/MMCore.cpp @@ -65,8 +65,6 @@ #include #include -using namespace std; - /* * Important! Read this before changing this file: * @@ -351,10 +349,10 @@ void CMMCore::stopSecondaryLogFile(int handle) throw (CMMError) /** * Displays core version. */ -string CMMCore::getVersionInfo() const +std::string CMMCore::getVersionInfo() const { - ostringstream txt; - string debug; + std::ostringstream txt; + std::string debug; txt << "MMCore version " << MMCore_versionMajor << "." << MMCore_versionMinor << "." << MMCore_versionPatch; #ifdef _DEBUG txt << " (debug)"; @@ -419,9 +417,9 @@ CMMCore::getAvailableDeviceTypes(const char* moduleName) throw (CMMError) /** * Returns the module and device interface versions. */ -string CMMCore::getAPIVersionInfo() const +std::string CMMCore::getAPIVersionInfo() const { - ostringstream txt; + std::ostringstream txt; txt << "Device API version " << DEVICE_INTERFACE_VERSION << ", " << "Module API version " << MODULE_INTERFACE_VERSION; return txt.str(); } @@ -438,8 +436,8 @@ string CMMCore::getAPIVersionInfo() const Configuration CMMCore::getSystemState() { Configuration config; - vector devices = deviceManager_->GetDeviceList(); - for (vector::const_iterator i = devices.begin(), dend = devices.end(); i != dend; ++i) + std::vector devices = deviceManager_->GetDeviceList(); + for (std::vector::const_iterator i = devices.begin(), dend = devices.end(); i != dend; ++i) { std::shared_ptr pDev = deviceManager_->GetDevice(*i); mm::DeviceModuleLockGuard guard(pDev); @@ -473,11 +471,11 @@ Configuration CMMCore::getSystemState() } // add core properties - vector coreProps = properties_->GetNames(); + std::vector coreProps = properties_->GetNames(); for (unsigned i=0; i < coreProps.size(); i++) { - string name = coreProps[i]; - string val = properties_->Get(name.c_str()); + std::string name = coreProps[i]; + std::string val = properties_->Get(name.c_str()); config.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, name.c_str(), val.c_str(), properties_->IsReadOnly(name.c_str()))); } @@ -507,7 +505,7 @@ Configuration CMMCore::getConfigState(const char* group, const char* config) thr for (size_t i=0; i < cfgData.size(); i++) { PropertySetting cs = cfgData.getSetting(i); // config setting - string value = getProperty(cs.getDeviceLabel().c_str(), cs.getPropertyName().c_str()); + std::string value = getProperty(cs.getDeviceLabel().c_str(), cs.getPropertyName().c_str()); PropertySetting ss(cs.getDeviceLabel().c_str(), cs.getPropertyName().c_str(), value.c_str()); // state setting state.addSetting(ss); } @@ -844,7 +842,7 @@ void CMMCore::reset() throw (CMMError) */ void CMMCore::initializeAllDevices() throw (CMMError) { - vector devices = deviceManager_->GetDeviceList(); + std::vector devices = deviceManager_->GetDeviceList(); LOG_INFO(coreLogger_) << "Will initialize " << devices.size() << " devices"; for (size_t i=0; i devices = getLoadedDevicesOfType(devType); + std::vector devices = getLoadedDevicesOfType(devType); devices.push_back(""); // add empty value properties_->ClearAllowedValues(propName); for (size_t i=0; i devices = deviceManager_->GetDeviceList(); - vector::reverse_iterator it; + std::vector devices = deviceManager_->GetDeviceList(); + std::vector::reverse_iterator it; for (it=devices.rbegin(); it != devices.rend(); it++) { std::shared_ptr pDev = deviceManager_->GetDevice(*it); @@ -1205,7 +1203,7 @@ void CMMCore::waitForDevice(std::shared_ptr pDev) throw (CMMErro if (std::chrono::steady_clock::now() > deadline) { - string label = pDev->GetLabel(); + std::string label = pDev->GetLabel(); std::ostringstream mez; mez << "wait timed out after " << timeoutMs_ << " ms. "; logError(label.c_str(), mez.str().c_str()); @@ -1248,7 +1246,7 @@ void CMMCore::waitForSystem() throw (CMMError) */ bool CMMCore::deviceTypeBusy(MM::DeviceType devType) throw (CMMError) { - vector devices = deviceManager_->GetDeviceList(devType); + std::vector devices = deviceManager_->GetDeviceList(devType); for (size_t i=0; i devices = deviceManager_->GetDeviceList(devType); + std::vector devices = deviceManager_->GetDeviceList(devType); for (size_t i=0; i camera = currentCameraDevice_.lock(); if (camera) @@ -3174,7 +3172,7 @@ string CMMCore::getCameraDevice() * Returns the label of the currently selected shutter device. * @return shutter name */ -string CMMCore::getShutterDevice() +std::string CMMCore::getShutterDevice() { std::shared_ptr shutter = currentShutterDevice_.lock(); if (shutter) @@ -3188,7 +3186,7 @@ string CMMCore::getShutterDevice() * Returns the label of the currently selected focus device. * @return focus stage name */ -string CMMCore::getFocusDevice() +std::string CMMCore::getFocusDevice() { std::shared_ptr focus = currentFocusDevice_.lock(); if (focus) @@ -3201,7 +3199,7 @@ string CMMCore::getFocusDevice() /** * Returns the label of the currently selected XYStage device. */ -string CMMCore::getXYStageDevice() +std::string CMMCore::getXYStageDevice() { std::shared_ptr xyStage = currentXYStageDevice_.lock(); if (xyStage) @@ -3214,7 +3212,7 @@ string CMMCore::getXYStageDevice() /** * Returns the label of the currently selected auto-focus device. */ -string CMMCore::getAutoFocusDevice() +std::string CMMCore::getAutoFocusDevice() { std::shared_ptr autofocus = currentAutofocusDevice_.lock(); @@ -3252,7 +3250,7 @@ void CMMCore::setAutoFocusDevice(const char* autofocusLabel) throw (CMMError) /** * Returns the label of the currently selected image processor device. */ -string CMMCore::getImageProcessorDevice() +std::string CMMCore::getImageProcessorDevice() { std::shared_ptr imageProcessor = currentImageProcessor_.lock(); @@ -3267,7 +3265,7 @@ string CMMCore::getImageProcessorDevice() * Returns the label of the currently selected SLM device. * @return slm name */ -string CMMCore::getSLMDevice() +std::string CMMCore::getSLMDevice() { std::shared_ptr slm = currentSLMDevice_.lock(); if (slm) @@ -3281,7 +3279,7 @@ string CMMCore::getSLMDevice() * Returns the label of the currently selected Galvo device. * @return galvo name */ -string CMMCore::getGalvoDevice() +std::string CMMCore::getGalvoDevice() { std::shared_ptr galvos = currentGalvoDevice_.lock(); if (galvos) @@ -3399,7 +3397,7 @@ void CMMCore::setChannelGroup(const char* chGroup) throw (CMMError) /** * Returns the group determining the channel selection. */ -string CMMCore::getChannelGroup() +std::string CMMCore::getChannelGroup() { return channelGroup_; @@ -3547,7 +3545,7 @@ void CMMCore::setCameraDevice(const char* cameraLabel) throw (CMMError) * @return property name array * @param label the device label */ -vector CMMCore::getDevicePropertyNames(const char* label) throw (CMMError) +std::vector CMMCore::getDevicePropertyNames(const char* label) throw (CMMError) { if (IsCoreDeviceLabel(label)) return properties_->GetNames(); @@ -3563,9 +3561,9 @@ vector CMMCore::getDevicePropertyNames(const char* label) throw (CMMErro * Returns an array of labels for currently loaded devices. * @return array of labels */ -vector CMMCore::getLoadedDevices() const +std::vector CMMCore::getLoadedDevices() const { - vector deviceList = deviceManager_->GetDeviceList(); + std::vector deviceList = deviceManager_->GetDeviceList(); deviceList.push_back(MM::g_Keyword_CoreDevice); return deviceList; } @@ -3575,10 +3573,10 @@ vector CMMCore::getLoadedDevices() const * @param devType the device type identifier * @return array of labels */ -vector CMMCore::getLoadedDevicesOfType(MM::DeviceType devType) const +std::vector CMMCore::getLoadedDevicesOfType(MM::DeviceType devType) const { if (devType == MM::CoreDevice) { - vector coreDev; + std::vector coreDev; coreDev.push_back(MM::g_Keyword_CoreDevice); return coreDev; } @@ -3626,7 +3624,7 @@ std::vector CMMCore::getAllowedPropertyValues(const char* label, co * @param label the device label * @param propName the property name */ -string CMMCore::getProperty(const char* label, const char* propName) throw (CMMError) +std::string CMMCore::getProperty(const char* label, const char* propName) throw (CMMError) { if (IsCoreDeviceLabel(label)) return properties_->Get(propName); @@ -3654,7 +3652,7 @@ string CMMCore::getProperty(const char* label, const char* propName) throw (CMME * @param label the device label * @param propName the property name */ -string CMMCore::getPropertyFromCache(const char* label, const char* propName) const throw (CMMError) +std::string CMMCore::getPropertyFromCache(const char* label, const char* propName) const throw (CMMError) { if (IsCoreDeviceLabel(label)) return properties_->Get(propName); @@ -4116,7 +4114,7 @@ unsigned CMMCore::getNumberOfCameraChannels() /** * Returns the name of the requested channel as known by the default camera */ -string CMMCore::getCameraChannelName(unsigned int channelNr) +std::string CMMCore::getCameraChannelName(unsigned int channelNr) { std::shared_ptr camera = currentCameraDevice_.lock(); if (camera) @@ -4661,7 +4659,7 @@ void CMMCore::setStateLabel(const char* deviceLabel, const char* stateLabel) thr * @return the current state's label * @param deviceLabel the device label */ -string CMMCore::getStateLabel(const char* deviceLabel) throw (CMMError) +std::string CMMCore::getStateLabel(const char* deviceLabel) throw (CMMError) { std::shared_ptr pStateDev = deviceManager_->GetDeviceOfType(deviceLabel); @@ -4738,13 +4736,13 @@ void CMMCore::defineStateLabel(const char* deviceLabel, long state, const char* * @return an array of state labels * @param deviceLabel the device label */ -vector CMMCore::getStateLabels(const char* deviceLabel) throw (CMMError) +std::vector CMMCore::getStateLabels(const char* deviceLabel) throw (CMMError) { std::shared_ptr pStateDev = deviceManager_->GetDeviceOfType(deviceLabel); mm::DeviceModuleLockGuard guard(pStateDev); - vector stateLabels; + std::vector stateLabels; for (unsigned i=0; iGetNumberOfPositions(); i++) { stateLabels.push_back(pStateDev->GetPositionLabel(i)); @@ -4995,7 +4993,7 @@ void CMMCore::setPixelSizeConfig(const char* resolutionID) throw (CMMError) CheckConfigPresetName(resolutionID); PixelSizeConfiguration* psc = pixelSizeGroup_->Find(resolutionID); - ostringstream os; + std::ostringstream os; os << resolutionID; if (!psc) { @@ -5027,7 +5025,7 @@ void CMMCore::setConfig(const char* groupName, const char* configName) throw (CM CheckConfigPresetName(configName); Configuration* pCfg = configGroups_->Find(groupName, configName); - ostringstream os; + std::ostringstream os; os << groupName << "/" << configName; if (!pCfg) { @@ -5082,7 +5080,7 @@ void CMMCore::deleteConfig(const char* groupName, const char* configName) throw CheckConfigGroupName(groupName); CheckConfigPresetName(configName); - ostringstream os; + std::ostringstream os; os << groupName << "/" << configName; if (!configGroups_->Delete(groupName, configName)) { logError("deleteConfig", getCoreErrorText(MMERR_NoConfiguration).c_str()); @@ -5107,7 +5105,7 @@ void CMMCore::deleteConfig(const char* groupName, const char* configName, const CheckDeviceLabel(deviceLabel); CheckPropertyName(propName); - ostringstream os; + std::ostringstream os; os << groupName << "/" << configName << "/" << deviceLabel << "/" << propName; if (!configGroups_->Delete(groupName, configName, deviceLabel, propName)) { logError("deleteConfig", getCoreErrorText(MMERR_NoConfiguration).c_str()); @@ -5134,7 +5132,7 @@ void CMMCore::deleteConfig(const char* groupName, const char* configName, const * * @return an array of configuration names */ -vector CMMCore::getAvailableConfigs(const char* group) const +std::vector CMMCore::getAvailableConfigs(const char* group) const { std::vector ret; try @@ -5153,7 +5151,7 @@ vector CMMCore::getAvailableConfigs(const char* group) const * Returns the names of all defined configuration groups * @return an array of names of configuration groups */ -vector CMMCore::getAvailableConfigGroups() const +std::vector CMMCore::getAvailableConfigGroups() const { return configGroups_->GetAvailableGroups(); } @@ -5162,7 +5160,7 @@ vector CMMCore::getAvailableConfigGroups() const * Returns all defined resolution preset names * @return an array of resolution presets */ -vector CMMCore::getAvailablePixelSizeConfigs() const +std::vector CMMCore::getAvailablePixelSizeConfigs() const { return pixelSizeGroup_->GetAvailable(); } @@ -5176,11 +5174,11 @@ vector CMMCore::getAvailablePixelSizeConfigs() const * * @return The current configuration preset's name */ -string CMMCore::getCurrentConfig(const char* groupName) throw (CMMError) +std::string CMMCore::getCurrentConfig(const char* groupName) throw (CMMError) { CheckConfigGroupName(groupName); - vector cfgs = configGroups_->GetAvailableConfigs(groupName); + std::vector cfgs = configGroups_->GetAvailableConfigs(groupName); if (cfgs.empty()) return ""; @@ -5206,11 +5204,11 @@ string CMMCore::getCurrentConfig(const char* groupName) throw (CMMError) * * @return The cache's current configuration preset name */ -string CMMCore::getCurrentConfigFromCache(const char* groupName) throw (CMMError) +std::string CMMCore::getCurrentConfigFromCache(const char* groupName) throw (CMMError) { CheckConfigGroupName(groupName); - vector cfgs = configGroups_->GetAvailableConfigs(groupName); + std::vector cfgs = configGroups_->GetAvailableConfigs(groupName); if (cfgs.empty()) return ""; @@ -5241,7 +5239,7 @@ Configuration CMMCore::getConfigData(const char* groupName, const char* configNa if (!pCfg) { // not found - ostringstream os; + std::ostringstream os; os << groupName << "/" << configName; logError(os.str().c_str(), getCoreErrorText(MMERR_NoConfiguration).c_str()); throw CMMError("Configuration group " + ToQuotedString(groupName) + @@ -5264,7 +5262,7 @@ Configuration CMMCore::getPixelSizeConfigData(const char* configName) throw (CMM if (!pCfg) { // not found - ostringstream os; + std::ostringstream os; os << "Pixel size" << "/" << configName; logError(os.str().c_str(), getCoreErrorText(MMERR_NoConfiguration).c_str()); throw CMMError("Pixel size configuration preset " + ToQuotedString(configName) + @@ -5318,7 +5316,7 @@ void CMMCore::deletePixelSizeConfig(const char* configName) throw (CMMError) /** * Get the current pixel configuration name **/ -string CMMCore::getCurrentPixelSizeConfig() throw (CMMError) +std::string CMMCore::getCurrentPixelSizeConfig() throw (CMMError) { return getCurrentPixelSizeConfig(false); } @@ -5326,10 +5324,10 @@ string CMMCore::getCurrentPixelSizeConfig() throw (CMMError) /** * Get the current pixel configuration name **/ -string CMMCore::getCurrentPixelSizeConfig(bool cached) throw (CMMError) +std::string CMMCore::getCurrentPixelSizeConfig(bool cached) throw (CMMError) { // get a list of configuration names - vector cfgs = pixelSizeGroup_->GetAvailable(); + std::vector cfgs = pixelSizeGroup_->GetAvailable(); if (cfgs.empty()) return ""; @@ -5346,7 +5344,7 @@ string CMMCore::getCurrentPixelSizeConfig(bool cached) throw (CMMError) { try { - string value; + std::string value; if (!cached) { value = getProperty(cs.getDeviceLabel().c_str(), cs.getPropertyName().c_str()); @@ -5553,7 +5551,7 @@ std::vector CMMCore::getPixelSizeAffineByID(const char* resolutionID) th double CMMCore::getMagnificationFactor() const { double magnification = 1.0; - vector magnifiers = getLoadedDevicesOfType(MM::MagnifierDevice); + std::vector magnifiers = getLoadedDevicesOfType(MM::MagnifierDevice); for (size_t i=0; i magnifier = @@ -5655,12 +5653,12 @@ std::string CMMCore::getSerialPortAnswer(const char* portLabel, const char* term int ret = pSerial->GetAnswer(answerBuf, bufLen, term); if (ret != DEVICE_OK) { - string errText = getDeviceErrorText(ret, pSerial).c_str(); + std::string errText = getDeviceErrorText(ret, pSerial).c_str(); logError(portLabel, errText.c_str()); throw CMMError(errText); } - return string(answerBuf); + return std::string(answerBuf); } /** @@ -5682,7 +5680,7 @@ void CMMCore::writeToSerialPort(const char* portLabel, const std::vector & /** * Reads the contents of the Rx buffer. */ -vector CMMCore::readFromSerialPort(const char* portLabel) throw (CMMError) +std::vector CMMCore::readFromSerialPort(const char* portLabel) throw (CMMError) { std::shared_ptr pSerial = deviceManager_->GetDeviceOfType(portLabel); @@ -5697,7 +5695,7 @@ vector CMMCore::readFromSerialPort(const char* portLabel) throw (CMMError) throw CMMError(getDeviceErrorText(ret, pSerial)); } - vector data; + std::vector data; data.resize(read, 0); if (read > 0) std::memcpy(&(data[0]), answerBuf, read); @@ -6228,7 +6226,7 @@ void CMMCore::runGalvoSequence(const char* deviceLabel) throw (CMMError) /** * Get the name of the active galvo channel (for a multi-laser galvo device). */ -string CMMCore::getGalvoChannel(const char* deviceLabel) throw (CMMError) +std::string CMMCore::getGalvoChannel(const char* deviceLabel) throw (CMMError) { std::shared_ptr pGalvo = deviceManager_->GetDeviceOfType(deviceLabel); @@ -6250,8 +6248,8 @@ void CMMCore::saveSystemState(const char* fileName) throw (CMMError) if (!fileName) throw CMMError("Null filename"); - ofstream os; - os.open(fileName, ios_base::out | ios_base::trunc); + std::ofstream os; + os.open(fileName, std::ios_base::out | std::ios_base::trunc); if (!os.is_open()) { logError(fileName, getCoreErrorText(MMERR_FileOpenFailed).c_str()); @@ -6267,7 +6265,7 @@ void CMMCore::saveSystemState(const char* fileName) throw (CMMError) if (!isPropertyReadOnly(s.getDeviceLabel().c_str(), s.getPropertyName().c_str())) { os << MM::g_CFGCommand_Property << ',' << s.getDeviceLabel() - << ',' << s.getPropertyName() << ',' << s.getPropertyValue() << endl; + << ',' << s.getPropertyName() << ',' << s.getPropertyValue() << '\n'; } } } @@ -6284,8 +6282,8 @@ void CMMCore::loadSystemState(const char* fileName) throw (CMMError) if (!fileName) throw CMMError("Null filename"); - ifstream is; - is.open(fileName, ios_base::in); + std::ifstream is; + is.open(fileName, std::ios_base::in); if (!is.is_open()) { logError(fileName, getCoreErrorText(MMERR_FileOpenFailed).c_str()); @@ -6296,11 +6294,11 @@ void CMMCore::loadSystemState(const char* fileName) throw (CMMError) // Process commands const int maxLineLength = 4 * MM::MaxStrLength + 4; // accommodate up to 4 strings and delimiters char line[maxLineLength+1]; - vector tokens; + std::vector tokens; while(is.getline(line, maxLineLength, '\n')) { // strip a potential Windows/dos CR - istringstream il(line); + std::istringstream il(line); il.getline(line, maxLineLength, '\r'); if (strlen(line) > 0) { @@ -6357,8 +6355,8 @@ void CMMCore::saveSystemConfiguration(const char* fileName) throw (CMMError) if (!fileName) throw CMMError("Null filename"); - ofstream os; - os.open(fileName, ios_base::out | ios_base::trunc); + std::ofstream os; + os.open(fileName, std::ios_base::out | std::ios_base::trunc); if (!os.is_open()) { logError(fileName, getCoreErrorText(MMERR_FileOpenFailed).c_str()); @@ -6368,22 +6366,22 @@ void CMMCore::saveSystemConfiguration(const char* fileName) throw (CMMError) // insert the system reset command // this will unload all current devices - os << "# Unload all devices" << endl; - os << "Property,Core,Initialize,0" << endl; + os << "# Unload all devices\n"; + os << "Property,Core,Initialize,0\n"; // save device list - os << "# Load devices" << endl; - vector devices = deviceManager_->GetDeviceList(); - vector::const_iterator it; + os << "# Load devices\n"; + std::vector devices = deviceManager_->GetDeviceList(); + std::vector::const_iterator it; for (it=devices.begin(); it != devices.end(); it++) { std::shared_ptr pDev = deviceManager_->GetDevice(*it); mm::DeviceModuleLockGuard guard(pDev); - os << MM::g_CFGCommand_Device << "," << *it << "," << pDev->GetAdapterModule()->GetName() << "," << pDev->GetName() << endl; + os << MM::g_CFGCommand_Device << "," << *it << "," << pDev->GetAdapterModule()->GetName() << "," << pDev->GetName() << '\n'; } // save the pre-initialization properties - os << "# Pre-initialization properties" << endl; + os << "# Pre-initialization properties\n"; Configuration config = getSystemState(); for (size_t i=0; i device = deviceManager_->GetDevice(*it); @@ -6414,22 +6412,22 @@ void CMMCore::saveSystemConfiguration(const char* fileName) throw (CMMError) std::string parentID = device->GetParentID(); if (!parentID.empty()) { - os << MM::g_CFGCommand_ParentID << ',' << device->GetLabel() << ',' << parentID << endl; + os << MM::g_CFGCommand_ParentID << ',' << device->GetLabel() << ',' << parentID << '\n'; } } // insert the initialize command - os << "Property,Core,Initialize,1" << endl; + os << "Property,Core,Initialize,1\n"; // save delays - os << "# Delays" << endl; + os << "# Delays\n"; for (it=devices.begin(); it != devices.end(); it++) { std::shared_ptr pDev = deviceManager_->GetDevice(*it); mm::DeviceModuleLockGuard guard(pDev); if (pDev->GetDelayMs() > 0.0) - os << MM::g_CFGCommand_Delay << "," << *it << "," << pDev->GetDelayMs() << endl; + os << MM::g_CFGCommand_Delay << "," << *it << "," << pDev->GetDelayMs() << '\n'; } // save focus directions @@ -6448,8 +6446,8 @@ void CMMCore::saveSystemConfiguration(const char* fileName) throw (CMMError) } // save labels - os << "# Labels" << endl; - vector deviceLabels = deviceManager_->GetDeviceList(MM::StateDevice); + os << "# Labels\n"; + std::vector deviceLabels = deviceManager_->GetDeviceList(MM::StateDevice); for (size_t i=0; i pSD = @@ -6470,20 +6468,20 @@ void CMMCore::saveSystemConfiguration(const char* fileName) throw (CMMError) } if (!stateLabel.empty()) { - os << MM::g_CFGCommand_Label << ',' << deviceLabels[i] << ',' << j << ',' << stateLabel << endl; + os << MM::g_CFGCommand_Label << ',' << deviceLabels[i] << ',' << j << ',' << stateLabel << '\n'; } } } // save configuration groups - os << "# Group configurations" << endl; - vector groups = getAvailableConfigGroups(); + os << "# Group configurations\n"; + std::vector groups = getAvailableConfigGroups(); for (size_t i=0; i configs = getAvailableConfigs(groups[i].c_str()); + std::vector configs = getAvailableConfigs(groups[i].c_str()); if (configs.size() == 0) - os << MM::g_CFGCommand_ConfigGroup << ',' << groups[i] << endl; + os << MM::g_CFGCommand_ConfigGroup << ',' << groups[i] << '\n'; // normal group records for (size_t j=0; j camera = currentCameraDevice_.lock(); if (camera) { - os << MM::g_CFGCommand_Property << ',' << MM::g_Keyword_CoreDevice << ',' << MM::g_Keyword_CoreCamera << ',' << camera->GetLabel() << endl; + os << MM::g_CFGCommand_Property << ',' << MM::g_Keyword_CoreDevice << ',' << MM::g_Keyword_CoreCamera << ',' << camera->GetLabel() << '\n'; } std::shared_ptr shutter = currentShutterDevice_.lock(); if (shutter) { - os << MM::g_CFGCommand_Property << ',' << MM::g_Keyword_CoreDevice << ',' << MM::g_Keyword_CoreShutter << ',' << shutter->GetLabel() << endl; + os << MM::g_CFGCommand_Property << ',' << MM::g_Keyword_CoreDevice << ',' << MM::g_Keyword_CoreShutter << ',' << shutter->GetLabel() << '\n'; } std::shared_ptr focus = currentFocusDevice_.lock(); if (focus) { - os << MM::g_CFGCommand_Property << ',' << MM::g_Keyword_CoreDevice << ',' << MM::g_Keyword_CoreFocus << ',' << focus->GetLabel() << endl; + os << MM::g_CFGCommand_Property << ',' << MM::g_Keyword_CoreDevice << ',' << MM::g_Keyword_CoreFocus << ',' << focus->GetLabel() << '\n'; } } @@ -6575,8 +6573,8 @@ void CMMCore::loadSystemConfigurationImpl(const char* fileName) throw (CMMError) if (!fileName) throw CMMError("Null filename"); - ifstream is; - is.open(fileName, ios_base::in); + std::ifstream is; + is.open(fileName, std::ios_base::in); if (!is.is_open()) { logError(fileName, getCoreErrorText(MMERR_FileOpenFailed).c_str()); @@ -6587,14 +6585,14 @@ void CMMCore::loadSystemConfigurationImpl(const char* fileName) throw (CMMError) // Process commands const int maxLineLength = 4 * MM::MaxStrLength + 4; // accommodate up to 4 strings and delimiters char line[maxLineLength+1]; - vector tokens; + std::vector tokens; int lineCount = 0; while(is.getline(line, maxLineLength, '\n')) { // strip a potential Windows/dos CR - istringstream il(line); + std::istringstream il(line); il.getline(line, maxLineLength, '\r'); lineCount++; @@ -6776,8 +6774,8 @@ void CMMCore::loadSystemConfigurationImpl(const char* fileName) throw (CMMError) if (externalCallback_) externalCallback_->onSystemConfigurationLoaded(); std::ostringstream errorText; - errorText << "Line " << lineCount << ": " << line << endl; - errorText << err.getFullMsg() << endl << endl; + errorText << "Line " << lineCount << ": " << line << '\n'; + errorText << err.getFullMsg() << "\n\n"; throw CMMError(errorText.str().c_str(), MMERR_InvalidConfigurationFile); } } @@ -7259,7 +7257,7 @@ void CMMCore::applyConfiguration(const Configuration& config) throw (CMMError) { std::ostringstream sall; bool error = false; - vector failedProps; + std::vector failedProps; for (size_t i=0; i (unsigned) applyProperties(failedProps, errorString) ) { if (failedProps.size() == 0) @@ -7316,10 +7314,10 @@ void CMMCore::applyConfiguration(const Configuration& config) throw (CMMError) * properties until there are none left or none succeed * returns number of properties successfully set */ -int CMMCore::applyProperties(vector& props, string& lastError) +int CMMCore::applyProperties(std::vector& props, std::string& lastError) { // int succeeded = 0; - vector failedProps; + std::vector failedProps; for (size_t i=0; i& props, string& lastError) -string CMMCore::getDeviceErrorText(int deviceCode, std::shared_ptr device) +std::string CMMCore::getDeviceErrorText(int deviceCode, std::shared_ptr device) { if (!device) { @@ -7366,11 +7364,11 @@ string CMMCore::getDeviceErrorText(int deviceCode, std::shared_ptr::const_iterator it; + std::string txt; + std::map::const_iterator it; it = errorText_.find(code); if (it != errorText_.end()) txt = it->second; @@ -7384,7 +7382,7 @@ void CMMCore::logError(const char* device, const char* msg) LOG_ERROR(coreLogger_) << "Error occurred in device " << device << ": " << msg; } -string CMMCore::getDeviceName(std::shared_ptr pDev) +std::string CMMCore::getDeviceName(std::shared_ptr pDev) { mm::DeviceModuleLockGuard guard(pDev); return pDev->GetName(); From e28383c56f01eaefdbf43877e8e8ea8e0c47c32f Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Fri, 8 Dec 2023 17:05:43 -0600 Subject: [PATCH 4/7] MMCore: Use #pragma once consistently --- MMCore/ConfigGroup.h | 10 ++-------- MMCore/Configuration.h | 8 ++------ MMCore/CoreCallback.h | 5 +---- MMCore/CoreProperty.h | 9 ++------- MMCore/Error.h | 5 +---- MMCore/MMCore.h | 7 ++----- MMCore/PluginManager.h | 6 +----- 7 files changed, 11 insertions(+), 39 deletions(-) diff --git a/MMCore/ConfigGroup.h b/MMCore/ConfigGroup.h index 0a8d705ed..050020815 100644 --- a/MMCore/ConfigGroup.h +++ b/MMCore/ConfigGroup.h @@ -19,11 +19,8 @@ // IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. -// -// CVS: $Id: ConfigGroup.h 17248 2020-01-25 19:49:51Z nico $ -// -#ifndef _CONFIG_GROUP_H_ -#define _CONFIG_GROUP_H_ + +#pragma once #include "Configuration.h" #include "Error.h" @@ -439,6 +436,3 @@ class PixelSizeConfigGroup : public ConfigGroupBase } } }; - -#endif - diff --git a/MMCore/Configuration.h b/MMCore/Configuration.h index 133321259..ea171bc6c 100644 --- a/MMCore/Configuration.h +++ b/MMCore/Configuration.h @@ -17,10 +17,8 @@ // IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. -// CVS: $Id: Configuration.h 16305 2017-02-11 05:01:12Z mark $ -// -#ifndef _CONFIGURATION_H_ -#define _CONFIGURATION_H_ + +#pragma once #ifdef WIN32 // disable exception scpecification warnings in MSVC @@ -120,5 +118,3 @@ class Configuration std::vector settings_; std::map index_; }; - -#endif //_CONFIGURATION_H_ diff --git a/MMCore/CoreCallback.h b/MMCore/CoreCallback.h index 29be56f9e..275493b42 100644 --- a/MMCore/CoreCallback.h +++ b/MMCore/CoreCallback.h @@ -22,8 +22,7 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. -#ifndef _CORECALLBACK_H_ -#define _CORECALLBACK_H_ +#pragma once #include "Devices/DeviceInstances.h" #include "CoreUtils.h" @@ -147,5 +146,3 @@ class CoreCallback : public MM::Core int OnPixelSizeChanged(double newPixelSizeUm); int OnPixelSizeAffineChanged(std::vector newPixelSizeAffine); }; - -#endif // _CORECALLBACK_H_ diff --git a/MMCore/CoreProperty.h b/MMCore/CoreProperty.h index 1b3306539..07ddb7af7 100644 --- a/MMCore/CoreProperty.h +++ b/MMCore/CoreProperty.h @@ -21,10 +21,8 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. // -// CVS: $Id: CoreProperty.h 8004 2011-10-27 04:58:53Z nico $ -// -#ifndef _CORE_PROPERTY_H -#define _CORE_PROPERTY_H + +#pragma once #include #include @@ -83,6 +81,3 @@ class CorePropertyCollection CMMCore* core_; std::map properties_; }; - -#endif - diff --git a/MMCore/Error.h b/MMCore/Error.h index 9a2e835ad..00cc017ec 100644 --- a/MMCore/Error.h +++ b/MMCore/Error.h @@ -22,8 +22,7 @@ // AUTHOR: Nenad Amodaj, nenad@amodaj.com, 09/19/2005 // Mark Tsuchida, 12/04/2013 (made chainable) -#ifndef _ERROR_H_ -#define _ERROR_H_ +#pragma once #include "ErrorCodes.h" @@ -158,5 +157,3 @@ class CMMError : public std::exception Code code_; std::unique_ptr underlying_; }; - -#endif //_ERROR_H_ diff --git a/MMCore/MMCore.h b/MMCore/MMCore.h index 79b2af386..6264bda8f 100644 --- a/MMCore/MMCore.h +++ b/MMCore/MMCore.h @@ -36,6 +36,8 @@ // because public method names appear as wrapped methods in other // languages, in particular Java. +#pragma once + /* * Important! Read this before changing this file. * @@ -43,9 +45,6 @@ * file (MMCore.cpp). */ -#ifndef _MMCORE_H_ -#define _MMCORE_H_ - #ifdef _MSC_VER // We use exception specifications to instruct SWIG to generate the correct // exception specifications for Java. Turn off the warnings that VC++ issues by @@ -693,5 +692,3 @@ class CMMCore void updateCoreProperty(const char* propName, MM::DeviceType devType) throw (CMMError); void loadSystemConfigurationImpl(const char* fileName) throw (CMMError); }; - -#endif //_MMCORE_H_ diff --git a/MMCore/PluginManager.h b/MMCore/PluginManager.h index aa3b1aa45..d61ad0686 100644 --- a/MMCore/PluginManager.h +++ b/MMCore/PluginManager.h @@ -20,9 +20,7 @@ // // AUTHOR: Nenad Amodaj, nenad@amodaj.com, 08/10/2005 -#ifndef _PLUGIN_MANAGER_H_ -#define _PLUGIN_MANAGER_H_ - +#pragma once #include "../MMDevice/DeviceThreads.h" @@ -66,5 +64,3 @@ class CPluginManager /* final */ std::map< std::string, std::shared_ptr > moduleMap_; }; - -#endif //_PLUGIN_MANAGER_H_ From 948375890fbf6f4ec8037f854ccede910e0e8dca Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Fri, 8 Dec 2023 17:10:17 -0600 Subject: [PATCH 5/7] DemoCamera: Avoid 'using namespace std' --- DeviceAdapters/DemoCamera/DemoCamera.cpp | 17 +++++++---------- DeviceAdapters/DemoCamera/DemoCamera.h | 7 +------ DeviceAdapters/DemoCamera/WriteCompactTiffRGB.h | 5 +---- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/DeviceAdapters/DemoCamera/DemoCamera.cpp b/DeviceAdapters/DemoCamera/DemoCamera.cpp index d5dd386c0..4684fc74b 100644 --- a/DeviceAdapters/DemoCamera/DemoCamera.cpp +++ b/DeviceAdapters/DemoCamera/DemoCamera.cpp @@ -33,9 +33,6 @@ #include #include - - -using namespace std; const double CDemoCamera::nominalPixelSizeUm_ = 1.0; double g_IntensityFactor_ = 1.0; @@ -346,7 +343,7 @@ int CDemoCamera::Initialize() nRet = CreateStringProperty(MM::g_Keyword_PixelType, g_PixelType_8bit, false, pAct); assert(nRet == DEVICE_OK); - vector pixelTypeValues; + std::vector pixelTypeValues; pixelTypeValues.push_back(g_PixelType_8bit); pixelTypeValues.push_back(g_PixelType_16bit); pixelTypeValues.push_back(g_PixelType_32bitRGB); @@ -362,7 +359,7 @@ int CDemoCamera::Initialize() nRet = CreateIntegerProperty("BitDepth", 8, false, pAct); assert(nRet == DEVICE_OK); - vector bitDepths; + std::vector bitDepths; bitDepths.push_back("8"); bitDepths.push_back("10"); bitDepths.push_back("11"); @@ -1021,7 +1018,7 @@ int CDemoCamera::SendExposureSequence() const { int CDemoCamera::SetAllowedBinning() { - vector binValues; + std::vector binValues; binValues.push_back("1"); binValues.push_back("2"); if (scanMode_ < 3) @@ -1400,7 +1397,7 @@ int CDemoCamera::OnPixelType(MM::PropertyBase* pProp, MM::ActionType eAct) if(IsCapturing()) return DEVICE_CAMERA_BUSY_ACQUIRING; - string pixelType; + std::string pixelType; pProp->Get(pixelType); if (pixelType.compare(g_PixelType_8bit) == 0) @@ -3991,8 +3988,8 @@ gatedVolts_(0), open_(true), sequenceRunning_(false), sequenceIndex_(0), -sentSequence_(vector()), -nascentSequence_(vector()) +sentSequence_(std::vector()), +nascentSequence_(std::vector()) { SetErrorText(ERR_SEQUENCE_INACTIVE, "Sequence triggered, but sequence is not running"); @@ -4063,7 +4060,7 @@ int DemoDA::SetSignal(double volts) volt_ = volts; if (open_) gatedVolts_ = volts; - stringstream s; + std::stringstream s; s << "Voltage set to " << volts; LogMessage(s.str(), false); return DEVICE_OK; diff --git a/DeviceAdapters/DemoCamera/DemoCamera.h b/DeviceAdapters/DemoCamera/DemoCamera.h index acd3df13a..881db22f7 100644 --- a/DeviceAdapters/DemoCamera/DemoCamera.h +++ b/DeviceAdapters/DemoCamera/DemoCamera.h @@ -27,8 +27,7 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. -#ifndef _DEMOCAMERA_H_ -#define _DEMOCAMERA_H_ +#pragma once #include "DeviceBase.h" #include "ImgBuffer.h" @@ -1193,7 +1192,3 @@ class DemoGalvo : public CGalvoBase, ImgManipulator int offsetY_; double vMaxY_; }; - - - -#endif //_DEMOCAMERA_H_ diff --git a/DeviceAdapters/DemoCamera/WriteCompactTiffRGB.h b/DeviceAdapters/DemoCamera/WriteCompactTiffRGB.h index 71dd7bfec..0c676e965 100644 --- a/DeviceAdapters/DemoCamera/WriteCompactTiffRGB.h +++ b/DeviceAdapters/DemoCamera/WriteCompactTiffRGB.h @@ -1,3 +1,4 @@ +#pragma once #include "stdio.h" #include "math.h" @@ -240,7 +241,3 @@ void GenerateRGBTestImage( const int nx, const int ny, const char color, unsigne } } } - - - - From 2eebada3245732cb6261803f53d438d321a3e652 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Mon, 11 Dec 2023 15:46:14 -0600 Subject: [PATCH 6/7] DemoCamera: Avoid Windows.h's min/max macros --- DeviceAdapters/DemoCamera/DemoCamera.cpp | 20 ++++++++++---------- DeviceAdapters/DemoCamera/DemoCamera.vcxproj | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/DeviceAdapters/DemoCamera/DemoCamera.cpp b/DeviceAdapters/DemoCamera/DemoCamera.cpp index 4684fc74b..537ef041c 100644 --- a/DeviceAdapters/DemoCamera/DemoCamera.cpp +++ b/DeviceAdapters/DemoCamera/DemoCamera.cpp @@ -2136,7 +2136,7 @@ void CDemoCamera::GenerateSyntheticImage(ImgBuffer& img, double exp) for (k=0; k maxDrawnVal) { maxDrawnVal = val; } @@ -2169,7 +2169,7 @@ void CDemoCamera::GenerateSyntheticImage(ImgBuffer& img, double exp) for (k=0; k maxDrawnVal) { maxDrawnVal = val; } @@ -2204,7 +2204,7 @@ void CDemoCamera::GenerateSyntheticImage(ImgBuffer& img, double exp) for (k=0; k maxDrawnVal) { maxDrawnVal = value; } @@ -2273,15 +2273,15 @@ void CDemoCamera::GenerateSyntheticImage(ImgBuffer& img, double exp) { long lIndex = imgWidth*j + k; double factor = (2.0 * lSinePeriod * k) / lPeriod; - unsigned char value0 = (unsigned char) min(255.0, (pedestal + dAmp * sin(dPhase_ + dLinePhase + factor))); + unsigned char value0 = (unsigned char) std::min(255.0, (pedestal + dAmp * sin(dPhase_ + dLinePhase + factor))); theBytes[0] = value0; if( NULL != pTmpBuffer) pTmp2[1] = value0; - unsigned char value1 = (unsigned char) min(255.0, (pedestal + dAmp * sin(dPhase_ + dLinePhase*2 + factor))); + unsigned char value1 = (unsigned char) std::min(255.0, (pedestal + dAmp * sin(dPhase_ + dLinePhase*2 + factor))); theBytes[1] = value1; if( NULL != pTmpBuffer) pTmp2[2] = value1; - unsigned char value2 = (unsigned char) min(255.0, (pedestal + dAmp * sin(dPhase_ + dLinePhase*4 + factor))); + unsigned char value2 = (unsigned char) std::min(255.0, (pedestal + dAmp * sin(dPhase_ + dLinePhase*4 + factor))); theBytes[2] = value2; if( NULL != pTmpBuffer){ @@ -2325,9 +2325,9 @@ void CDemoCamera::GenerateSyntheticImage(ImgBuffer& img, double exp) for (k=0; k maxDrawnVal) { maxDrawnVal = static_cast(tval); @@ -3470,7 +3470,7 @@ int CDemoStage::SetPositionUm(double pos) void CDemoStage::SetIntensityFactor(double pos) { pos = fabs(pos); - g_IntensityFactor_ = max(.1, min(1.0, 1.0 - .2 * log(pos))); + g_IntensityFactor_ = std::max(.1, std::min(1.0, 1.0 - .2 * log(pos))); } int CDemoStage::IsStageSequenceable(bool& isSequenceable) const diff --git a/DeviceAdapters/DemoCamera/DemoCamera.vcxproj b/DeviceAdapters/DemoCamera/DemoCamera.vcxproj index 754e069f4..9c38b333f 100644 --- a/DeviceAdapters/DemoCamera/DemoCamera.vcxproj +++ b/DeviceAdapters/DemoCamera/DemoCamera.vcxproj @@ -56,7 +56,7 @@ Disabled true Speed - WIN32;_DEBUG;_WINDOWS;_USRDLL;MODULE_EXPORTS;%(PreprocessorDefinitions) + NOMINMAX;WIN32;_DEBUG;_WINDOWS;_USRDLL;MODULE_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks true @@ -77,7 +77,7 @@ MaxSpeed true Speed - WIN32;NDEBUG;_WINDOWS;_USRDLL;MODULE_EXPORTS;%(PreprocessorDefinitions) + NOMINMAX;WIN32;NDEBUG;_WINDOWS;_USRDLL;MODULE_EXPORTS;%(PreprocessorDefinitions) true From 8a295f565547ea4cab93d740a29676035944b879 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Mon, 11 Dec 2023 16:10:14 -0600 Subject: [PATCH 7/7] MMCore: Avoid Windows.h's min/max macros --- MMCore/CoreCallback.cpp | 4 ---- MMCore/MMCore.vcxproj | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/MMCore/CoreCallback.cpp b/MMCore/CoreCallback.cpp index b0e98fe69..471313c24 100644 --- a/MMCore/CoreCallback.cpp +++ b/MMCore/CoreCallback.cpp @@ -1031,11 +1031,7 @@ void CoreCallback::NextPostedError(int& errorCode, char* pMessage, int maxlen, i if( 0 < maxlen ) { *pMessage = 0; -#ifdef _WINDOWS - messageLength = min( maxlen, (int) nextError.second.length()); -#else messageLength = std::min( maxlen, (int) nextError.second.length()); -#endif strncpy(pMessage, nextError.second.c_str(), messageLength); } } diff --git a/MMCore/MMCore.vcxproj b/MMCore/MMCore.vcxproj index d5e4c2f28..26d732feb 100644 --- a/MMCore/MMCore.vcxproj +++ b/MMCore/MMCore.vcxproj @@ -50,7 +50,7 @@ Disabled - WIN32;_DEBUG;_LIB;_WINDOWS;%(PreprocessorDefinitions) + NOMINMAX;WIN32;_DEBUG;_LIB;_WINDOWS;%(PreprocessorDefinitions) EnableFastChecks true @@ -66,7 +66,7 @@ X64 - WIN32;NDEBUG;_LIB;_WINDOWS;%(PreprocessorDefinitions) + NOMINMAX;WIN32;NDEBUG;_LIB;_WINDOWS;%(PreprocessorDefinitions) true @@ -183,4 +183,4 @@ - + \ No newline at end of file