diff --git a/source/adios2/core/ADIOS.h b/source/adios2/core/ADIOS.h index c9e9937076f33f3d15f06c0d4cc02f304f38a2ef..618a33232bf29cc7d931dc36d3b0932166d85818 100644 --- a/source/adios2/core/ADIOS.h +++ b/source/adios2/core/ADIOS.h @@ -33,7 +33,9 @@ class ADIOS public: /** Passed from parallel constructor, MPI_Comm is a pointer itself. */ MPI_Comm m_MPIComm; - std::string m_HostLanguage = "C++"; ///< changed by language bindings + + /** Changed by language bindings */ + std::string m_HostLanguage = "C++"; /** * @brief Constructor for MPI applications WITH a XML config file @@ -66,6 +68,13 @@ public: */ ADIOS(const bool debugMode = false); + /** + * Delete copy constructor explicitly. Objects shouldn't be allowed to be + * redefined. Use smart pointers if this is absolutely necessary. + * @param adios reference to another adios object + */ + ADIOS(const ADIOS &adios) = delete; + ~ADIOS() = default; /** @@ -81,16 +90,18 @@ public: IO &DeclareIO(const std::string ioName); /** - * Retrieve an already defined IO object + * Retrieve an already defined IO object. Make sure IO was previously + * created with DeclareIO. Otherwise, throws an exception in debug mode. + * @return reference to existing IO object inside ADIOS */ IO &GetIO(const std::string name); -protected: // no const member to allow default empty and copy constructors +private: /** XML File to be read containing configuration information */ - std::string m_ConfigFile; + const std::string m_ConfigFile; /** if true will do more checks, exceptions, warnings, expect slower code */ - bool m_DebugMode = false; + const bool m_DebugMode = false; /** transforms associated with ADIOS run */ std::vector<std::shared_ptr<Transform>> m_Transforms; diff --git a/source/adios2/helper/adiosSystem.cpp b/source/adios2/helper/adiosSystem.cpp index f4006fc1bbf458ce25fd3cc656beae81d43d17fb..9dcbd42f313b741a2555b5e07b7953fa71bdaa42 100644 --- a/source/adios2/helper/adiosSystem.cpp +++ b/source/adios2/helper/adiosSystem.cpp @@ -9,7 +9,7 @@ */ #include "adiosSystem.h" -#include <ctime> //std::ctime +#include <ctime> #include <chrono> //system_clock, now @@ -19,8 +19,12 @@ #include "adios2/ADIOSTypes.h" #include "adios2/helper/adiosString.h" -#ifdef _WIN32 -#define _CRT_SECURE_NO_DEPRECATE // remove warning for ctime +// remove ctime warning on Windows +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_WARNINGS +#define _SCL_SECURE_NO_DEPRECATE #endif namespace adios2 diff --git a/source/adios2/mpidummy.cpp b/source/adios2/mpidummy.cpp index 9d7f46b790e779e19c8c36aefa5563e76ab32d33..763d9a6f36a7df161657d54c0afe7e2470cf8c01 100644 --- a/source/adios2/mpidummy.cpp +++ b/source/adios2/mpidummy.cpp @@ -33,6 +33,13 @@ #include <chrono> #include <string> +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_WARNINGS +#define _SCL_SECURE_NO_DEPRECATE +#endif + namespace adios2 { diff --git a/source/adios2/mpidummy.h b/source/adios2/mpidummy.h index f4607ea204c313de54f37a1a8b0a2f484fc50ade..5457f0dd7788c55653787571271a4294878d9079 100644 --- a/source/adios2/mpidummy.h +++ b/source/adios2/mpidummy.h @@ -14,9 +14,6 @@ #include <cstdint> #include <cstdio> -/// \cond EXCLUDE_FROM_DOXYGEN -/// \endcond - namespace adios2 { diff --git a/source/adios2/toolkit/capsule/heap/STLVector.cpp b/source/adios2/toolkit/capsule/heap/STLVector.cpp index 545fc9a5dd8d0a5be525872d6e12582f99f183bf..9ff852d3f2d76d5535cb57191ed87112234c2690 100644 --- a/source/adios2/toolkit/capsule/heap/STLVector.cpp +++ b/source/adios2/toolkit/capsule/heap/STLVector.cpp @@ -43,10 +43,10 @@ void STLVector::ResizeData(const size_t size) } catch (std::bad_alloc &e) { - throw std::runtime_error("ERROR: bad_alloc detected when resizing " - "data buffer with size " + - std::to_string(size) + "\ndescription: " + - std::string(e.what()) + "\n"); + std::throw_with_nested( + std::runtime_error("ERROR: bad_alloc detected when resizing " + "data buffer with size " + + std::to_string(size) + "\n")); } } else @@ -65,11 +65,10 @@ void STLVector::ResizeMetadata(const size_t size) } catch (std::bad_alloc &e) { - throw std::runtime_error("ERROR: bad_alloc detected when resizing " - "metadata buffer with size " + - std::to_string(size) + - "\nadditional description: " + - std::string(e.what()) + "\n"); + std::throw_with_nested( + std::runtime_error("ERROR: bad_alloc detected when resizing " + "metadata buffer with size " + + std::to_string(size) + "\n")); } } else diff --git a/source/adios2/toolkit/capsule/shmem/ShmSystemV.cpp b/source/adios2/toolkit/capsule/shmem/ShmSystemV.cpp index 62486da1d39580ba1e211928cf9a1bbb5ca9cf60..21ba4efcd636c739cfa8a3517d03f4d7db9e14c5 100644 --- a/source/adios2/toolkit/capsule/shmem/ShmSystemV.cpp +++ b/source/adios2/toolkit/capsule/shmem/ShmSystemV.cpp @@ -2,10 +2,10 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * ShmSystemV.cpp + * ShmSystemV.cpp : implementation of ShmSystemV class * * Created on: Dec 22, 2016 - * Author: wfg + * Author: William F Godoy godoywf@ornl.gov */ #include "ShmSystemV.h" diff --git a/source/adios2/toolkit/capsule/shmem/ShmSystemV.h b/source/adios2/toolkit/capsule/shmem/ShmSystemV.h index df997af7bf10a2a6cd46939c3fc544ffe15e89e6..b1bf0f48ea2c28a77c9571137c7e66d803b7eb09 100644 --- a/source/adios2/toolkit/capsule/shmem/ShmSystemV.h +++ b/source/adios2/toolkit/capsule/shmem/ShmSystemV.h @@ -1,6 +1,12 @@ /* * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. + * + * ShmSystemV.h : ShmSystem class as a thin wrapper to a shared memory capsule + * using POSIX SystemV + * + * Created on: Dec 22, 2016 + * Author: William F Godoy godoywf@ornl.gov */ #ifndef ADIOS2_TOOLKIT_CAPSULE_SHMEM_SHMSYSTEMV_H_ diff --git a/source/adios2/toolkit/transport/file/FilePointer.cpp b/source/adios2/toolkit/transport/file/FilePointer.cpp index a4f9a7121eda2a30281409baf1e9b34d74aa1662..468b726e13c1f4db2dc0fa50cfc33f23b73ecb69 100644 --- a/source/adios2/toolkit/transport/file/FilePointer.cpp +++ b/source/adios2/toolkit/transport/file/FilePointer.cpp @@ -14,6 +14,14 @@ #include <ios> //std::ios_base::failure /// \endcond +// removes fopen warning on Windows +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_DEPRECATE +#define _SCL_SECURE_NO_WARNINGS +#define _SCL_SECURE_NO_DEPRECATE +#endif + namespace adios2 { namespace transport @@ -60,7 +68,7 @@ void FilePointer::Open(const std::string &name, const OpenMode openMode) m_File = fopen(name.c_str(), "rb"); } - if (std::ferror(m_File)) + if (ferror(m_File)) { throw std::ios_base::failure("ERROR: couldn't open file " + name + ", " @@ -72,7 +80,7 @@ void FilePointer::Open(const std::string &name, const OpenMode openMode) void FilePointer::SetBuffer(char *buffer, size_t size) { - const int status = std::setvbuf(m_File, buffer, _IOFBF, size); + const int status = setvbuf(m_File, buffer, _IOFBF, size); if (!status) { @@ -90,7 +98,7 @@ void FilePointer::Write(const char *buffer, size_t size) { m_Profiler.Timers.at("write").Resume(); } - auto writtenSize = std::fwrite(buffer, sizeof(char), size, m_File); + auto writtenSize = fwrite(buffer, sizeof(char), size, m_File); if (m_Profiler.IsActive) { @@ -133,7 +141,7 @@ void FilePointer::Write(const char *buffer, size_t size) void FilePointer::Flush() { - const int status = std::fflush(m_File); + const int status = fflush(m_File); if (status == EOF) { @@ -149,7 +157,7 @@ void FilePointer::Close() m_Profiler.Timers.at("close").Resume(); } - const int status = std::fclose(m_File); + const int status = fclose(m_File); if (m_Profiler.IsActive) { diff --git a/source/adios2/toolkit/transport/file/FilePointer.h b/source/adios2/toolkit/transport/file/FilePointer.h index 7c14b48066d1291790411adac6ffef5194bb6cb1..6d1521a3d5d99fff26f00806871194f9461fa5a8 100644 --- a/source/adios2/toolkit/transport/file/FilePointer.h +++ b/source/adios2/toolkit/transport/file/FilePointer.h @@ -45,7 +45,7 @@ public: private: /** C File pointer */ - std::FILE *m_File = nullptr; // NULL or nullptr? + FILE *m_File = nullptr; // NULL or nullptr? }; } // end namespace transport diff --git a/testing/adios2/xml/TestXMLConfig.cpp b/testing/adios2/xml/TestXMLConfig.cpp index 6724a9a883a3489a4fccdfc3da01759495482d34..5d3cb161b01080cd33a19083516deba70d3caaaa 100644 --- a/testing/adios2/xml/TestXMLConfig.cpp +++ b/testing/adios2/xml/TestXMLConfig.cpp @@ -54,14 +54,13 @@ TEST_F(XMLConfigTest, TwoIOs) TEST_F(XMLConfigTest, TwoEnginesException) { std::string configFile = configDir + "/config2.xml"; - adios2::ADIOS adios; #ifdef ADIOS2_HAVE_MPI - EXPECT_THROW(adios = - adios2::ADIOS(configFile, MPI_COMM_WORLD, adios2::DebugON), - std::invalid_argument); + EXPECT_THROW( + adios2::ADIOS adios(configFile, MPI_COMM_WORLD, adios2::DebugON), + std::invalid_argument); #else - EXPECT_THROW(adios = adios2::ADIOS(configFile, adios2::DebugON), + EXPECT_THROW(adios2::ADIOS adios(configFile, adios2::DebugON), std::invalid_argument); #endif }