From 0499edc81eab8e1d5aaff9a8aa6a474e99f1f012 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 2 Dec 2022 16:06:05 -0800 Subject: [PATCH 01/29] Add installation instructions for Homebrew --- doc/Installation.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/Installation.md b/doc/Installation.md index 09c0bb62..99c150f0 100644 --- a/doc/Installation.md +++ b/doc/Installation.md @@ -10,6 +10,10 @@ Standalone: if you are using [Anaconda Python](https://www.anaconda.com/), insta conda install -c conda-forge rmf +or on a Mac with [Homebrew](https://brew.sh/), install with + + brew tap salilab/salilab; brew install rmf + IMP: Download an IMP binary (which includes RMF) from the [IMP download page](https://integrativemodeling.org/download.html). From b0c1eb7e6adb6cac84ecfb17a04a84083b00dea9 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 7 Dec 2022 20:59:56 -0800 Subject: [PATCH 02/29] Report full version number --- CMakeLists.txt | 1 + bin/common.h | 2 +- config.h.in | 1 + swig/RMF.i | 3 ++- tools/new-release.txt | 3 +-- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 734992b3..6316af57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,7 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) # Version information set (RMF_VERSION_MAJOR 1) set (RMF_VERSION_MINOR 4) +set (RMF_VERSION_MICRO 1) set(RMF_SOVERSION "${RMF_VERSION_MAJOR}.${RMF_VERSION_MINOR}" CACHE INTERNAL "" FORCE) set(RMF_HAS_DEBUG_VECTOR 0 CACHE BOOL "Whether to use a bounds checked vector") diff --git a/bin/common.h b/bin/common.h index e8037dcd..c630ac53 100644 --- a/bin/common.h +++ b/bin/common.h @@ -44,7 +44,7 @@ void print_help_and_exit(char* argv[]) { void print_version_and_exit() { std::cout << "RMF version " << RMF_VERSION_MAJOR << "." << RMF_VERSION_MINOR - << std::endl; + << "." << RMF_VERSION_MICRO << std::endl; exit(0); } diff --git a/config.h.in b/config.h.in index 69e3e080..4b0b6318 100644 --- a/config.h.in +++ b/config.h.in @@ -33,6 +33,7 @@ // Version number #define RMF_VERSION_MAJOR @RMF_VERSION_MAJOR@ #define RMF_VERSION_MINOR @RMF_VERSION_MINOR@ +#define RMF_VERSION_MICRO @RMF_VERSION_MICRO@ #define RMF_HAS_LOG4CXX @RMF_HAS_LOG4CXX@ diff --git a/swig/RMF.i b/swig/RMF.i index dd6566cf..363ac96c 100644 --- a/swig/RMF.i +++ b/swig/RMF.i @@ -94,7 +94,8 @@ %inline %{ std::string _get_rmf_version() { std::ostringstream oss; - oss << RMF_VERSION_MAJOR << "." << RMF_VERSION_MINOR; + oss << RMF_VERSION_MAJOR << "." << RMF_VERSION_MINOR + << "." << RMF_VERSION_MICRO; return oss.str(); } %} diff --git a/tools/new-release.txt b/tools/new-release.txt index f5a213ab..3c55e8d5 100644 --- a/tools/new-release.txt +++ b/tools/new-release.txt @@ -1,8 +1,7 @@ To make a new release: - Update ChangeLog.md with release date and features. -- Add version number as RMF_VERSION_MAJOR and RMF_VERSION_MINOR - to CMakeLists.txt. +- Add version number as RMF_VERSION_(MAJOR,MINOR,MICRO) to CMakeLists.txt. - git push origin develop - Make sure all CI passes - Merge into main: From 6b51d180b41edfef6c21272b0577b2da19888c40 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 7 Dec 2022 22:22:00 -0800 Subject: [PATCH 03/29] Modern glibc no longer contains libSegFault.so --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 09ff68d1..ccb67909 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,7 +65,6 @@ jobs: ../tools/coverage/setup.py PYTHONPATH=`pwd`/coverage cmake .. -DCMAKE_BUILD_TYPE="${{ matrix.build }}" -DCMAKE_CXX_FLAGS="${{ matrix.flags }}" -DCMAKE_EXE_LINKER_FLAGS="${{ matrix.flags }}" -DCMAKE_MODULE_LINKER_FLAGS="${{ matrix.flags }}" -DCMAKE_SHARED_LINKER_FLAGS="${{ matrix.flags }}" make -j 2 - export LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so ctest -j 2 --output-on-failure -L ${{ matrix.tests }} - name: Combine coverage run: | From cd7d051927dc4c73d474a055c74fcf34e8c34ed2 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 11 Jan 2023 13:11:20 -0800 Subject: [PATCH 04/29] Squashed 'tools/dev_tools/' changes from 626e51c1..7e8e4043 7e8e4043 Use current year for copyright of autogen files 8164076f Run flake8 separately, not as part of pytest 84af9307 flake8 fix fb3f9d03 Test with Python 3.11 git-subtree-dir: tools/dev_tools git-subtree-split: 7e8e40439473731d326790e0549ea53f052e4eaa --- tools/dev_tools/.github/workflows/build.yml | 7 ++++--- tools/dev_tools/make_all_header.py | 6 ++++-- tools/dev_tools/pytest.ini | 3 --- tools/dev_tools/python_tools/__init__.py | 4 ++-- tools/dev_tools/test/test_header.py | 6 ++++-- 5 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 tools/dev_tools/pytest.ini diff --git a/tools/dev_tools/.github/workflows/build.yml b/tools/dev_tools/.github/workflows/build.yml index d7190075..bb987395 100644 --- a/tools/dev_tools/.github/workflows/build.yml +++ b/tools/dev_tools/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: [2.7, 3.7, 3.8, 3.9, "3.10"] + python-version: ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"] runs-on: ${{ matrix.os }} steps: @@ -20,8 +20,9 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - pip install 'pytest-flake8<1.1' pytest-cov + pip install pytest flake8 pytest-cov - name: Test run: | - py.test --cov=. --cov-branch --cov-report=xml -v --flake8 . + py.test --cov=. --cov-branch --cov-report=xml -v . + flake8 --ignore=E402,W503 --exclude python_tools/reindent.py - uses: codecov/codecov-action@v1 diff --git a/tools/dev_tools/make_all_header.py b/tools/dev_tools/make_all_header.py index ec9af48a..b10deee0 100755 --- a/tools/dev_tools/make_all_header.py +++ b/tools/dev_tools/make_all_header.py @@ -6,6 +6,7 @@ import sys import glob +import datetime import os sys.path.append(os.path.split(sys.argv[0])[0]) @@ -27,13 +28,14 @@ def _add_includes(headers, output): includepath = sys.argv[1][sys.argv[1].find("include") + len("include") + 1:] +year = datetime.datetime.now().year output = ["""/** * \\file %s * \\brief Include all non-deprecated headers in %s. * - * Copyright 2007-2022 IMP Inventors. All rights reserved. + * Copyright 2007-%d IMP Inventors. All rights reserved. */ -""" % (includepath, includepath[:-2].replace('/', '.'))] +""" % (includepath, includepath[:-2].replace('/', '.'), year)] guard = includepath.replace( "/", "_").replace("\\", diff --git a/tools/dev_tools/pytest.ini b/tools/dev_tools/pytest.ini deleted file mode 100644 index aec0cb16..00000000 --- a/tools/dev_tools/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pytest] -flake8-ignore = E402 W503 -addopts = --ignore=python_tools/reindent.py diff --git a/tools/dev_tools/python_tools/__init__.py b/tools/dev_tools/python_tools/__init__.py index 17fd6027..aecd175f 100644 --- a/tools/dev_tools/python_tools/__init__.py +++ b/tools/dev_tools/python_tools/__init__.py @@ -174,8 +174,8 @@ def get_modules(source): def split(string, sep=":"): - return([x.replace("@", ":") - for x in string.replace("\\:", "@").split(sep) if x != ""]) + return ([x.replace("@", ":") + for x in string.replace("\\:", "@").split(sep) if x != ""]) def get_project_info(path): diff --git a/tools/dev_tools/test/test_header.py b/tools/dev_tools/test/test_header.py index a00c32bd..ef3f7b06 100644 --- a/tools/dev_tools/test/test_header.py +++ b/tools/dev_tools/test/test_header.py @@ -1,6 +1,7 @@ import unittest import subprocess import os +import datetime import utils TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) @@ -26,13 +27,14 @@ def test_header(self): 'include/test/subdir'], cwd=tmpdir) stdout, stderr = p.communicate() self.assertEqual(p.returncode, 0) + year = datetime.datetime.now().year self.assertEqual(utils.read_file(os.path.join(tmpdir, 'include/test.h')), """/** * \\file test.h * \\brief Include all non-deprecated headers in test. * - * Copyright 2007-2022 IMP Inventors. All rights reserved. + * Copyright 2007-%d IMP Inventors. All rights reserved. */ #ifndef TEST_H @@ -43,7 +45,7 @@ def test_header(self): #include #endif #endif /* TEST_H */ -""") +""" % year) if __name__ == '__main__': From c88470c23c021f866e034a6d1c140d51993c88cd Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 11 Jan 2023 13:13:35 -0800 Subject: [PATCH 05/29] Update copyright year Update the reported copyright year range in documentation. Each .cpp and .h file also has a copyright notice, but we will no longer update those in bulk each year, as these updates muddy the git logs and provide no meaningful copyright protection. Instead, we will update individual files ad hoc, only when significant changes are made. --- README.md | 2 +- doc/Main.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 61ab395a..b2ecd3c0 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ and score data. The main documentation is found on the [web site](http://integrativemodeling.org/rmf/nightly/doc/). -Copyright 2007-2022 IMP Inventors. +Copyright 2007-2023 IMP Inventors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/doc/Main.md b/doc/Main.md index 7de426e7..cdb4b415 100644 --- a/doc/Main.md +++ b/doc/Main.md @@ -19,7 +19,7 @@ See Also see the [rmf examples](https://github.com/salilab/rmf_examples) repository for examples of interesting or problematic RMF files. -Copyright 2007-2022 IMP Inventors. +Copyright 2007-2023 IMP Inventors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 3222e0139f6bea0cf0ce6b881608187945ba1049 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 1 Feb 2023 11:42:38 -0800 Subject: [PATCH 06/29] Clarify error message --- src/internal/SharedData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/SharedData.cpp b/src/internal/SharedData.cpp index 0672d414..e22c85d4 100644 --- a/src/internal/SharedData.cpp +++ b/src/internal/SharedData.cpp @@ -40,7 +40,7 @@ SharedData::SharedData(boost::shared_ptr io, std::string name, } RMF_USAGE_CHECK( open_for_writing.find(get_file_path()) == open_for_writing.end(), - "Opening a file that is still being written is asking for trouble."); + "This file is currently being written to. Close it first."); if (write) open_for_writing.insert(get_file_path()); } From db8694dc725a0fc4dd8adf8f18194f5ee5eeb57b Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 3 Feb 2023 10:15:33 -0800 Subject: [PATCH 07/29] Don't crash trying to show closed file handles --- include/RMF/FileConstHandle.h | 8 +++++++- test/test_file_handle.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/test_file_handle.py diff --git a/include/RMF/FileConstHandle.h b/include/RMF/FileConstHandle.h index 518fea48..87c2d0e8 100644 --- a/include/RMF/FileConstHandle.h +++ b/include/RMF/FileConstHandle.h @@ -116,7 +116,13 @@ class RMFEXPORT FileConstHandle { return NodeConstHandle(NodeID(0), shared_); } - std::string get_name() const { return shared_->get_file_name(); } + std::string get_name() const { + if (shared_) { + return shared_->get_file_name(); + } else { + return "(closed RMF file handle)"; + } + } std::string get_path() const { return shared_->get_file_path(); } diff --git a/test/test_file_handle.py b/test/test_file_handle.py new file mode 100644 index 00000000..b39279a8 --- /dev/null +++ b/test/test_file_handle.py @@ -0,0 +1,16 @@ +import unittest +import RMF + + +class Tests(unittest.TestCase): + + def test_closed_repr(self): + """Test show of closed file handle""" + fh = RMF.FileConstHandle() + _ = repr(fh) + fh = RMF.FileHandle() + _ = repr(fh) + + +if __name__ == '__main__': + unittest.main() From 4ddd0040bf289d78aff687f455e0bfd45571c354 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 3 Feb 2023 10:32:53 -0800 Subject: [PATCH 08/29] Add check-for-closed-file method --- include/RMF/FileConstHandle.h | 5 +++++ test/test_file_handle.py | 5 +++++ test/test_file_level.py | 1 + 3 files changed, 11 insertions(+) diff --git a/include/RMF/FileConstHandle.h b/include/RMF/FileConstHandle.h index 87c2d0e8..130ed5a1 100644 --- a/include/RMF/FileConstHandle.h +++ b/include/RMF/FileConstHandle.h @@ -116,6 +116,11 @@ class RMFEXPORT FileConstHandle { return NodeConstHandle(NodeID(0), shared_); } + //! Return True iff the file is closed + bool get_is_closed() const { + return !shared_; + } + std::string get_name() const { if (shared_) { return shared_->get_file_name(); diff --git a/test/test_file_handle.py b/test/test_file_handle.py index b39279a8..f091a384 100644 --- a/test/test_file_handle.py +++ b/test/test_file_handle.py @@ -11,6 +11,11 @@ def test_closed_repr(self): fh = RMF.FileHandle() _ = repr(fh) + def test_closed_file_methods(self): + """Test methods on closed file""" + fh = RMF.FileConstHandle() + self.assertTrue(fh.get_is_closed()) + if __name__ == '__main__': unittest.main() diff --git a/test/test_file_level.py b/test/test_file_level.py index c40922fc..98457baa 100644 --- a/test/test_file_level.py +++ b/test/test_file_level.py @@ -16,6 +16,7 @@ def test_perturbed(self): for suffix in RMF.suffixes: f = RMF.create_rmf_file( RMF._get_temporary_file_path("test_file_perturbed." + suffix)) + self.assertFalse(f.get_is_closed()) r = f.get_root_node() print(r.get_type()) sc = f.get_category("sequence") From ac7202fa183a076043438cfe3268e5ea7e2218ce Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 3 Feb 2023 10:55:02 -0800 Subject: [PATCH 09/29] Check for operations on closed files Don't segfault when trying to perform most actions with closed files, but instead raise an exception. --- include/RMF/FileConstHandle.h | 24 +++++++++++++++++++++--- include/RMF/FileHandle.h | 5 ++++- src/FileHandle.cpp | 5 +++++ test/test_file_handle.py | 22 +++++++++++++++++++++- 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/include/RMF/FileConstHandle.h b/include/RMF/FileConstHandle.h index 130ed5a1..c74c829f 100644 --- a/include/RMF/FileConstHandle.h +++ b/include/RMF/FileConstHandle.h @@ -113,6 +113,7 @@ class RMFEXPORT FileConstHandle { //! Return the root of the hierarchy NodeConstHandle get_root_node() const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); return NodeConstHandle(NodeID(0), shared_); } @@ -129,7 +130,10 @@ class RMFEXPORT FileConstHandle { } } - std::string get_path() const { return shared_->get_file_path(); } + std::string get_path() const { + RMF_USAGE_CHECK(!get_is_closed(), "File is closed, no path."); + return shared_->get_file_path(); + } /** \name Methods for manipulating keys When using C++ it is most convenient to specify types @@ -204,22 +208,31 @@ class RMFEXPORT FileConstHandle { point. @{ */ - FrameID get_current_frame() const { return shared_->get_loaded_frame(); } + FrameID get_current_frame() const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); + return shared_->get_loaded_frame(); + } + FrameType get_type(FrameID fr) const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); return shared_->get_frame_data(fr).type; } std::string get_name(FrameID fr) const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); return shared_->get_frame_data(fr).name; } FrameIDs get_children(FrameID id) const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); const internal::FrameData& fd = shared_->get_frame_data(id); return FrameIDs(fd.children.begin(), fd.children.end()); } FrameIDs get_parents(FrameID id) const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); const internal::FrameData& fd = shared_->get_frame_data(id); return FrameIDs(fd.parents.begin(), fd.parents.end()); } void set_current_frame(FrameID frame) const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); RMF_USAGE_CHECK(frame != FrameID(), "Invalid frame passed."); RMF_USAGE_CHECK(frame != ALL_FRAMES, "Use set_static_value() and get_static_value() to " @@ -233,6 +246,7 @@ class RMFEXPORT FileConstHandle { /** Return the number of frames in the file. */ unsigned int get_number_of_frames() const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); try { return shared_->get_number_of_frames(); } @@ -242,6 +256,7 @@ class RMFEXPORT FileConstHandle { /** Return the number of nodes in the file. */ unsigned int get_number_of_nodes() const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); try { return shared_->get_number_of_nodes(); } @@ -250,7 +265,10 @@ class RMFEXPORT FileConstHandle { /** Return a string identifying the file type. */ - std::string get_file_type() const { return shared_->get_file_type(); } + std::string get_file_type() const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); + return shared_->get_file_type(); + } /** Get all the frames that are roots (aren't subframes). */ FrameIDs get_root_frames() const; diff --git a/include/RMF/FileHandle.h b/include/RMF/FileHandle.h index d77abb8e..1de06df9 100644 --- a/include/RMF/FileHandle.h +++ b/include/RMF/FileHandle.h @@ -64,7 +64,10 @@ class RMFEXPORT FileHandle : public FileConstHandle { #endif //! Return the root of the hierarchy stored in the file. - NodeHandle get_root_node() const { return NodeHandle(NodeID(0), shared_); } + NodeHandle get_root_node() const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); + return NodeHandle(NodeID(0), shared_); + } //! Add a frame and make it the current frame. FrameID add_frame(std::string name, FrameType t = FRAME) const; diff --git a/src/FileHandle.cpp b/src/FileHandle.cpp index 5d569c6b..9497c68e 100644 --- a/src/FileHandle.cpp +++ b/src/FileHandle.cpp @@ -31,6 +31,7 @@ NodeHandle FileHandle::get_node(NodeID id) const { } void FileHandle::flush() const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); try { shared_->flush(); } @@ -38,20 +39,24 @@ void FileHandle::flush() const { } void FileHandle::set_description(std::string descr) const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); shared_->set_description(descr); } void FileHandle::set_producer(std::string descr) const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); shared_->set_producer(descr); } FrameID FileHandle::add_frame(std::string name, FrameType t) const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); FrameID ret = shared_->add_frame(name, t); return ret; } FrameID FileHandle::add_frame(std::string name, FrameID parent, FrameType t) const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); FrameID ret = shared_->add_frame(name, parent, t); return ret; } diff --git a/test/test_file_handle.py b/test/test_file_handle.py index f091a384..f6e207e5 100644 --- a/test/test_file_handle.py +++ b/test/test_file_handle.py @@ -12,9 +12,29 @@ def test_closed_repr(self): _ = repr(fh) def test_closed_file_methods(self): - """Test methods on closed file""" + """Test methods on closed files""" fh = RMF.FileConstHandle() self.assertTrue(fh.get_is_closed()) + self.assertRaises(OSError, fh.set_current_frame, RMF.FrameID(0)) + self.assertRaises(OSError, fh.get_path) + self.assertRaises(OSError, fh.get_current_frame) + self.assertRaises(OSError, fh.get_type, RMF.FrameID(0)) + self.assertRaises(OSError, fh.get_name, RMF.FrameID(0)) + self.assertRaises(OSError, fh.get_children, RMF.FrameID(0)) + self.assertRaises(OSError, fh.get_parents, RMF.FrameID(0)) + self.assertRaises(OSError, fh.get_number_of_frames) + self.assertRaises(OSError, fh.get_number_of_nodes) + self.assertRaises(OSError, fh.get_file_type) + self.assertRaises(OSError, fh.get_root_node) + + fh = RMF.FileHandle() + self.assertTrue(fh.get_is_closed()) + self.assertRaises(OSError, fh.get_root_node) + self.assertRaises(OSError, fh.add_frame, "f0") + self.assertRaises(OSError, fh.add_frame, "f1", RMF.FrameID(0)) + self.assertRaises(OSError, fh.set_description, "foo") + self.assertRaises(OSError, fh.set_producer, "foo") + self.assertRaises(OSError, fh.flush) if __name__ == '__main__': From c1527ad4c9ee8eab07ec6bb440a8be0569354a9c Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 3 Feb 2023 11:07:49 -0800 Subject: [PATCH 10/29] Allow explicit close of file handles --- include/RMF/FileConstHandle.h | 11 +++++++++++ test/test_file_level.py | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/RMF/FileConstHandle.h b/include/RMF/FileConstHandle.h index c74c829f..3f544150 100644 --- a/include/RMF/FileConstHandle.h +++ b/include/RMF/FileConstHandle.h @@ -122,6 +122,17 @@ class RMFEXPORT FileConstHandle { return !shared_; } + //! Explicitly close the file handle. + /** Normally, an RMF file is automatically closed when this handle object + goes out of scope. If closed with this method, any further operations + on this handle will raise an error. + Trying to close a file that is already closed will do nothing. */ + void close() { + if (!get_is_closed()) { + shared_.reset(); + } + } + std::string get_name() const { if (shared_) { return shared_->get_file_name(); diff --git a/test/test_file_level.py b/test/test_file_level.py index 98457baa..94c57dfc 100644 --- a/test/test_file_level.py +++ b/test/test_file_level.py @@ -110,6 +110,20 @@ def test_base_frames(self): self.assertEqual(f.get_current_frame(), RMF.FrameID()) f.set_current_frame(RMF.FrameID(0)) -if __name__ == '__main__': + def test_close(self): + """Test explicit close of file handle""" + for suffix in RMF.suffixes: + path = RMF._get_temporary_file_path("test_close." + suffix) + f = RMF.create_rmf_file(path) + self.assertEqual(f.get_number_of_frames(), 0) + f.add_frame("hi", RMF.FRAME) + self.assertEqual(f.get_number_of_frames(), 1) + f.close() + self.assertTrue(f.get_is_closed()) + self.assertRaises(OSError, f.get_number_of_frames) + f2 = RMF.open_rmf_file_read_only(path) + self.assertEqual(f2.get_number_of_frames(), 1) + +if __name__ == '__main__': unittest.main() From 0cfcf2b84d857f21f912590032580e37d5f0a1c5 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 3 Feb 2023 11:28:07 -0800 Subject: [PATCH 11/29] Add context manager support to file handles When using file handles in Python, support the context manager protocol ('with' keyword) to ensure that the handle is closed at the end of the 'with' block. --- swig/RMF.FileConstHandle.i | 7 +++++++ test/test_file_level.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/swig/RMF.FileConstHandle.i b/swig/RMF.FileConstHandle.i index 02c2befb..2c273ddf 100644 --- a/swig/RMF.FileConstHandle.i +++ b/swig/RMF.FileConstHandle.i @@ -4,6 +4,13 @@ namespace RMF { %extend RMF::FileConstHandle { %pythoncode %{ + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.close() + return False + def get_frames(self): class MyRange: def __init__(self, mx): diff --git a/test/test_file_level.py b/test/test_file_level.py index 94c57dfc..814ca7f6 100644 --- a/test/test_file_level.py +++ b/test/test_file_level.py @@ -124,6 +124,21 @@ def test_close(self): f2 = RMF.open_rmf_file_read_only(path) self.assertEqual(f2.get_number_of_frames(), 1) + def test_context_manager(self): + """Test file handle context manager support""" + for suffix in RMF.suffixes: + path = RMF._get_temporary_file_path( + "test_context_manager." + suffix) + with RMF.create_rmf_file(path) as f: + self.assertEqual(f.get_number_of_frames(), 0) + f.add_frame("hi", RMF.FRAME) + self.assertEqual(f.get_number_of_frames(), 1) + self.assertTrue(f.get_is_closed()) + self.assertRaises(OSError, f.get_number_of_frames) + with RMF.open_rmf_file_read_only(path) as f2: + self.assertEqual(f2.get_number_of_frames(), 1) + self.assertTrue(f2.get_is_closed()) + if __name__ == '__main__': unittest.main() From 904c2ed5b5634c94f0d3bacb55fb2ce86dd1e62c Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 3 Feb 2023 12:00:19 -0800 Subject: [PATCH 12/29] Replace boost::shared_ptr with std::shared_ptr Now that we require C++11, use smart pointers from the standard library rather than those from Boost. --- bin/rmf3_dump.cpp | 4 +- include/RMF/BufferConstHandle.h | 15 +++-- include/RMF/Decorator.h | 4 +- include/RMF/FileConstHandle.h | 6 +- include/RMF/FileHandle.h | 7 +-- include/RMF/HDF5/ConstAttributes.h | 2 +- include/RMF/HDF5/ConstDataSetD.h | 15 +++-- include/RMF/HDF5/ConstFile.h | 2 +- include/RMF/HDF5/ConstGroup.h | 2 +- include/RMF/HDF5/DataSetAccessPropertiesD.h | 4 +- include/RMF/HDF5/DataSetD.h | 4 +- include/RMF/HDF5/File.h | 2 +- include/RMF/HDF5/Group.h | 2 +- include/RMF/HDF5/Object.h | 10 ++-- include/RMF/HDF5/infrastructure_macros.h | 4 +- include/RMF/NodeConstHandle.h | 10 ++-- include/RMF/NodeHandle.h | 4 +- include/RMF/TraverseHelper.h | 6 +- include/RMF/internal/SharedData.h | 6 +- include/RMF/internal/SharedDataData_impl.h | 2 +- include/RMF/internal/SharedDataUserData.h | 4 +- include/RMF/internal/SharedData_impl.h | 2 +- include/RMF/internal/shared_data_factories.h | 10 ++-- include/RMF/validate.h | 3 +- src/BufferConstHandle.cpp | 7 +-- src/FileConstHandle.cpp | 4 +- src/FileHandle.cpp | 4 +- src/NodeConstHandle.cpp | 4 +- src/NodeHandle.cpp | 4 +- src/TraverseHelper.cpp | 7 +-- src/avrocpp/api/DataFile.hh | 28 +++++----- src/avrocpp/api/Decoder.hh | 6 +- src/avrocpp/api/Encoder.hh | 4 +- src/avrocpp/api/Node.hh | 4 +- src/avrocpp/api/NodeImpl.hh | 7 +-- src/avrocpp/api/ResolverSchema.hh | 4 +- src/avrocpp/api/Stream.hh | 14 ++--- src/avrocpp/api/buffer/detail/BufferDetail.hh | 10 ++-- src/avrocpp/examples/custom.cc | 4 +- src/avrocpp/examples/generated.cc | 4 +- src/avrocpp/examples/generic.cc | 4 +- src/avrocpp/examples/resolving.cc | 4 +- src/avrocpp/examples/validating.cc | 4 +- src/avrocpp/impl/BinaryDecoder.cc | 3 +- src/avrocpp/impl/BinaryEncoder.cc | 5 +- src/avrocpp/impl/Compiler.cc | 6 +- src/avrocpp/impl/DataFile.cc | 20 +++---- src/avrocpp/impl/FileStream.cc | 32 +++++------ src/avrocpp/impl/Resolver.cc | 2 +- src/avrocpp/impl/Stream.cc | 14 ++--- src/avrocpp/impl/ValidSchema.cc | 4 +- src/avrocpp/impl/json/JsonDom.cc | 8 +-- src/avrocpp/impl/parsing/JsonCodec.cc | 20 +++---- src/avrocpp/impl/parsing/ResolvingDecoder.cc | 18 +++--- src/avrocpp/impl/parsing/Symbol.hh | 31 +++++----- src/avrocpp/impl/parsing/ValidatingCodec.cc | 20 +++---- src/avrocpp/impl/parsing/ValidatingCodec.hh | 7 +-- src/avrocpp/test/AvrogencppTests.cc | 8 +-- src/avrocpp/test/CodecTests.cc | 56 +++++++++---------- src/avrocpp/test/DataFileTests.cc | 39 +++++++------ src/avrocpp/test/SpecificTests.cc | 4 +- src/avrocpp/test/StreamTests.cc | 18 +++--- src/avrocpp/test/testgentest.cc | 2 +- src/avrocpp/test/unittest.cc | 2 +- src/backend/IO.cpp | 40 ++++++------- src/backend/IO.h | 10 ++-- src/backend/IOFactory.h | 18 +++--- src/backend/avro/factory.cpp | 33 ++++++----- src/backend/avro/factory.h | 2 +- src/backend/avro/io.h | 3 +- src/backend/avro/traits.cpp | 18 +++--- src/backend/avro/traits.h | 27 +++++---- .../deprecated_avro/MultipleAvroFileReader.h | 4 +- .../deprecated_avro/MultipleAvroFileWriter.h | 6 +- .../deprecated_avro/SingleAvroFile.cpp | 14 ++--- src/backend/deprecated_avro/SingleAvroFile.h | 6 +- .../deprecated_avro/avro_schema_io.cpp | 2 +- src/backend/deprecated_avro/avro_schema_io.h | 6 +- src/backend/deprecated_avro/create.cpp | 39 +++++++------ src/backend/deprecated_avro/factory.h | 2 +- src/backend/deprecated_hdf5/HDF5SharedData.h | 1 - src/backend/deprecated_hdf5/create.cpp | 17 +++--- src/backend/deprecated_hdf5/factory.h | 2 +- src/hdf5_wrapper.cpp | 21 ++++--- src/internal/SharedData.cpp | 2 +- src/internal/shared_data_factories.cpp | 30 +++++----- src/signature.cpp | 2 +- src/utility.cpp | 2 +- test/test_associations.cpp | 6 +- test/test_avro2_low_level.cpp | 4 +- test/test_avro2_validate.cpp | 10 ++-- test/test_json_encode_decode.cpp | 10 ++-- 92 files changed, 444 insertions(+), 469 deletions(-) diff --git a/bin/rmf3_dump.cpp b/bin/rmf3_dump.cpp index 06f6e849..d6201697 100644 --- a/bin/rmf3_dump.cpp +++ b/bin/rmf3_dump.cpp @@ -2,7 +2,7 @@ * Copyright 2007-2022 IMP Inventors. All rights reserved. */ -#include +#include #include #include #include @@ -38,7 +38,7 @@ int main(int argc, char** argv) { if (variables_map.count("verbose")) { internal_avro::EncoderPtr encoder = internal_avro::jsonEncoder(schema); - boost::shared_ptr os = + std::shared_ptr os = internal_avro::ostreamOutputStream(std::cout); encoder->init(*os); internal_avro::encode(*encoder, frame); diff --git a/include/RMF/BufferConstHandle.h b/include/RMF/BufferConstHandle.h index 4aa71609..e6804fec 100644 --- a/include/RMF/BufferConstHandle.h +++ b/include/RMF/BufferConstHandle.h @@ -12,8 +12,7 @@ #include "RMF/config.h" #include "infrastructure_macros.h" #include "exceptions.h" -#include -#include +#include #include #include @@ -29,7 +28,7 @@ namespace RMF { */ class BufferConstHandle { protected: - boost::shared_ptr > data_; + std::shared_ptr > data_; int compare(BufferConstHandle o) const { if (&*data_ < &*o.data_) return -1; @@ -42,13 +41,13 @@ class BufferConstHandle { public: #ifndef SWIG explicit BufferConstHandle(std::string r) - : data_(boost::make_shared >(r.begin(), r.end())) {} + : data_(std::make_shared >(r.begin(), r.end())) {} #endif explicit BufferConstHandle(const std::vector &r) - : data_(boost::make_shared >(r.begin(), r.end())) {} + : data_(std::make_shared >(r.begin(), r.end())) {} explicit BufferConstHandle(const std::vector &r) - : data_(boost::make_shared >(r.begin(), r.end())) {} - explicit BufferConstHandle(boost::shared_ptr > r) + : data_(std::make_shared >(r.begin(), r.end())) {} + explicit BufferConstHandle(std::shared_ptr > r) : data_(r) {} const std::vector &get_buffer() const { return *data_; } #ifndef SWIG @@ -65,7 +64,7 @@ class BufferConstHandle { return std::make_pair(reinterpret_cast(&(*data_)[0]), data_->size()); } - boost::shared_ptr > get() const { return data_; } + std::shared_ptr > get() const { return data_; } #endif }; diff --git a/include/RMF/Decorator.h b/include/RMF/Decorator.h index 7fa6c984..49d62518 100644 --- a/include/RMF/Decorator.h +++ b/include/RMF/Decorator.h @@ -15,7 +15,7 @@ #include "internal/SharedData.h" #include "NodeConstHandle.h" #include "NodeHandle.h" -#include +#include RMF_ENABLE_WARNINGS namespace RMF { @@ -29,7 +29,7 @@ namespace RMF { class Decorator { private: NodeID id_; - boost::shared_ptr data_; + std::shared_ptr data_; protected: Decorator(NodeConstHandle handle) diff --git a/include/RMF/FileConstHandle.h b/include/RMF/FileConstHandle.h index 3f544150..063f89ef 100644 --- a/include/RMF/FileConstHandle.h +++ b/include/RMF/FileConstHandle.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -99,7 +99,7 @@ class RMFEXPORT FileConstHandle { } protected: - boost::shared_ptr shared_; + std::shared_ptr shared_; public: RMF_COMPARISONS(FileConstHandle); @@ -108,7 +108,7 @@ class RMFEXPORT FileConstHandle { //! Empty root handle, no open file. FileConstHandle() {} #if !defined(RMF_DOXYGEN) && !defined(SWIG) - FileConstHandle(boost::shared_ptr shared); + FileConstHandle(std::shared_ptr shared); #endif //! Return the root of the hierarchy diff --git a/include/RMF/FileHandle.h b/include/RMF/FileHandle.h index 1de06df9..9fe4b5ac 100644 --- a/include/RMF/FileHandle.h +++ b/include/RMF/FileHandle.h @@ -9,8 +9,7 @@ #ifndef RMF_FILE_HANDLE_H #define RMF_FILE_HANDLE_H -#include -#include +#include #include #include @@ -54,13 +53,13 @@ class BufferHandle; */ class RMFEXPORT FileHandle : public FileConstHandle { friend class NodeHandle; - friend class boost::shared_ptr; + friend class std::shared_ptr; public: //! Empty file handle, no open file. FileHandle() {} #if !defined(RMF_DOXYGEN) && !defined(SWIG) - FileHandle(boost::shared_ptr shared_); + FileHandle(std::shared_ptr shared_); #endif //! Return the root of the hierarchy stored in the file. diff --git a/include/RMF/HDF5/ConstAttributes.h b/include/RMF/HDF5/ConstAttributes.h index fbfdcf9b..e9a788ce 100644 --- a/include/RMF/HDF5/ConstAttributes.h +++ b/include/RMF/HDF5/ConstAttributes.h @@ -29,7 +29,7 @@ template class ConstAttributes : public Base { #ifndef SWIG protected: - ConstAttributes(boost::shared_ptr h) : Base(h) {} + ConstAttributes(std::shared_ptr h) : Base(h) {} ConstAttributes() {} #else private: diff --git a/include/RMF/HDF5/ConstDataSetD.h b/include/RMF/HDF5/ConstDataSetD.h index 9f718b0d..b1e43d9b 100644 --- a/include/RMF/HDF5/ConstDataSetD.h +++ b/include/RMF/HDF5/ConstDataSetD.h @@ -18,8 +18,7 @@ #include "DataSetCreationPropertiesD.h" #include "infrastructure_macros.h" #include -#include -#include +#include RMF_ENABLE_WARNINGS @@ -50,7 +49,7 @@ class ConstDataSetD : public ConstDataSetAttributes { DataSetIndexD size_; }; - boost::shared_ptr data_; + std::shared_ptr data_; int compare(const ConstDataSetD& o) const { // not great, but... if (data_ && !o.data_) @@ -85,7 +84,7 @@ class ConstDataSetD : public ConstDataSetAttributes { typedef DataSetCreationPropertiesD CreationProperties; typedef DataSetAccessPropertiesD AccessProperties; - ConstDataSetD(boost::shared_ptr parent, std::string name, + ConstDataSetD(std::shared_ptr parent, std::string name, CreationProperties props) : data_(new Data()) { // std::cout << "Creating data set " << name << std::endl; @@ -97,7 +96,7 @@ class ConstDataSetD : public ConstDataSetAttributes { std::fill(maxs, maxs + D, H5S_UNLIMITED); RMF_HDF5_HANDLE(ds, H5Screate_simple(D, dims, maxs), &H5Sclose); // std::cout << "creating..." << name << std::endl; - P::open(boost::make_shared( + P::open(std::make_shared( H5Dcreate2(parent->get_hid(), name.c_str(), TypeTraits::get_hdf5_disk_type(), ds, H5P_DEFAULT, props.get_handle(), H5P_DEFAULT), @@ -105,13 +104,13 @@ class ConstDataSetD : public ConstDataSetAttributes { initialize(); // std::cout << "done..." << std::endl; } - ConstDataSetD(boost::shared_ptr parent, std::string name, + ConstDataSetD(std::shared_ptr parent, std::string name, AccessProperties props) : data_(new Data()) { RMF_USAGE_CHECK( H5Lexists(parent->get_hid(), name.c_str(), H5P_DEFAULT), RMF::internal::get_error_message("Data set ", name, " does not exist")); - P::open(boost::make_shared( + P::open(std::make_shared( H5Dopen2(parent->get_hid(), name.c_str(), props.get_handle()), &H5Dclose, name)); // RMF_HDF5_HANDLE(s, H5Dget_space(h_->get_hid()), H5Sclose); @@ -160,7 +159,7 @@ class ConstDataSetD : public ConstDataSetAttributes { RMF_USAGE_CHECK( H5Lexists(file, name.c_str(), H5P_DEFAULT), RMF::internal::get_error_message("Data set ", name, " does not exist")); - P::open(boost::make_shared( + P::open(std::make_shared( H5Dopen2(file, name.c_str(), H5P_DEFAULT), &H5Dclose, name)); // RMF_HDF5_HANDLE(s, H5Dget_space(h_->get_hid()), H5Sclose); RMF_HDF5_HANDLE(sel, H5Dget_space(Object::get_handle()), &H5Sclose); diff --git a/include/RMF/HDF5/ConstFile.h b/include/RMF/HDF5/ConstFile.h index efc3f6b2..3f3e9e91 100644 --- a/include/RMF/HDF5/ConstFile.h +++ b/include/RMF/HDF5/ConstFile.h @@ -27,7 +27,7 @@ namespace HDF5 { class RMFEXPORT ConstFile : public ConstGroup { public: #if !defined(RMF_DOXYGEN) && !defined(SWIG) - ConstFile(boost::shared_ptr h); + ConstFile(std::shared_ptr h); #endif ConstFile(File f); ConstFile() {} diff --git a/include/RMF/HDF5/ConstGroup.h b/include/RMF/HDF5/ConstGroup.h index 4b3afa0c..f80cf42d 100644 --- a/include/RMF/HDF5/ConstGroup.h +++ b/include/RMF/HDF5/ConstGroup.h @@ -38,7 +38,7 @@ RMF_ENABLE_WARNINGS namespace RMF { } #ifndef SWIG protected: - ConstGroup(boost::shared_ptr h); + ConstGroup(std::shared_ptr h); #endif public: ConstGroup() {}; diff --git a/include/RMF/HDF5/DataSetAccessPropertiesD.h b/include/RMF/HDF5/DataSetAccessPropertiesD.h index c2c0a508..9bd3633a 100644 --- a/include/RMF/HDF5/DataSetAccessPropertiesD.h +++ b/include/RMF/HDF5/DataSetAccessPropertiesD.h @@ -11,7 +11,7 @@ #include "RMF/config.h" #include "DataSetIndexD.h" -#include +#include RMF_ENABLE_WARNINGS namespace RMF { namespace HDF5 { @@ -19,7 +19,7 @@ RMF_ENABLE_WARNINGS namespace RMF { /** A class to manage properties controlling access to HDF5 data sets.*/ template class DataSetAccessPropertiesD { - boost::shared_ptr h_; + std::shared_ptr h_; protected: DataSetAccessPropertiesD(hid_t type) diff --git a/include/RMF/HDF5/DataSetD.h b/include/RMF/HDF5/DataSetD.h index 6315a2a0..24bc7c04 100644 --- a/include/RMF/HDF5/DataSetD.h +++ b/include/RMF/HDF5/DataSetD.h @@ -38,10 +38,10 @@ class DataSetD : public MutableAttributes > { typedef DataSetCreationPropertiesD CreationProperties; typedef DataSetAccessPropertiesD AccessProperties; - DataSetD(boost::shared_ptr parent, std::string name, + DataSetD(std::shared_ptr parent, std::string name, CreationProperties props) : P(parent, name, props) {} - DataSetD(boost::shared_ptr parent, std::string name, + DataSetD(std::shared_ptr parent, std::string name, AccessProperties props) : P(parent, name, props) {} diff --git a/include/RMF/HDF5/File.h b/include/RMF/HDF5/File.h index edf081f4..92fc44f6 100644 --- a/include/RMF/HDF5/File.h +++ b/include/RMF/HDF5/File.h @@ -55,7 +55,7 @@ RMF_ENABLE_WARNINGS namespace RMF { class RMFEXPORT File : public Group { public: #if !defined(RMF_DOXYGEN) && !defined(SWIG) - File(boost::shared_ptr h); + File(std::shared_ptr h); // silliness to make RMF easier to implement bool get_is_writable() const { unsigned int intent; diff --git a/include/RMF/HDF5/Group.h b/include/RMF/HDF5/Group.h index 6583a936..5394d395 100644 --- a/include/RMF/HDF5/Group.h +++ b/include/RMF/HDF5/Group.h @@ -38,7 +38,7 @@ class RMFEXPORT Group : public MutableAttributes { } #ifndef SWIG protected: - Group(boost::shared_ptr h); + Group(std::shared_ptr h); #endif public: Group() {} diff --git a/include/RMF/HDF5/Object.h b/include/RMF/HDF5/Object.h index 05316bfa..1f8676af 100644 --- a/include/RMF/HDF5/Object.h +++ b/include/RMF/HDF5/Object.h @@ -14,7 +14,7 @@ #include "handle.h" #include "infrastructure_macros.h" #include -#include +#include RMF_ENABLE_WARNINGS @@ -28,14 +28,14 @@ class File; the HDF5 manual} for more information. */ class RMFEXPORT Object { - boost::shared_ptr h_; + std::shared_ptr h_; #ifndef SWIG protected: - Object(boost::shared_ptr h); + Object(std::shared_ptr h); // silliness friend class Group; - boost::shared_ptr get_shared_handle() const { return h_; } - void open(boost::shared_ptr h) { h_ = h; } + std::shared_ptr get_shared_handle() const { return h_; } + void open(std::shared_ptr h) { h_ = h; } Object() {} #else private: diff --git a/include/RMF/HDF5/infrastructure_macros.h b/include/RMF/HDF5/infrastructure_macros.h index f05ec25d..f25740af 100644 --- a/include/RMF/HDF5/infrastructure_macros.h +++ b/include/RMF/HDF5/infrastructure_macros.h @@ -33,8 +33,8 @@ using RMF::operator<<; /** Create new HDF5 SharedData.handle.*/ #define RMF_HDF5_NEW_HANDLE(name, cmd, cleanup) \ - boost::shared_ptr name = \ - boost::make_shared(cmd, cleanup, #cmd) + std::shared_ptr name = \ + std::make_shared(cmd, cleanup, #cmd) #define RMF_HDF5_HANDLE(name, cmd, cleanup) \ RMF::HDF5::Handle name(cmd, cleanup, #cmd) diff --git a/include/RMF/NodeConstHandle.h b/include/RMF/NodeConstHandle.h index 860963c1..78be2d9f 100644 --- a/include/RMF/NodeConstHandle.h +++ b/include/RMF/NodeConstHandle.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -110,7 +110,7 @@ class RMFEXPORT NodeConstHandle protected: NodeID node_; - boost::shared_ptr shared_; + std::shared_ptr shared_; // for error messages std::string get_file_name() const; // for error messages @@ -118,12 +118,12 @@ class RMFEXPORT NodeConstHandle #if !defined(SWIG) && !defined(RMF_DOXYGEN) public: - NodeConstHandle(NodeID node, boost::shared_ptr shared); + NodeConstHandle(NodeID node, std::shared_ptr shared); #endif public: #if !defined(RMF_DOXYGEN) && !defined(SWIG) - boost::shared_ptr get_shared_data() const { + std::shared_ptr get_shared_data() const { return shared_; } #endif @@ -175,7 +175,7 @@ class RMFEXPORT NodeConstHandle the passed type and returns a \c void* pointer in the namespace where the type is declared (so it is found via Koenig lookup). Support has already been - added for boost::shared_ptr. + added for std::shared_ptr. Either the association must not have been set before or overwrite must be true. If overwrite is true, diff --git a/include/RMF/NodeHandle.h b/include/RMF/NodeHandle.h index 36e27ca9..3a842d6b 100644 --- a/include/RMF/NodeHandle.h +++ b/include/RMF/NodeHandle.h @@ -9,7 +9,7 @@ #ifndef RMF_NODE_HANDLE_H #define RMF_NODE_HANDLE_H -#include +#include #include #include @@ -71,7 +71,7 @@ class RMFEXPORT NodeHandle : public NodeConstHandle { } #if !defined(SWIG) && !defined(RMF_DOXYGEN) public: - NodeHandle(NodeID node, boost::shared_ptr shared); + NodeHandle(NodeID node, std::shared_ptr shared); #endif public: diff --git a/include/RMF/TraverseHelper.h b/include/RMF/TraverseHelper.h index afd32e95..6474dba7 100644 --- a/include/RMF/TraverseHelper.h +++ b/include/RMF/TraverseHelper.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include RMF_ENABLE_WARNINGS @@ -38,7 +38,7 @@ typedef std::vector TraverseHelpers; */ class RMFEXPORT TraverseHelper : public NodeConstHandle { struct Index : public RMF_LARGE_UNORDERED_MAP {}; - boost::shared_ptr active_; + std::shared_ptr active_; struct Data { decorator::ChainFactory chain_factory_; decorator::ResidueFactory residue_factory_; @@ -60,7 +60,7 @@ class RMFEXPORT TraverseHelper : public NodeConstHandle { Data(NodeConstHandle root, std::string molecule_name, double resolution, int state_filter); }; - boost::shared_ptr data_; + std::shared_ptr data_; void visit_impl(NodeConstHandle n); diff --git a/include/RMF/internal/SharedData.h b/include/RMF/internal/SharedData.h index 55817a73..5bce24bc 100644 --- a/include/RMF/internal/SharedData.h +++ b/include/RMF/internal/SharedData.h @@ -9,7 +9,7 @@ #ifndef RMF_INTERNAL_SHARED_DATA_H #define RMF_INTERNAL_SHARED_DATA_H -#include +#include #include #include "RMF/ID.h" @@ -61,7 +61,7 @@ class RMFEXPORT SharedData RMF_FOREACH_TYPE(RMF_SHARED_DATA_PARENT) public SharedDataFrames { std::string path_; bool write_; - boost::shared_ptr io_; + std::shared_ptr io_; FrameID loaded_frame_; public: @@ -73,7 +73,7 @@ class RMFEXPORT SharedData RMF_FOREACH_TYPE(RMF_HOIST); - SharedData(boost::shared_ptr io, std::string name, bool write, + SharedData(std::shared_ptr io, std::string name, bool write, bool created); void set_loaded_frame(FrameID frame); FrameID add_frame(std::string name, FrameType type); diff --git a/include/RMF/internal/SharedDataData_impl.h b/include/RMF/internal/SharedDataData_impl.h index 70cdbb95..6a7558c7 100644 --- a/include/RMF/internal/SharedDataData_impl.h +++ b/include/RMF/internal/SharedDataData_impl.h @@ -22,7 +22,7 @@ #include #include -#include +#include RMF_ENABLE_WARNINGS diff --git a/include/RMF/internal/SharedDataUserData.h b/include/RMF/internal/SharedDataUserData.h index 88af5749..0c03c5b7 100644 --- a/include/RMF/internal/SharedDataUserData.h +++ b/include/RMF/internal/SharedDataUserData.h @@ -17,7 +17,7 @@ #include #include -#include +#include RMF_ENABLE_WARNINGS @@ -28,7 +28,7 @@ inline uintptr_t get_uint(const P* p) { return reinterpret_cast(p); } template -inline uintptr_t get_uint(boost::shared_ptr

p) { +inline uintptr_t get_uint(std::shared_ptr

p) { return reinterpret_cast(p.get()); } inline uintptr_t get_uint(NodeID id) { return id.get_index(); } diff --git a/include/RMF/internal/SharedData_impl.h b/include/RMF/internal/SharedData_impl.h index a0423474..e3566929 100644 --- a/include/RMF/internal/SharedData_impl.h +++ b/include/RMF/internal/SharedData_impl.h @@ -21,7 +21,7 @@ #include "SharedDataPath.h" #include -#include +#include RMF_ENABLE_WARNINGS diff --git a/include/RMF/internal/shared_data_factories.h b/include/RMF/internal/shared_data_factories.h index f6b3a2d6..bdc72d8a 100644 --- a/include/RMF/internal/shared_data_factories.h +++ b/include/RMF/internal/shared_data_factories.h @@ -9,7 +9,7 @@ #ifndef RMF_INTERNAL_SHARED_DATA_FACTORIES_H #define RMF_INTERNAL_SHARED_DATA_FACTORIES_H -#include +#include #include #include @@ -33,10 +33,10 @@ namespace RMF { namespace internal { -RMFEXPORT boost::shared_ptr create_file(const std::string& name); -RMFEXPORT boost::shared_ptr create_buffer(BufferHandle buffer); -RMFEXPORT boost::shared_ptr read_file(const std::string& name); -RMFEXPORT boost::shared_ptr read_buffer(BufferConstHandle buffer); +RMFEXPORT std::shared_ptr create_file(const std::string& name); +RMFEXPORT std::shared_ptr create_buffer(BufferHandle buffer); +RMFEXPORT std::shared_ptr read_file(const std::string& name); +RMFEXPORT std::shared_ptr read_buffer(BufferConstHandle buffer); } // namespace internal } /* namespace RMF */ diff --git a/include/RMF/validate.h b/include/RMF/validate.h index 724dfd89..63c5babc 100644 --- a/include/RMF/validate.h +++ b/include/RMF/validate.h @@ -9,8 +9,7 @@ #ifndef RMF_VALIDATE_H #define RMF_VALIDATE_H -#include -#include +#include #include #include diff --git a/src/BufferConstHandle.cpp b/src/BufferConstHandle.cpp index 9f33a3e2..4f4ae4f2 100644 --- a/src/BufferConstHandle.cpp +++ b/src/BufferConstHandle.cpp @@ -8,8 +8,7 @@ #include "RMF/BufferConstHandle.h" #include "RMF/log.h" -#include -#include +#include #include RMF_ENABLE_WARNINGS @@ -21,8 +20,8 @@ BufferConstHandle read_buffer(std::string file_name) { std::ios::in | std::ios::binary | std::ios::ate); unsigned int size = szstr.tellg(); std::ifstream in(file_name.c_str(), std::ios::in | std::ios::binary); - boost::shared_ptr > data = - boost::make_shared >(size); + std::shared_ptr > data = + std::make_shared >(size); RMF_TRACE("Found buffer of size " << data->size()); in.read(&(*data)[0], data->size()); return BufferConstHandle(data); diff --git a/src/FileConstHandle.cpp b/src/FileConstHandle.cpp index 824d256e..10edce28 100644 --- a/src/FileConstHandle.cpp +++ b/src/FileConstHandle.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include @@ -25,7 +25,7 @@ RMF_ENABLE_WARNINGS namespace RMF { -FileConstHandle::FileConstHandle(boost::shared_ptr shared) +FileConstHandle::FileConstHandle(std::shared_ptr shared) : shared_(shared) {} NodeConstHandle FileConstHandle::get_node(NodeID id) const { diff --git a/src/FileHandle.cpp b/src/FileHandle.cpp index 9497c68e..1c65ef12 100644 --- a/src/FileHandle.cpp +++ b/src/FileHandle.cpp @@ -6,7 +6,7 @@ * */ -#include +#include #include #include "RMF/BufferHandle.h" @@ -23,7 +23,7 @@ RMF_ENABLE_WARNINGS namespace RMF { -FileHandle::FileHandle(boost::shared_ptr shared) +FileHandle::FileHandle(std::shared_ptr shared) : FileConstHandle(shared) {} NodeHandle FileHandle::get_node(NodeID id) const { diff --git a/src/NodeConstHandle.cpp b/src/NodeConstHandle.cpp index 983018db..e6213f31 100644 --- a/src/NodeConstHandle.cpp +++ b/src/NodeConstHandle.cpp @@ -6,7 +6,7 @@ * */ -#include +#include #include #include #include @@ -26,7 +26,7 @@ RMF_ENABLE_WARNINGS namespace RMF { NodeConstHandle::NodeConstHandle(NodeID node, - boost::shared_ptr shared) + std::shared_ptr shared) : node_(node), shared_(shared) {} FileConstHandle NodeConstHandle::get_file() const { diff --git a/src/NodeHandle.cpp b/src/NodeHandle.cpp index bde17c48..36cd0a62 100644 --- a/src/NodeHandle.cpp +++ b/src/NodeHandle.cpp @@ -6,7 +6,7 @@ * */ -#include +#include #include #include "RMF/FileHandle.h" @@ -21,7 +21,7 @@ RMF_ENABLE_WARNINGS namespace RMF { NodeHandle::NodeHandle(NodeID node, - boost::shared_ptr shared) + std::shared_ptr shared) : NodeConstHandle(node, shared) {} NodeHandle NodeHandle::add_child(std::string name, NodeType t) const { diff --git a/src/TraverseHelper.cpp b/src/TraverseHelper.cpp index c414d03e..8f07a7c1 100644 --- a/src/TraverseHelper.cpp +++ b/src/TraverseHelper.cpp @@ -7,7 +7,6 @@ */ #include "RMF/TraverseHelper.h" -#include RMF_ENABLE_WARNINGS @@ -33,8 +32,8 @@ TraverseHelper::Data::Data(NodeConstHandle root, std::string molecule_name, TraverseHelper::TraverseHelper(NodeConstHandle root, std::string molecule_name, double resolution, int state_filter) - : active_(boost::make_shared()), - data_(boost::make_shared(root, molecule_name, resolution, + : active_(std::make_shared()), + data_(std::make_shared(root, molecule_name, resolution, state_filter)) { visit_impl(root); } @@ -76,7 +75,7 @@ void TraverseHelper::visit_impl(NodeConstHandle n) { TraverseHelper TraverseHelper::visit(NodeConstHandle n) const { TraverseHelper ret; - ret.data_ = boost::make_shared(*data_); + ret.data_ = std::make_shared(*data_); ret.active_ = active_; ret.visit_impl(n); return ret; diff --git a/src/avrocpp/api/DataFile.hh b/src/avrocpp/api/DataFile.hh index b5ef7ee2..a257284c 100644 --- a/src/avrocpp/api/DataFile.hh +++ b/src/avrocpp/api/DataFile.hh @@ -60,8 +60,8 @@ class AVRO_DECL DataFileWriterBase : boost::noncopyable { const size_t syncInterval_; Codec codec_; - boost::shared_ptr stream_; - boost::shared_ptr buffer_; + std::shared_ptr stream_; + std::shared_ptr buffer_; const DataFileSync sync_; int64_t objectCount_; @@ -69,7 +69,7 @@ class AVRO_DECL DataFileWriterBase : boost::noncopyable { Metadata metadata_; - static boost::shared_ptr makeStream(const char* filename); + static std::shared_ptr makeStream(const char* filename); static DataFileSync makeSync(); void writeHeader(); @@ -107,7 +107,7 @@ class AVRO_DECL DataFileWriterBase : boost::noncopyable { * Constructs a data file writer to a given stream with the given schema * and sync interval. */ - DataFileWriterBase(boost::shared_ptr stream, + DataFileWriterBase(std::shared_ptr stream, const ValidSchema& schema, size_t syncInterval, Codec codec = NULL_CODEC); @@ -134,7 +134,7 @@ class AVRO_DECL DataFileWriterBase : boost::noncopyable { */ template class DataFileWriter : boost::noncopyable { - boost::shared_ptr base_; + std::shared_ptr base_; public: /** @@ -147,7 +147,7 @@ class DataFileWriter : boost::noncopyable { /** * Constructs a new data file. */ - DataFileWriter(boost::shared_ptr stream, + DataFileWriter(std::shared_ptr stream, const ValidSchema& schema, size_t syncInterval = 16 * 1024, Codec codec = NULL_CODEC) : base_(new DataFileWriterBase(stream, schema, syncInterval, codec)) {} @@ -183,7 +183,7 @@ class DataFileWriter : boost::noncopyable { */ class AVRO_DECL DataFileReaderBase : boost::noncopyable { const std::string filename_; - const boost::shared_ptr stream_; + const std::shared_ptr stream_; const DecoderPtr decoder_; int64_t objectCount_; bool eof_; @@ -193,7 +193,7 @@ class AVRO_DECL DataFileReaderBase : boost::noncopyable { ValidSchema readerSchema_; ValidSchema dataSchema_; DecoderPtr dataDecoder_; - boost::shared_ptr dataStream_; + std::shared_ptr dataStream_; typedef std::map > Metadata; Metadata metadata_; @@ -237,7 +237,7 @@ class AVRO_DECL DataFileReaderBase : boost::noncopyable { * This function should be called exactly once after constructing * the DataFileReaderBase object. */ - DataFileReaderBase(boost::shared_ptr stream); + DataFileReaderBase(std::shared_ptr stream); /** * Initializes the reader so that the reader and writer schemas @@ -292,7 +292,7 @@ class AVRO_DECL DataFileReaderBase : boost::noncopyable { */ template class DataFileReader : boost::noncopyable { - boost::shared_ptr base_; + std::shared_ptr base_; public: /** @@ -317,7 +317,7 @@ class DataFileReader : boost::noncopyable { * Constructs the reader for the given stream and the reader is * expected to use the given schema. */ - DataFileReader(boost::shared_ptr stream, + DataFileReader(std::shared_ptr stream, const ValidSchema& readerSchema) : base_(new DataFileReaderBase(stream)) { base_->init(readerSchema); @@ -327,7 +327,7 @@ class DataFileReader : boost::noncopyable { * Constructs the reader for the given stream and the reader is * expected to use the schema that is used with data. */ - DataFileReader(boost::shared_ptr stream) + DataFileReader(std::shared_ptr stream) : base_(new DataFileReaderBase(stream)) { base_->init(); } @@ -341,7 +341,7 @@ class DataFileReader : boost::noncopyable { * The schema present in the data file will be used for reading * from this reader. */ - DataFileReader(boost::shared_ptr base) : base_(base) { + DataFileReader(std::shared_ptr base) : base_(base) { base_->init(); } @@ -354,7 +354,7 @@ class DataFileReader : boost::noncopyable { * The argument readerSchema will be used for reading * from this reader. */ - DataFileReader(boost::shared_ptr base, + DataFileReader(std::shared_ptr base, const ValidSchema& readerSchema) : base_(base) { base_->init(readerSchema); diff --git a/src/avrocpp/api/Decoder.hh b/src/avrocpp/api/Decoder.hh index 52c36f68..da6acb67 100644 --- a/src/avrocpp/api/Decoder.hh +++ b/src/avrocpp/api/Decoder.hh @@ -27,7 +27,7 @@ #include "ValidSchema.hh" #include "Stream.hh" -#include +#include /// \file /// @@ -158,7 +158,7 @@ class AVRO_DECL Decoder { /** * Shared pointer to Decoder. */ -typedef boost::shared_ptr DecoderPtr; +typedef std::shared_ptr DecoderPtr; /** * ResolvingDecoder is derived from \ref Decoder, with an additional @@ -177,7 +177,7 @@ class AVRO_DECL ResolvingDecoder : public Decoder { /** * Shared pointer to ResolvingDecoder. */ -typedef boost::shared_ptr ResolvingDecoderPtr; +typedef std::shared_ptr ResolvingDecoderPtr; /** * Returns an decoder that can decode binary Avro standard. */ diff --git a/src/avrocpp/api/Encoder.hh b/src/avrocpp/api/Encoder.hh index 48709b56..f64d4e6f 100644 --- a/src/avrocpp/api/Encoder.hh +++ b/src/avrocpp/api/Encoder.hh @@ -27,7 +27,7 @@ #include "ValidSchema.hh" #include "Stream.hh" -#include +#include /// \file /// @@ -141,7 +141,7 @@ class AVRO_DECL Encoder { /** * Shared pointer to Encoder. */ -typedef boost::shared_ptr EncoderPtr; +typedef std::shared_ptr EncoderPtr; /** * Returns an encoder that can encode binary Avro standard. diff --git a/src/avrocpp/api/Node.hh b/src/avrocpp/api/Node.hh index cce86c3d..6ab71454 100644 --- a/src/avrocpp/api/Node.hh +++ b/src/avrocpp/api/Node.hh @@ -23,7 +23,7 @@ #include #include -#include +#include #include "Exception.hh" #include "Types.hh" @@ -33,7 +33,7 @@ namespace internal_avro { class Node; -typedef boost::shared_ptr NodePtr; +typedef std::shared_ptr NodePtr; class AVRO_DECL Name { std::string ns_; diff --git a/src/avrocpp/api/NodeImpl.hh b/src/avrocpp/api/NodeImpl.hh index eca89841..599a8b2e 100644 --- a/src/avrocpp/api/NodeImpl.hh +++ b/src/avrocpp/api/NodeImpl.hh @@ -23,7 +23,6 @@ #include #include -#include #include "Node.hh" #include "NodeConcepts.hh" @@ -178,7 +177,7 @@ class AVRO_DECL NodePrimitive : public NodeImplPrimitive { }; class AVRO_DECL NodeSymbolic : public NodeImplSymbolic { - typedef boost::weak_ptr NodeWeakPtr; + typedef std::weak_ptr NodeWeakPtr; public: NodeSymbolic() : NodeImplSymbolic(AVRO_SYMBOLIC) {} @@ -437,8 +436,8 @@ inline NodePtr resolveSymbol(const NodePtr &node) { if (node->type() != AVRO_SYMBOLIC) { throw Exception("Only symbolic nodes may be resolved"); } - boost::shared_ptr symNode = - boost::static_pointer_cast(node); + std::shared_ptr symNode = + std::static_pointer_cast(node); return symNode->getNode(); } diff --git a/src/avrocpp/api/ResolverSchema.hh b/src/avrocpp/api/ResolverSchema.hh index e4285cd6..fe2d96e4 100644 --- a/src/avrocpp/api/ResolverSchema.hh +++ b/src/avrocpp/api/ResolverSchema.hh @@ -20,7 +20,7 @@ #define avro_ResolverSchema_hh__ #include -#include +#include #include #include "Config.hh" @@ -47,7 +47,7 @@ class AVRO_DECL ResolverSchema { void parse(Reader &reader, uint8_t *address); - boost::shared_ptr resolver_; + std::shared_ptr resolver_; }; } // namespace internal_avro diff --git a/src/avrocpp/api/Stream.hh b/src/avrocpp/api/Stream.hh index ed9f7b69..776c89c3 100644 --- a/src/avrocpp/api/Stream.hh +++ b/src/avrocpp/api/Stream.hh @@ -127,7 +127,7 @@ class AVRO_DECL OutputStream : boost::noncopyable { /** * Returns a new OutputStream, which grows in memory chunks of specified size. */ -AVRO_DECL boost::shared_ptr memoryOutputStream(size_t chunkSize = +AVRO_DECL std::shared_ptr memoryOutputStream(size_t chunkSize = 4 * 1024); /** @@ -135,7 +135,7 @@ AVRO_DECL boost::shared_ptr memoryOutputStream(size_t chunkSize = * It does not copy the data, the byte array should remain valid * until the InputStream is used. */ -AVRO_DECL boost::shared_ptr memoryInputStream(const uint8_t* data, +AVRO_DECL std::shared_ptr memoryInputStream(const uint8_t* data, size_t len); /** @@ -145,7 +145,7 @@ AVRO_DECL boost::shared_ptr memoryInputStream(const uint8_t* data, * input stream are the snapshot of the outputstream. One can construct * any number of memory input stream from a single memory output stream. */ -AVRO_DECL boost::shared_ptr memoryInputStream( +AVRO_DECL std::shared_ptr memoryInputStream( const OutputStream& source); /** @@ -155,7 +155,7 @@ AVRO_DECL boost::shared_ptr memoryInputStream( * If there is a file with the given name, it is truncated and overwritten. * If there is no file with the given name, it is created. */ -AVRO_DECL boost::shared_ptr fileOutputStream(const char* filename, +AVRO_DECL std::shared_ptr fileOutputStream(const char* filename, size_t bufferSize = 8 * 1024); @@ -163,7 +163,7 @@ AVRO_DECL boost::shared_ptr fileOutputStream(const char* filename, * Returns a new InputStream whose contents come from the given file. * Data is read in chunks of given buffer size. */ -AVRO_DECL boost::shared_ptr fileInputStream(const char* filename, +AVRO_DECL std::shared_ptr fileInputStream(const char* filename, size_t bufferSize = 8 * 1024); @@ -172,7 +172,7 @@ AVRO_DECL boost::shared_ptr fileInputStream(const char* filename, * std::ostream. The std::ostream object should outlive the returned * OutputStream. */ -AVRO_DECL boost::shared_ptr ostreamOutputStream( +AVRO_DECL std::shared_ptr ostreamOutputStream( std::ostream& os, size_t bufferSize = 8 * 1024); /** @@ -180,7 +180,7 @@ AVRO_DECL boost::shared_ptr ostreamOutputStream( * std::istream. The std::istream object should outlive the returned * InputStream. */ -AVRO_DECL boost::shared_ptr istreamInputStream(std::istream& in, +AVRO_DECL std::shared_ptr istreamInputStream(std::istream& in, size_t bufferSize = 8 * 1024); diff --git a/src/avrocpp/api/buffer/detail/BufferDetail.hh b/src/avrocpp/api/buffer/detail/BufferDetail.hh index 33f948fb..e79542b6 100644 --- a/src/avrocpp/api/buffer/detail/BufferDetail.hh +++ b/src/avrocpp/api/buffer/detail/BufferDetail.hh @@ -19,7 +19,7 @@ #ifndef avro_BufferDetail_hh__ #define avro_BufferDetail_hh__ -#include +#include #include #include #include @@ -93,7 +93,7 @@ class CallOnDestroy { class Chunk { public: - typedef boost::shared_ptr SharedPtr; + typedef std::shared_ptr SharedPtr; /// Default constructor, allocates a new underlying block for this chunk. Chunk(size_type size) @@ -112,7 +112,7 @@ class Chunk { private: // reference counted object will call a functor when it's destroyed - boost::shared_ptr callOnDestroy_; + std::shared_ptr callOnDestroy_; public: /// Remove readable bytes from the front of the chunk by advancing the @@ -270,8 +270,8 @@ class BufferImpl : boost::noncopyable { public: typedef std::deque ChunkList; - typedef boost::shared_ptr SharedPtr; - typedef boost::shared_ptr ConstSharedPtr; + typedef std::shared_ptr SharedPtr; + typedef std::shared_ptr ConstSharedPtr; /// Default constructor, creates a buffer without any chunks BufferImpl() : freeSpace_(0), size_(0) {} diff --git a/src/avrocpp/examples/custom.cc b/src/avrocpp/examples/custom.cc index 8ba97407..86da4c6a 100644 --- a/src/avrocpp/examples/custom.cc +++ b/src/avrocpp/examples/custom.cc @@ -39,14 +39,14 @@ struct codec_traits > { }; } int main() { - boost::shared_ptr out = + std::shared_ptr out = internal_avro::memoryOutputStream(); internal_avro::EncoderPtr e = internal_avro::binaryEncoder(); e->init(*out); std::complex c1(1.0, 2.0); internal_avro::encode(*e, c1); - boost::shared_ptr in = + std::shared_ptr in = internal_avro::memoryInputStream(*out); internal_avro::DecoderPtr d = internal_avro::binaryDecoder(); d->init(*in); diff --git a/src/avrocpp/examples/generated.cc b/src/avrocpp/examples/generated.cc index 1e37a6d8..890fdca6 100644 --- a/src/avrocpp/examples/generated.cc +++ b/src/avrocpp/examples/generated.cc @@ -21,7 +21,7 @@ #include "avro/Decoder.hh" int main() { - boost::shared_ptr out = + std::shared_ptr out = internal_avro::memoryOutputStream(); internal_avro::EncoderPtr e = internal_avro::binaryEncoder(); e->init(*out); @@ -30,7 +30,7 @@ int main() { c1.im = 2.13; internal_avro::encode(*e, c1); - boost::shared_ptr in = + std::shared_ptr in = internal_avro::memoryInputStream(*out); internal_avro::DecoderPtr d = internal_avro::binaryDecoder(); d->init(*in); diff --git a/src/avrocpp/examples/generic.cc b/src/avrocpp/examples/generic.cc index 18baec78..09c1fd2a 100644 --- a/src/avrocpp/examples/generic.cc +++ b/src/avrocpp/examples/generic.cc @@ -33,7 +33,7 @@ int main() { internal_avro::ValidSchema cpxSchema; internal_avro::compileJsonSchema(ifs, cpxSchema); - boost::shared_ptr out = + std::shared_ptr out = internal_avro::memoryOutputStream(); internal_avro::EncoderPtr e = internal_avro::binaryEncoder(); e->init(*out); @@ -42,7 +42,7 @@ int main() { c1.im = 105.77; internal_avro::encode(*e, c1); - boost::shared_ptr in = + std::shared_ptr in = internal_avro::memoryInputStream(*out); internal_avro::DecoderPtr d = internal_avro::binaryDecoder(); d->init(*in); diff --git a/src/avrocpp/examples/resolving.cc b/src/avrocpp/examples/resolving.cc index 48334bfe..6abc2bfb 100644 --- a/src/avrocpp/examples/resolving.cc +++ b/src/avrocpp/examples/resolving.cc @@ -38,7 +38,7 @@ int main() { internal_avro::ValidSchema cpxSchema = load("cpx.json"); internal_avro::ValidSchema imaginarySchema = load("imaginary.json"); - boost::shared_ptr out = + std::shared_ptr out = internal_avro::memoryOutputStream(); internal_avro::EncoderPtr e = internal_avro::binaryEncoder(); e->init(*out); @@ -47,7 +47,7 @@ int main() { c1.im = 105.77; internal_avro::encode(*e, c1); - boost::shared_ptr in = + std::shared_ptr in = internal_avro::memoryInputStream(*out); internal_avro::DecoderPtr d = internal_avro::resolvingDecoder( cpxSchema, imaginarySchema, internal_avro::binaryDecoder()); diff --git a/src/avrocpp/examples/validating.cc b/src/avrocpp/examples/validating.cc index 56b059a2..4ae1e645 100644 --- a/src/avrocpp/examples/validating.cc +++ b/src/avrocpp/examples/validating.cc @@ -46,7 +46,7 @@ int main() { internal_avro::ValidSchema cpxSchema; internal_avro::compileJsonSchema(ifs, cpxSchema); - boost::shared_ptr out = + std::shared_ptr out = internal_avro::memoryOutputStream(); internal_avro::EncoderPtr e = internal_avro::validatingEncoder( cpxSchema, internal_avro::binaryEncoder()); @@ -54,7 +54,7 @@ int main() { std::complex c1(1.0, 2.0); internal_avro::encode(*e, c1); - boost::shared_ptr in = + std::shared_ptr in = internal_avro::memoryInputStream(*out); internal_avro::DecoderPtr d = internal_avro::validatingDecoder( cpxSchema, internal_avro::binaryDecoder()); diff --git a/src/avrocpp/impl/BinaryDecoder.cc b/src/avrocpp/impl/BinaryDecoder.cc index 28e384c2..f605ca0b 100644 --- a/src/avrocpp/impl/BinaryDecoder.cc +++ b/src/avrocpp/impl/BinaryDecoder.cc @@ -23,11 +23,10 @@ #include "Exception.hh" #include -#include namespace internal_avro { -using boost::make_shared; +using std::make_shared; class BinaryDecoder : public Decoder { StreamReader in_; diff --git a/src/avrocpp/impl/BinaryEncoder.cc b/src/avrocpp/impl/BinaryEncoder.cc index 4725b7fb..256c221a 100644 --- a/src/avrocpp/impl/BinaryEncoder.cc +++ b/src/avrocpp/impl/BinaryEncoder.cc @@ -19,12 +19,11 @@ #include "Encoder.hh" #include "Zigzag.hh" #include -#include namespace internal_avro { -using boost::make_shared; -using boost::shared_ptr; +using std::make_shared; +using std::shared_ptr; class BinaryEncoder : public Encoder { StreamWriter out_; diff --git a/src/avrocpp/impl/Compiler.cc b/src/avrocpp/impl/Compiler.cc index 5397a35b..82d720ac 100644 --- a/src/avrocpp/impl/Compiler.cc +++ b/src/avrocpp/impl/Compiler.cc @@ -217,8 +217,8 @@ static NodePtr makeNode(const Entity& e, const map& m, result = NodePtr(new NodeRecord()); st[nm] = result; NodePtr r = makeRecordNode(e, nm, m, st, nm.ns()); - (boost::dynamic_pointer_cast(r)) - ->swap(*boost::dynamic_pointer_cast(result)); + (std::dynamic_pointer_cast(r)) + ->swap(*std::dynamic_pointer_cast(result)); } else { result = (type == "enum") ? makeEnumNode(e, nm, m) : makeFixedNode(e, nm, m); @@ -278,7 +278,7 @@ ValidSchema compileJsonSchemaFromString(const std::string& input) { } static ValidSchema compile(std::istream& is) { - boost::shared_ptr in = istreamInputStream(is); + std::shared_ptr in = istreamInputStream(is); return compileJsonSchemaFromStream(*in); } diff --git a/src/avrocpp/impl/DataFile.cc b/src/avrocpp/impl/DataFile.cc index 5ef97e4f..58194beb 100644 --- a/src/avrocpp/impl/DataFile.cc +++ b/src/avrocpp/impl/DataFile.cc @@ -28,7 +28,7 @@ #include namespace internal_avro { -using boost::shared_ptr; +using std::shared_ptr; using std::ostringstream; using std::istringstream; using std::vector; @@ -77,7 +77,7 @@ DataFileWriterBase::DataFileWriterBase(const char* filename, setup(); } -DataFileWriterBase::DataFileWriterBase(boost::shared_ptr stream, +DataFileWriterBase::DataFileWriterBase(std::shared_ptr stream, const ValidSchema& schema, size_t syncInterval, Codec codec) @@ -133,7 +133,7 @@ void DataFileWriterBase::sync() { int64_t byteCount = buffer_->byteCount(); internal_avro::encode(*encoderPtr_, byteCount); encoderPtr_->flush(); - boost::shared_ptr in = memoryInputStream(*buffer_); + std::shared_ptr in = memoryInputStream(*buffer_); copy(*in, *stream_); } else { std::vector buf; @@ -146,12 +146,12 @@ void DataFileWriterBase::sync() { const uint8_t* data; size_t len; - boost::shared_ptr input = memoryInputStream(*buffer_); + std::shared_ptr input = memoryInputStream(*buffer_); while (input->next(&data, &len)) { boost::iostreams::write(os, reinterpret_cast(data), len); } } - boost::shared_ptr in = memoryInputStream( + std::shared_ptr in = memoryInputStream( reinterpret_cast(&buf[0]), buf.size()); int64_t byteCount = buf.size(); internal_avro::encode(*encoderPtr_, byteCount); @@ -213,7 +213,7 @@ DataFileReaderBase::DataFileReaderBase(const char* filename) readHeader(); } -DataFileReaderBase::DataFileReaderBase(boost::shared_ptr stream) +DataFileReaderBase::DataFileReaderBase(std::shared_ptr stream) : filename_("stream"), stream_(stream), decoder_(binaryDecoder()), @@ -311,9 +311,9 @@ class BoundedInputStream : public InputStream { BoundedInputStream(InputStream& in, size_t limit) : in_(in), limit_(limit) {} }; -boost::shared_ptr boundedInputStream(InputStream& in, +std::shared_ptr boundedInputStream(InputStream& in, size_t limit) { - return boost::shared_ptr(new BoundedInputStream(in, limit)); + return std::shared_ptr(new BoundedInputStream(in, limit)); } bool DataFileReaderBase::readDataBlock() { @@ -330,7 +330,7 @@ bool DataFileReaderBase::readDataBlock() { internal_avro::decode(*decoder_, byteCount); decoder_->init(*stream_); - boost::shared_ptr st = + std::shared_ptr st = boundedInputStream(*stream_, static_cast(byteCount)); if (codec_ == NULL_CODEC) { dataDecoder_->init(*st); @@ -350,7 +350,7 @@ bool DataFileReaderBase::readDataBlock() { os_->push(boost::iostreams::basic_array_source(&compressed_[0], compressed_.size())); - boost::shared_ptr in = istreamInputStream(*os_); + std::shared_ptr in = istreamInputStream(*os_); dataDecoder_->init(*in); dataStream_ = in; } diff --git a/src/avrocpp/impl/FileStream.cc b/src/avrocpp/impl/FileStream.cc index e1d16aea..75c8eb28 100644 --- a/src/avrocpp/impl/FileStream.cc +++ b/src/avrocpp/impl/FileStream.cc @@ -153,7 +153,7 @@ struct IStreamBufferCopyIn : public BufferCopyIn { class BufferCopyInInputStream : public InputStream { const size_t bufferSize_; uint8_t* const buffer_; - boost::shared_ptr in_; + std::shared_ptr in_; size_t byteCount_; uint8_t* next_; size_t available_; @@ -213,7 +213,7 @@ class BufferCopyInInputStream : public InputStream { } public: - BufferCopyInInputStream(boost::shared_ptr& in, + BufferCopyInInputStream(std::shared_ptr& in, size_t bufferSize) : bufferSize_(bufferSize), buffer_(new uint8_t[bufferSize]), @@ -293,7 +293,7 @@ struct OStreamBufferCopyOut : public BufferCopyOut { class BufferCopyOutputStream : public OutputStream { size_t bufferSize_; uint8_t* const buffer_; - boost::shared_ptr out_; + std::shared_ptr out_; uint8_t* next_; size_t available_; size_t byteCount_; @@ -326,7 +326,7 @@ class BufferCopyOutputStream : public OutputStream { } public: - BufferCopyOutputStream(boost::shared_ptr out, + BufferCopyOutputStream(std::shared_ptr out, size_t bufferSize) : bufferSize_(bufferSize), buffer_(new uint8_t[bufferSize]), @@ -338,31 +338,31 @@ class BufferCopyOutputStream : public OutputStream { ~BufferCopyOutputStream() { delete[] buffer_; } }; -boost::shared_ptr fileInputStream(const char* filename, +std::shared_ptr fileInputStream(const char* filename, size_t bufferSize) { - boost::shared_ptr in(new FileBufferCopyIn(filename)); - return boost::shared_ptr( + std::shared_ptr in(new FileBufferCopyIn(filename)); + return std::shared_ptr( new BufferCopyInInputStream(in, bufferSize)); } -boost::shared_ptr istreamInputStream(istream& is, +std::shared_ptr istreamInputStream(istream& is, size_t bufferSize) { - boost::shared_ptr in(new IStreamBufferCopyIn(is)); - return boost::shared_ptr( + std::shared_ptr in(new IStreamBufferCopyIn(is)); + return std::shared_ptr( new BufferCopyInInputStream(in, bufferSize)); } -boost::shared_ptr fileOutputStream(const char* filename, +std::shared_ptr fileOutputStream(const char* filename, size_t bufferSize) { - boost::shared_ptr out(new FileBufferCopyOut(filename)); - return boost::shared_ptr( + std::shared_ptr out(new FileBufferCopyOut(filename)); + return std::shared_ptr( new BufferCopyOutputStream(out, bufferSize)); } -boost::shared_ptr ostreamOutputStream(ostream& os, +std::shared_ptr ostreamOutputStream(ostream& os, size_t bufferSize) { - boost::shared_ptr out(new OStreamBufferCopyOut(os)); - return boost::shared_ptr( + std::shared_ptr out(new OStreamBufferCopyOut(os)); + return std::shared_ptr( new BufferCopyOutputStream(out, bufferSize)); } diff --git a/src/avrocpp/impl/Resolver.cc b/src/avrocpp/impl/Resolver.cc index bb7fa6ae..8f445f18 100644 --- a/src/avrocpp/impl/Resolver.cc +++ b/src/avrocpp/impl/Resolver.cc @@ -29,7 +29,7 @@ namespace internal_avro { class ResolverFactory; -typedef boost::shared_ptr ResolverPtr; +typedef std::shared_ptr ResolverPtr; typedef boost::ptr_vector ResolverPtrVector; // #define DEBUG_VERBOSE diff --git a/src/avrocpp/impl/Stream.cc b/src/avrocpp/impl/Stream.cc index a062db2b..c84602a0 100644 --- a/src/avrocpp/impl/Stream.cc +++ b/src/avrocpp/impl/Stream.cc @@ -154,21 +154,21 @@ class MemoryOutputStream : public OutputStream { void flush() {} }; -boost::shared_ptr memoryOutputStream(size_t chunkSize) { - return boost::shared_ptr(new MemoryOutputStream(chunkSize)); +std::shared_ptr memoryOutputStream(size_t chunkSize) { + return std::shared_ptr(new MemoryOutputStream(chunkSize)); } -boost::shared_ptr memoryInputStream(const uint8_t* data, +std::shared_ptr memoryInputStream(const uint8_t* data, size_t len) { - return boost::shared_ptr(new MemoryInputStream2(data, len)); + return std::shared_ptr(new MemoryInputStream2(data, len)); } -boost::shared_ptr memoryInputStream(const OutputStream& source) { +std::shared_ptr memoryInputStream(const OutputStream& source) { const MemoryOutputStream& mos = dynamic_cast(source); return (mos.data_.empty()) - ? boost::shared_ptr(new MemoryInputStream2(0, 0)) - : boost::shared_ptr( + ? std::shared_ptr(new MemoryInputStream2(0, 0)) + : std::shared_ptr( new MemoryInputStream(mos.data_, mos.chunkSize_, (mos.chunkSize_ - mos.available_))); } diff --git a/src/avrocpp/impl/ValidSchema.cc b/src/avrocpp/impl/ValidSchema.cc index a6f15b9e..7fc2a365 100644 --- a/src/avrocpp/impl/ValidSchema.cc +++ b/src/avrocpp/impl/ValidSchema.cc @@ -26,8 +26,8 @@ using std::string; using std::make_pair; using boost::format; -using boost::shared_ptr; -using boost::static_pointer_cast; +using std::shared_ptr; +using std::static_pointer_cast; namespace internal_avro { diff --git a/src/avrocpp/impl/json/JsonDom.cc b/src/avrocpp/impl/json/JsonDom.cc index 428b92f3..3cb435dc 100644 --- a/src/avrocpp/impl/json/JsonDom.cc +++ b/src/avrocpp/impl/json/JsonDom.cc @@ -82,7 +82,7 @@ Entity loadEntity(InputStream& in) { } Entity loadEntity(const uint8_t* text, size_t len) { - boost::shared_ptr in = memoryInputStream(text, len); + std::shared_ptr in = memoryInputStream(text, len); return loadEntity(*in); } @@ -127,12 +127,12 @@ void writeEntity(JsonGenerator& g, const Entity& n) { } std::string Entity::toString() const { - boost::shared_ptr out = memoryOutputStream(); + std::shared_ptr out = memoryOutputStream(); JsonGenerator g; g.init(*out); writeEntity(g, *this); g.flush(); - boost::shared_ptr in = memoryInputStream(*out); + std::shared_ptr in = memoryInputStream(*out); const uint8_t* p = 0; size_t n = 0; size_t c = 0; @@ -142,7 +142,7 @@ std::string Entity::toString() const { std::string result; result.resize(c); c = 0; - boost::shared_ptr in2 = memoryInputStream(*out); + std::shared_ptr in2 = memoryInputStream(*out); while (in2->next(&p, &n)) { ::memcpy(&result[c], p, n); c += n; diff --git a/src/avrocpp/impl/parsing/JsonCodec.cc b/src/avrocpp/impl/parsing/JsonCodec.cc index 39534593..d5a3ea46 100644 --- a/src/avrocpp/impl/parsing/JsonCodec.cc +++ b/src/avrocpp/impl/parsing/JsonCodec.cc @@ -23,9 +23,7 @@ #include #include #include -#include -#include -#include +#include #include #include @@ -42,8 +40,8 @@ namespace internal_avro { namespace parsing { -using boost::shared_ptr; -using boost::static_pointer_cast; +using std::shared_ptr; +using std::static_pointer_cast; using std::map; using std::vector; @@ -57,7 +55,7 @@ using internal_avro::json::JsonGenerator; class JsonGrammarGenerator : public ValidatingGrammarGenerator { Production doGenerate(const NodePtr& n, - std::map >& m); + std::map >& m); }; static std::string nameOf(const NodePtr& n) { @@ -70,7 +68,7 @@ static std::string nameOf(const NodePtr& n) { } Production JsonGrammarGenerator::doGenerate( - const NodePtr& n, std::map >& m) { + const NodePtr& n, std::map >& m) { switch (n->type()) { case AVRO_NULL: case AVRO_BOOL: @@ -104,7 +102,7 @@ Production JsonGrammarGenerator::doGenerate( bool found = m.find(n) != m.end(); - shared_ptr p = boost::make_shared(result); + shared_ptr p = std::make_shared(result); m[n] = p; return found ? Production(1, Symbol::indirect(p)) : result; @@ -118,7 +116,7 @@ Production JsonGrammarGenerator::doGenerate( } Symbol r[] = {Symbol::nameListSymbol(nn), Symbol::enumSymbol()}; Production result(r, r + 2); - m[n] = boost::make_shared(result); + m[n] = std::make_shared(result); return result; } case AVRO_UNION: { @@ -635,12 +633,12 @@ void JsonEncoder

::encodeUnionIndex(size_t e) { } // namespace parsing DecoderPtr jsonDecoder(const ValidSchema& s) { - return boost::make_shared > >(s); } EncoderPtr jsonEncoder(const ValidSchema& schema) { - return boost::make_shared< + return std::make_shared< parsing::JsonEncoder > >( schema); } diff --git a/src/avrocpp/impl/parsing/ResolvingDecoder.cc b/src/avrocpp/impl/parsing/ResolvingDecoder.cc index 549ceac0..8ff5cdb4 100644 --- a/src/avrocpp/impl/parsing/ResolvingDecoder.cc +++ b/src/avrocpp/impl/parsing/ResolvingDecoder.cc @@ -24,9 +24,7 @@ #include #include #include -#include -#include -#include +#include #include #include @@ -40,12 +38,12 @@ namespace internal_avro { -using boost::make_shared; +using std::make_shared; namespace parsing { -using boost::shared_ptr; -using boost::static_pointer_cast; +using std::shared_ptr; +using std::static_pointer_cast; using std::map; using std::pair; @@ -188,7 +186,7 @@ Production ResolvingGrammarGenerator::resolveRecords( if (p.size() == 1) { result.push_back(p[0]); } else { - result.push_back(Symbol::indirect(boost::make_shared(p))); + result.push_back(Symbol::indirect(std::make_shared(p))); } } } @@ -249,7 +247,7 @@ Production ResolvingGrammarGenerator::doGenerate( Symbol r[] = {Symbol::sizeCheckSymbol(reader->fixedSize()), Symbol::fixedSymbol()}; Production result(r, r + 2); - m[make_pair(writer, reader)] = boost::make_shared(result); + m[make_pair(writer, reader)] = std::make_shared(result); return result; } break; @@ -261,7 +259,7 @@ Production ResolvingGrammarGenerator::doGenerate( const bool found = m.find(key) != m.end(); - shared_ptr p = boost::make_shared(result); + shared_ptr p = std::make_shared(result); m[key] = p; return found ? Production(1, Symbol::indirect(p)) : result; } @@ -272,7 +270,7 @@ Production ResolvingGrammarGenerator::doGenerate( Symbol r[] = {Symbol::enumAdjustSymbol(writer, reader), Symbol::enumSymbol(), }; Production result(r, r + 2); - m[make_pair(writer, reader)] = boost::make_shared(result); + m[make_pair(writer, reader)] = std::make_shared(result); return result; } break; diff --git a/src/avrocpp/impl/parsing/Symbol.hh b/src/avrocpp/impl/parsing/Symbol.hh index 61031e97..321ca1c1 100644 --- a/src/avrocpp/impl/parsing/Symbol.hh +++ b/src/avrocpp/impl/parsing/Symbol.hh @@ -25,8 +25,7 @@ #include #include -#include -#include +#include #include #include "Node.hh" @@ -202,11 +201,11 @@ class Symbol { return Symbol(sPlaceholder, n); } - static Symbol indirect(const boost::shared_ptr& p) { + static Symbol indirect(const std::shared_ptr& p) { return Symbol(sIndirect, p); } - static Symbol symbolic(const boost::weak_ptr& p) { + static Symbol symbolic(const std::weak_ptr& p) { return Symbol(sSymbolic, p); } @@ -233,17 +232,17 @@ class Symbol { template void fixup(Production& p, - const std::map >& m) { + const std::map >& m) { for (Production::iterator it = p.begin(); it != p.end(); ++it) { fixup(*it, m); } } template -void fixup(Symbol& s, const std::map >& m) { +void fixup(Symbol& s, const std::map >& m) { switch (s.kind()) { case Symbol::sIndirect: - fixup(*s.extra >(), m); + fixup(*s.extra >(), m); break; case Symbol::sAlternative: { std::vector* vv = s.extrap >(); @@ -259,7 +258,7 @@ void fixup(Symbol& s, const std::map >& m) { } break; case Symbol::sPlaceholder: s = Symbol::symbolic( - boost::weak_ptr(m.find(s.extra())->second)); + std::weak_ptr(m.find(s.extra())->second)); break; case Symbol::sUnionAdjust: fixup(s.extrap >()->second, m); @@ -325,15 +324,15 @@ class SimpleParser { append(boost::tuples::get<0>(*s.extrap())); continue; case Symbol::sIndirect: { - boost::shared_ptr pp = - s.extra >(); + std::shared_ptr pp = + s.extra >(); parsingStack.pop(); append(*pp); } continue; case Symbol::sSymbolic: { - boost::shared_ptr pp( - s.extra >()); + std::shared_ptr pp( + s.extra >()); parsingStack.pop(); append(*pp); } @@ -465,15 +464,15 @@ class SimpleParser { } } break; case Symbol::sIndirect: { - boost::shared_ptr pp = - t.extra >(); + std::shared_ptr pp = + t.extra >(); parsingStack.pop(); append(*pp); } continue; case Symbol::sSymbolic: { - boost::shared_ptr pp( - t.extra >()); + std::shared_ptr pp( + t.extra >()); parsingStack.pop(); append(*pp); } diff --git a/src/avrocpp/impl/parsing/ValidatingCodec.cc b/src/avrocpp/impl/parsing/ValidatingCodec.cc index 00ab7e0e..c0f47389 100644 --- a/src/avrocpp/impl/parsing/ValidatingCodec.cc +++ b/src/avrocpp/impl/parsing/ValidatingCodec.cc @@ -22,9 +22,7 @@ #include #include #include -#include -#include -#include +#include #include #include "ValidSchema.hh" @@ -36,9 +34,9 @@ namespace internal_avro { namespace parsing { -using boost::shared_ptr; -using boost::weak_ptr; -using boost::static_pointer_cast; +using std::shared_ptr; +using std::weak_ptr; +using std::static_pointer_cast; using std::map; using std::vector; @@ -82,7 +80,7 @@ Production ValidatingGrammarGenerator::doGenerate( Symbol r[] = {Symbol::sizeCheckSymbol(n->fixedSize()), Symbol::fixedSymbol()}; Production result(r, r + 2); - m[n] = boost::make_shared(result); + m[n] = std::make_shared(result); return result; } case AVRO_RECORD: { @@ -99,7 +97,7 @@ Production ValidatingGrammarGenerator::doGenerate( bool found = m.find(n) != m.end(); - shared_ptr p = boost::make_shared(result); + shared_ptr p = std::make_shared(result); m[n] = p; return found ? Production(1, Symbol::indirect(p)) : result; @@ -107,7 +105,7 @@ Production ValidatingGrammarGenerator::doGenerate( case AVRO_ENUM: { Symbol r[] = {Symbol::sizeCheckSymbol(n->names()), Symbol::enumSymbol()}; Production result(r, r + 2); - m[n] = boost::make_shared(result); + m[n] = std::make_shared(result); return result; } case AVRO_ARRAY: { @@ -513,13 +511,13 @@ void ValidatingEncoder

::encodeUnionIndex(size_t e) { } // namespace parsing DecoderPtr validatingDecoder(const ValidSchema& s, const DecoderPtr& base) { - return boost::make_shared > >(s, base); } EncoderPtr validatingEncoder(const ValidSchema& schema, const EncoderPtr& base) { - return boost::make_shared > >(schema, base); } diff --git a/src/avrocpp/impl/parsing/ValidatingCodec.hh b/src/avrocpp/impl/parsing/ValidatingCodec.hh index 441cd672..1f2b9345 100644 --- a/src/avrocpp/impl/parsing/ValidatingCodec.hh +++ b/src/avrocpp/impl/parsing/ValidatingCodec.hh @@ -21,7 +21,6 @@ #include #include -#include "boost/make_shared.hpp" #include "Symbol.hh" #include "ValidSchema.hh" @@ -34,13 +33,13 @@ class ValidatingGrammarGenerator { protected: template static void doFixup(Production& p, - const std::map >& m); + const std::map >& m); template static void doFixup(Symbol& s, - const std::map >& m); + const std::map >& m); virtual Production doGenerate( - const NodePtr& n, std::map >& m); + const NodePtr& n, std::map >& m); Production generate(const NodePtr& schema); diff --git a/src/avrocpp/test/AvrogencppTests.cc b/src/avrocpp/test/AvrogencppTests.cc index b3dade27..09f70a6a 100644 --- a/src/avrocpp/test/AvrogencppTests.cc +++ b/src/avrocpp/test/AvrogencppTests.cc @@ -119,7 +119,7 @@ void testEncoding() { ValidSchema s; ifstream ifs("jsonschemas/bigrecord"); compileJsonSchema(ifs, s); - boost::shared_ptr os = memoryOutputStream(); + std::shared_ptr os = memoryOutputStream(); EncoderPtr e = validatingEncoder(s, binaryEncoder()); e->init(*os); testgen::RootRecord t1; @@ -128,7 +128,7 @@ void testEncoding() { e->flush(); DecoderPtr d = validatingDecoder(s, binaryDecoder()); - boost::shared_ptr is = memoryInputStream(*os); + std::shared_ptr is = memoryInputStream(*os); d->init(*is); testgen::RootRecord t2; internal_avro::decode(*d, t2); @@ -177,7 +177,7 @@ void testEncoding2() { ifstream ifs(schemaFilename::value); compileJsonSchema(ifs, s); - boost::shared_ptr os = memoryOutputStream(); + std::shared_ptr os = memoryOutputStream(); EncoderPtr e = validatingEncoder(s, binaryEncoder()); e->init(*os); T t1; @@ -186,7 +186,7 @@ void testEncoding2() { e->flush(); DecoderPtr d = validatingDecoder(s, binaryDecoder()); - boost::shared_ptr is = memoryInputStream(*os); + std::shared_ptr is = memoryInputStream(*os); d->init(*is); T t2; internal_avro::decode(*d, t2); diff --git a/src/avrocpp/test/CodecTests.cc b/src/avrocpp/test/CodecTests.cc index 1fa9e77d..862766b2 100644 --- a/src/avrocpp/test/CodecTests.cc +++ b/src/avrocpp/test/CodecTests.cc @@ -43,7 +43,7 @@ namespace internal_avro { /* void dump(const OutputStream& os) { - boost::shared_ptr in = memoryInputStream(os); + std::shared_ptr in = memoryInputStream(os); const char *b; size_t n; std::cout << os.byteCount() << std::endl; @@ -221,11 +221,11 @@ static vector randomValues(const char* calls) { return result; } -static boost::shared_ptr generate(Encoder& e, const char* calls, +static std::shared_ptr generate(Encoder& e, const char* calls, const vector& values) { Scanner sc(calls); vector::const_iterator it = values.begin(); - boost::shared_ptr ob = memoryOutputStream(); + std::shared_ptr ob = memoryOutputStream(); e.init(*ob); while (!sc.isDone()) { @@ -501,7 +501,7 @@ ValidSchema makeValidSchema(const char* schema) { } void testEncoder(const EncoderPtr& e, const char* writerCalls, - vector& v, boost::shared_ptr& p) { + vector& v, std::shared_ptr& p) { v = randomValues(writerCalls); p = generate(*e, writerCalls, v); } @@ -577,7 +577,7 @@ void testCodec(const TestData& td) { for (unsigned int i = 0; i < count; ++i) { vector v; - boost::shared_ptr p; + std::shared_ptr p; testEncoder(CodecFactory::newEncoder(vs), td.calls, v, p); // dump(*p); @@ -592,7 +592,7 @@ void testCodec(const TestData& td) { BOOST_TEST_CHECKPOINT("Test: " << testNo << ' ' << " schema: " << td.schema << " calls: " << td.calls << " skip-level: " << skipLevel); - boost::shared_ptr in = memoryInputStream(*p); + std::shared_ptr in = memoryInputStream(*p); testDecoder(CodecFactory::newDecoder(vs), v, *in, td.calls, skipLevel); } } @@ -613,7 +613,7 @@ void testCodecResolving(const TestData3& td) { for (unsigned int i = 0; i < count; ++i) { vector v; - boost::shared_ptr p; + std::shared_ptr p; testEncoder(CodecFactory::newEncoder(vs), td.writerCalls, v, p); // dump(*p); @@ -626,7 +626,7 @@ void testCodecResolving(const TestData3& td) { << " reader schema: " << td.readerSchema << " reader calls: " << td.readerCalls << " skip-level: " << skipLevel); - boost::shared_ptr in = memoryInputStream(*p); + std::shared_ptr in = memoryInputStream(*p); testDecoder(CodecFactory::newDecoder(vs, rvs), v, *in, td.readerCalls, skipLevel); } @@ -655,7 +655,7 @@ void testCodecResolving2(const TestData4& td) { ValidSchema vs = makeValidSchema(td.writerSchema); vector wd = mkValues(td.writerValues); - boost::shared_ptr p = + std::shared_ptr p = generate(*CodecFactory::newEncoder(vs), td.writerCalls, wd); // dump(*p); @@ -669,7 +669,7 @@ void testCodecResolving2(const TestData4& td) { << " reader schema: " << td.readerSchema << " reader calls: " << td.readerCalls << " skip-level: " << skipLevel); - boost::shared_ptr in = memoryInputStream(*p); + std::shared_ptr in = memoryInputStream(*p); testDecoder(CodecFactory::newDecoder(vs, rvs), rd, *in, td.readerCalls, skipLevel); } @@ -686,9 +686,9 @@ void testReaderFail(const TestData2& td) { ValidSchema vs = makeValidSchema(td.schema); vector v; - boost::shared_ptr p; + std::shared_ptr p; testEncoder(CodecFactory::newEncoder(vs), td.correctCalls, v, p); - boost::shared_ptr in = memoryInputStream(*p); + std::shared_ptr in = memoryInputStream(*p); BOOST_CHECK_THROW(testDecoder(CodecFactory::newDecoder(vs), v, *in, td.incorrectCalls, td.depth), Exception); @@ -703,7 +703,7 @@ void testWriterFail(const TestData2& td) { ValidSchema vs = makeValidSchema(td.schema); vector v; - boost::shared_ptr p; + std::shared_ptr p; BOOST_CHECK_THROW( testEncoder(CodecFactory::newEncoder(vs), td.incorrectCalls, v, p), Exception); @@ -718,17 +718,17 @@ void testGeneric(const TestData& td) { for (unsigned int i = 0; i < count; ++i) { vector v; - boost::shared_ptr p; + std::shared_ptr p; testEncoder(CodecFactory::newEncoder(vs), td.calls, v, p); // dump(*p); DecoderPtr d1 = CodecFactory::newDecoder(vs); - boost::shared_ptr in1 = memoryInputStream(*p); + std::shared_ptr in1 = memoryInputStream(*p); d1->init(*in1); GenericDatum datum(vs); internal_avro::decode(*d1, datum); EncoderPtr e2 = CodecFactory::newEncoder(vs); - boost::shared_ptr ob = memoryOutputStream(); + std::shared_ptr ob = memoryOutputStream(); e2->init(*ob); internal_avro::encode(*e2, datum); @@ -736,7 +736,7 @@ void testGeneric(const TestData& td) { BOOST_TEST_CHECKPOINT("Test: " << testNo << ' ' << " schema: " << td.schema << " calls: " << td.calls); - boost::shared_ptr in2 = memoryInputStream(*ob); + std::shared_ptr in2 = memoryInputStream(*ob); testDecoder(CodecFactory::newDecoder(vs), v, *in2, td.calls, td.depth); } } @@ -757,11 +757,11 @@ void testGenericResolving(const TestData3& td) { for (unsigned int i = 0; i < count; ++i) { vector v; - boost::shared_ptr p; + std::shared_ptr p; testEncoder(CodecFactory::newEncoder(wvs), td.writerCalls, v, p); // dump(*p); DecoderPtr d1 = CodecFactory::newDecoder(wvs); - boost::shared_ptr in1 = memoryInputStream(*p); + std::shared_ptr in1 = memoryInputStream(*p); d1->init(*in1); GenericReader gr(wvs, rvs, d1); @@ -769,7 +769,7 @@ void testGenericResolving(const TestData3& td) { gr.read(datum); EncoderPtr e2 = CodecFactory::newEncoder(rvs); - boost::shared_ptr ob = memoryOutputStream(); + std::shared_ptr ob = memoryOutputStream(); e2->init(*ob); internal_avro::encode(*e2, datum); e2->flush(); @@ -779,7 +779,7 @@ void testGenericResolving(const TestData3& td) { << " writer-calls: " << td.writerCalls << " reader-schema: " << td.readerSchema << " calls: " << td.readerCalls); - boost::shared_ptr in2 = memoryInputStream(*ob); + std::shared_ptr in2 = memoryInputStream(*ob); testDecoder(CodecFactory::newDecoder(rvs), v, *in2, td.readerCalls, td.depth); } @@ -801,11 +801,11 @@ void testGenericResolving2(const TestData4& td) { const vector wd = mkValues(td.writerValues); - boost::shared_ptr p = + std::shared_ptr p = generate(*CodecFactory::newEncoder(wvs), td.writerCalls, wd); // dump(*p); DecoderPtr d1 = CodecFactory::newDecoder(wvs); - boost::shared_ptr in1 = memoryInputStream(*p); + std::shared_ptr in1 = memoryInputStream(*p); d1->init(*in1); GenericReader gr(wvs, rvs, d1); @@ -813,7 +813,7 @@ void testGenericResolving2(const TestData4& td) { gr.read(datum); EncoderPtr e2 = CodecFactory::newEncoder(rvs); - boost::shared_ptr ob = memoryOutputStream(); + std::shared_ptr ob = memoryOutputStream(); e2->init(*ob); internal_avro::encode(*e2, datum); e2->flush(); @@ -1384,7 +1384,7 @@ void add_tests(boost::unit_test::test_suite& ts) { static void testStreamLifetimes() { EncoderPtr e = binaryEncoder(); { - boost::shared_ptr s1 = memoryOutputStream(); + std::shared_ptr s1 = memoryOutputStream(); e->init(*s1); e->encodeInt(100); e->encodeDouble(4.73); @@ -1392,7 +1392,7 @@ static void testStreamLifetimes() { } { - boost::shared_ptr s2 = memoryOutputStream(); + std::shared_ptr s2 = memoryOutputStream(); e->init(*s2); e->encodeDouble(3.14); e->flush(); @@ -1400,7 +1400,7 @@ static void testStreamLifetimes() { } static void testLimits(const EncoderPtr& e, const DecoderPtr& d) { - boost::shared_ptr s1 = memoryOutputStream(); + std::shared_ptr s1 = memoryOutputStream(); { e->init(*s1); e->encodeDouble(std::numeric_limits::infinity()); @@ -1413,7 +1413,7 @@ static void testLimits(const EncoderPtr& e, const DecoderPtr& d) { } { - boost::shared_ptr s2 = memoryInputStream(*s1); + std::shared_ptr s2 = memoryInputStream(*s1); d->init(*s2); BOOST_CHECK_EQUAL(d->decodeDouble(), std::numeric_limits::infinity()); diff --git a/src/avrocpp/test/DataFileTests.cc b/src/avrocpp/test/DataFileTests.cc index 1d7c4f72..767abc3e 100644 --- a/src/avrocpp/test/DataFileTests.cc +++ b/src/avrocpp/test/DataFileTests.cc @@ -19,7 +19,6 @@ #include #include #include -#include #include #include "DataFile.hh" @@ -27,7 +26,7 @@ #include "Stream.hh" #include "Compiler.hh" -using boost::shared_ptr; +using std::shared_ptr; using std::string; using std::pair; using std::vector; @@ -36,7 +35,7 @@ using std::istringstream; using std::ostringstream; using boost::array; -using boost::shared_ptr; +using std::shared_ptr; using boost::unit_test::test_suite; using internal_avro::ValidSchema; @@ -323,7 +322,7 @@ class DataFileTest { * Constructs the DataFileReader in two steps. */ void testReadDoubleTwoStep() { - boost::shared_ptr base( + std::shared_ptr base( new internal_avro::DataFileReaderBase(filename)); internal_avro::DataFileReader df(base); BOOST_CHECK_EQUAL(toString(writerSchema), toString(df.readerSchema())); @@ -347,7 +346,7 @@ class DataFileTest { * reader schema. */ void testReadDoubleTwoStepProject() { - boost::shared_ptr base( + std::shared_ptr base( new internal_avro::DataFileReaderBase(filename)); internal_avro::DataFileReader df(base, readerSchema); @@ -375,7 +374,7 @@ class DataFileTest { // first create a large file ValidSchema dschema = internal_avro::compileJsonSchemaFromString(prsch); { - boost::shared_ptr > writer( + std::shared_ptr > writer( new internal_avro::DataFileWriter(filename, dschema)); for (size_t i = 0; i < number_of_objects; ++i) { @@ -392,7 +391,7 @@ class DataFileTest { // check seeking to the start and end { - boost::shared_ptr > reader( + std::shared_ptr > reader( new internal_avro::DataFileReader(filename)); BOOST_REQUIRE_NE(reader->sizeBytes(), -1); // test that seek to the start gets the first element @@ -410,7 +409,7 @@ class DataFileTest { { std::vector dividers; { - boost::shared_ptr > reader( + std::shared_ptr > reader( new internal_avro::DataFileReader(filename)); int size = reader->sizeBytes(); dividers.push_back(reader->blockOffsetBytes()); @@ -424,7 +423,7 @@ class DataFileTest { } std::vector found; for (size_t i = 1; i < dividers.size(); ++i) { - boost::shared_ptr > reader( + std::shared_ptr > reader( new internal_avro::DataFileReader(filename)); reader->seekBlockBytes(dividers[i - 1]); block_offsets.insert(reader->blockOffsetBytes()); @@ -446,7 +445,7 @@ class DataFileTest { { for (std::set::const_iterator it = block_offsets.begin(); it != block_offsets.end(); ++it) { - boost::shared_ptr > reader( + std::shared_ptr > reader( new internal_avro::DataFileReader(filename)); reader->seekBlockBytes(*it); BOOST_CHECK_EQUAL(reader->blockOffsetBytes(), *it); @@ -462,11 +461,11 @@ class DataFileTest { const size_t number_of_objects = 100; // first create a large file ValidSchema dschema = internal_avro::compileJsonSchemaFromString(prsch); - boost::shared_ptr buf = + std::shared_ptr buf = internal_avro::memoryOutputStream(); { - boost::shared_ptr > writer = - boost::make_shared >( + std::shared_ptr > writer = + std::make_shared >( buf, dschema); for (size_t i = 0; i < number_of_objects; ++i) { @@ -482,10 +481,10 @@ class DataFileTest { } { { - boost::shared_ptr inbuf = + std::shared_ptr inbuf = internal_avro::memoryInputStream(*buf); - boost::shared_ptr > reader = - boost::make_shared >( + std::shared_ptr > reader = + std::make_shared >( inbuf); std::vector found; PaddedRecord record; @@ -509,8 +508,8 @@ class DataFileTest { // first create a large file ValidSchema dschema = internal_avro::compileJsonSchemaFromString(prsch); { - boost::shared_ptr > writer = - boost::make_shared >( + std::shared_ptr > writer = + std::make_shared >( filename, dschema, 16 * 1024, internal_avro::DEFLATE_CODEC); for (size_t i = 0; i < number_of_objects; ++i) { @@ -526,8 +525,8 @@ class DataFileTest { } { { - boost::shared_ptr > reader = - boost::make_shared >( + std::shared_ptr > reader = + std::make_shared >( filename, dschema); std::vector found; PaddedRecord record; diff --git a/src/avrocpp/test/SpecificTests.cc b/src/avrocpp/test/SpecificTests.cc index 18d8aac8..56a79611 100644 --- a/src/avrocpp/test/SpecificTests.cc +++ b/src/avrocpp/test/SpecificTests.cc @@ -60,7 +60,7 @@ struct codec_traits { namespace specific { class Test { - boost::shared_ptr os; + std::shared_ptr os; EncoderPtr e; DecoderPtr d; @@ -77,7 +77,7 @@ class Test { template void decode(T& t) { - boost::shared_ptr is = memoryInputStream(*os); + std::shared_ptr is = memoryInputStream(*os); d->init(*is); internal_avro::decode(*d, t); } diff --git a/src/avrocpp/test/StreamTests.cc b/src/avrocpp/test/StreamTests.cc index 76aaf25d..687aa565 100644 --- a/src/avrocpp/test/StreamTests.cc +++ b/src/avrocpp/test/StreamTests.cc @@ -105,17 +105,17 @@ struct Verify2 { template void testEmpty_memoryStream() { - boost::shared_ptr os = memoryOutputStream(); - boost::shared_ptr is = memoryInputStream(*os); + std::shared_ptr os = memoryOutputStream(); + std::shared_ptr is = memoryInputStream(*os); V()(*is); } template void testNonEmpty_memoryStream(const TestData& td) { - boost::shared_ptr os = memoryOutputStream(td.chunkSize); + std::shared_ptr os = memoryOutputStream(td.chunkSize); F()(*os, td.dataSize); - boost::shared_ptr is = memoryInputStream(*os); + std::shared_ptr is = memoryInputStream(*os); V()(*is, td.dataSize); } @@ -126,7 +126,7 @@ void testNonEmpty2(const TestData& td) { } uint8_t v2 = 0; - boost::shared_ptr is = + std::shared_ptr is = memoryInputStream(v.empty() ? &v2 : &v[0], v.size()); Verify1()(*is, td.dataSize); } @@ -142,8 +142,8 @@ struct FileRemover { template void testEmpty_fileStream() { FileRemover fr(filename); - { boost::shared_ptr os = fileOutputStream(filename); } - boost::shared_ptr is = fileInputStream(filename); + { std::shared_ptr os = fileOutputStream(filename); } + std::shared_ptr is = fileInputStream(filename); V()(*is); } @@ -151,12 +151,12 @@ template void testNonEmpty_fileStream(const TestData& td) { FileRemover fr(filename); { - boost::shared_ptr os = + std::shared_ptr os = fileOutputStream(filename, td.chunkSize); F()(*os, td.dataSize); } - boost::shared_ptr is = fileInputStream(filename, td.chunkSize); + std::shared_ptr is = fileInputStream(filename, td.chunkSize); V()(*is, td.dataSize); } diff --git a/src/avrocpp/test/testgentest.cc b/src/avrocpp/test/testgentest.cc index be749a49..d326ea7d 100644 --- a/src/avrocpp/test/testgentest.cc +++ b/src/avrocpp/test/testgentest.cc @@ -506,7 +506,7 @@ struct TestSchemaResolving { template void addTestCase(boost::unit_test::test_suite &test) { - boost::shared_ptr newtest(new T); + std::shared_ptr newtest(new T); test.add(BOOST_CLASS_TEST_CASE(&T::test, newtest)); } diff --git a/src/avrocpp/test/unittest.cc b/src/avrocpp/test/unittest.cc index 82956825..74475622 100644 --- a/src/avrocpp/test/unittest.cc +++ b/src/avrocpp/test/unittest.cc @@ -728,7 +728,7 @@ struct TestResolution { template void addTestCase(boost::unit_test::test_suite &test) { - boost::shared_ptr newtest(new T); + std::shared_ptr newtest(new T); test.add(BOOST_CLASS_TEST_CASE(&T::test, newtest)); } diff --git a/src/backend/IO.cpp b/src/backend/IO.cpp index d69a5779..376bf648 100644 --- a/src/backend/IO.cpp +++ b/src/backend/IO.cpp @@ -30,16 +30,16 @@ namespace RMF { namespace backends { namespace { RMF_LARGE_UNORDERED_MAP test_buffers; -struct GetFactories : public std::vector > { +struct GetFactories : public std::vector > { GetFactories() { - std::vector > favro2 = avro2::get_factories(); + std::vector > favro2 = avro2::get_factories(); insert(end(), favro2.begin(), favro2.end()); #if RMF_HAS_DEPRECATED_BACKENDS - std::vector > fhdf5 = + std::vector > fhdf5 = hdf5_backend::get_factories(); insert(end(), fhdf5.begin(), fhdf5.end()); - std::vector > favro = + std::vector > favro = avro_backend::get_factories(); insert(end(), favro.begin(), favro.end()); #endif @@ -47,7 +47,7 @@ struct GetFactories : public std::vector > { } factories; } -boost::shared_ptr create_file(const std::string &name) { +std::shared_ptr create_file(const std::string &name) { if (boost::filesystem::exists(name)) { unlink(name.c_str()); } @@ -55,30 +55,30 @@ boost::shared_ptr create_file(const std::string &name) { test_buffers[name] = BufferHandle(); return create_buffer(test_buffers.find(name)->second); } else { - for(boost::shared_ptr f : factories) { + for(std::shared_ptr f : factories) { if (!boost::algorithm::ends_with(name, f->get_file_extension())) continue; - boost::shared_ptr cur = f->create_file(name); + std::shared_ptr cur = f->create_file(name); if (cur) return cur; } } - return boost::shared_ptr(); + return std::shared_ptr(); } -boost::shared_ptr create_buffer(BufferHandle buffer) { - for(boost::shared_ptr f : factories) { - boost::shared_ptr cur = f->create_buffer(buffer); +std::shared_ptr create_buffer(BufferHandle buffer) { + for(std::shared_ptr f : factories) { + std::shared_ptr cur = f->create_buffer(buffer); if (cur) return cur; } - return boost::shared_ptr(); + return std::shared_ptr(); } -boost::shared_ptr read_file(const std::string &name) { +std::shared_ptr read_file(const std::string &name) { if (boost::algorithm::ends_with(name, "_rmf_test_buffer")) { return read_buffer(test_buffers.find(name)->second); } else { - for(boost::shared_ptr f : factories) { + for(std::shared_ptr f : factories) { // if (!boost::algorithm::ends_with(name, f->get_file_extension())) // continue; try { - boost::shared_ptr cur = f->read_file(name); + std::shared_ptr cur = f->read_file(name); if (cur) return cur; } catch (const std::exception &e) { @@ -86,14 +86,14 @@ boost::shared_ptr read_file(const std::string &name) { } } } - return boost::shared_ptr(); + return std::shared_ptr(); } -boost::shared_ptr read_buffer(BufferConstHandle buffer) { - for(boost::shared_ptr f : factories) { - boost::shared_ptr cur = f->read_buffer(buffer); +std::shared_ptr read_buffer(BufferConstHandle buffer) { + for(std::shared_ptr f : factories) { + std::shared_ptr cur = f->read_buffer(buffer); if (cur) return cur; } - return boost::shared_ptr(); + return std::shared_ptr(); } } } diff --git a/src/backend/IO.h b/src/backend/IO.h index 5ffbf287..693f6c9b 100644 --- a/src/backend/IO.h +++ b/src/backend/IO.h @@ -9,7 +9,7 @@ #ifndef RMF_INTERNAL_IO_H #define RMF_INTERNAL_IO_H -#include +#include #include #include "RMF/BufferConstHandle.h" @@ -59,10 +59,10 @@ struct IO { virtual ~IO() {} }; -RMFEXPORT boost::shared_ptr create_file(const std::string &name); -RMFEXPORT boost::shared_ptr create_buffer(BufferHandle buffer); -RMFEXPORT boost::shared_ptr read_file(const std::string &name); -RMFEXPORT boost::shared_ptr read_buffer(BufferConstHandle buffer); +RMFEXPORT std::shared_ptr create_file(const std::string &name); +RMFEXPORT std::shared_ptr create_buffer(BufferHandle buffer); +RMFEXPORT std::shared_ptr read_file(const std::string &name); +RMFEXPORT std::shared_ptr read_buffer(BufferConstHandle buffer); } // namespace internal } /* namespace RMF */ diff --git a/src/backend/IOFactory.h b/src/backend/IOFactory.h index 12af1506..a2baf30f 100644 --- a/src/backend/IOFactory.h +++ b/src/backend/IOFactory.h @@ -14,7 +14,7 @@ #include "RMF/BufferHandle.h" #include "RMF/BufferConstHandle.h" #include "RMF/infrastructure_macros.h" -#include +#include RMF_ENABLE_WARNINGS @@ -25,17 +25,17 @@ namespace backends { class IOFactory { public: virtual std::string get_file_extension() const = 0; - virtual boost::shared_ptr read_buffer(BufferConstHandle) const { - return boost::shared_ptr(); + virtual std::shared_ptr read_buffer(BufferConstHandle) const { + return std::shared_ptr(); } - virtual boost::shared_ptr read_file(const std::string &) const { - return boost::shared_ptr(); + virtual std::shared_ptr read_file(const std::string &) const { + return std::shared_ptr(); } - virtual boost::shared_ptr create_buffer(BufferHandle) const { - return boost::shared_ptr(); + virtual std::shared_ptr create_buffer(BufferHandle) const { + return std::shared_ptr(); } - virtual boost::shared_ptr create_file(const std::string &) const { - return boost::shared_ptr(); + virtual std::shared_ptr create_file(const std::string &) const { + return std::shared_ptr(); } virtual ~IOFactory() {} }; diff --git a/src/backend/avro/factory.cpp b/src/backend/avro/factory.cpp index 998bc8e0..421daa27 100644 --- a/src/backend/avro/factory.cpp +++ b/src/backend/avro/factory.cpp @@ -6,8 +6,7 @@ * */ -#include -#include +#include #include #include "RMF/BufferConstHandle.h" @@ -39,13 +38,13 @@ class Avro2IOFileFactory : public backends::IOFactory { else return ".rmf"; } - virtual boost::shared_ptr read_file(const std::string &name) + virtual std::shared_ptr read_file(const std::string &name) const override { - return boost::make_shared > >(name); + return std::make_shared > >(name); } - virtual boost::shared_ptr create_file(const std::string &name) + virtual std::shared_ptr create_file(const std::string &name) const override { - return boost::make_shared > >(name); + return std::make_shared > >(name); } }; @@ -54,29 +53,29 @@ class Avro2IOBufferFactory : public backends::IOFactory { virtual std::string get_file_extension() const override { return ".none"; } - virtual boost::shared_ptr read_buffer(BufferConstHandle buffer) + virtual std::shared_ptr read_buffer(BufferConstHandle buffer) const override { try { - return boost::make_shared > >( + return std::make_shared > >( buffer); } catch (const std::exception &e) { RMF_INFO("Avro2 reader can't read buffer: " << e.what()); - return boost::shared_ptr(); + return std::shared_ptr(); } } - virtual boost::shared_ptr create_buffer(BufferHandle buffer) + virtual std::shared_ptr create_buffer(BufferHandle buffer) const override { - return boost::make_shared >(buffer); + return std::make_shared >(buffer); } }; -std::vector > get_factories() { - std::vector > ret; - ret.push_back(boost::make_shared >()); - ret.push_back(boost::make_shared >()); - ret.push_back(boost::make_shared >()); - ret.push_back(boost::make_shared()); +std::vector > get_factories() { + std::vector > ret; + ret.push_back(std::make_shared >()); + ret.push_back(std::make_shared >()); + ret.push_back(std::make_shared >()); + ret.push_back(std::make_shared()); return ret; } diff --git a/src/backend/avro/factory.h b/src/backend/avro/factory.h index b42de2ea..4e48188a 100644 --- a/src/backend/avro/factory.h +++ b/src/backend/avro/factory.h @@ -21,7 +21,7 @@ RMF_ENABLE_WARNINGS namespace RMF { namespace avro2 { -RMFEXPORT std::vector > get_factories(); +RMFEXPORT std::vector > get_factories(); } } diff --git a/src/backend/avro/io.h b/src/backend/avro/io.h index cc353072..5f2ca374 100644 --- a/src/backend/avro/io.h +++ b/src/backend/avro/io.h @@ -19,8 +19,7 @@ #include "RMF/internal/SharedData.h" #include "RMF/internal/shared_data_ranges.h" #include -#include -#include +#include RMF_ENABLE_WARNINGS diff --git a/src/backend/avro/traits.cpp b/src/backend/avro/traits.cpp index 3b2a7e44..86d6755b 100644 --- a/src/backend/avro/traits.cpp +++ b/src/backend/avro/traits.cpp @@ -455,14 +455,14 @@ struct codec_traits { namespace RMF { namespace avro2 { -void flush_buffer(boost::shared_ptr writer, - boost::shared_ptr stream, +void flush_buffer(std::shared_ptr writer, + std::shared_ptr stream, BufferHandle buffer) { RMF_INFO("Flushing to buffer"); // avoid rewriting later writer->flush(); buffer.access_buffer().clear(); - boost::shared_ptr input_stream = + std::shared_ptr input_stream = internal_avro::memoryInputStream(*stream); const uint8_t* data; size_t len; @@ -473,23 +473,23 @@ void flush_buffer(boost::shared_ptr writer, } BufferConstHandle try_convert(BufferConstHandle buffer, std::string message) { - boost::shared_ptr stream = + std::shared_ptr stream = internal_avro::memoryInputStream(buffer.get_uint8_t().first, buffer.get_uint8_t().second); - boost::shared_ptr > reader; + std::shared_ptr > reader; try { - reader = boost::make_shared >( + reader = std::make_shared >( stream, valid_backwards_schema); } catch (const std::exception &e) { RMF_THROW(Message(message + " and " + e.what()), IOException); } - boost::shared_ptr out_stream = + std::shared_ptr out_stream = internal_avro::memoryOutputStream(); - boost::shared_ptr writer = - boost::make_shared( + std::shared_ptr writer = + std::make_shared( out_stream, internal_avro::compileJsonSchemaFromString( RMF::data_avro::frame_json), 16 * 1024, internal_avro::DEFLATE_CODEC); diff --git a/src/backend/avro/traits.h b/src/backend/avro/traits.h index 45ee69b3..34bfce3a 100644 --- a/src/backend/avro/traits.h +++ b/src/backend/avro/traits.h @@ -16,8 +16,7 @@ #include "avrocpp/api/Compiler.hh" #include "data_file.h" #include "generated/embed_jsons.h" -#include -#include +#include RMF_ENABLE_WARNINGS @@ -33,7 +32,7 @@ internal_avro::ValidSchema get_schema() { } struct FileWriterTraitsBase { - boost::shared_ptr writer_; + std::shared_ptr writer_; std::string path_; FileWriterTraitsBase(std::string path) : path_(path) {} template @@ -57,7 +56,7 @@ struct FileWriterTraitsBase { template struct ReaderTraits { Base base_file_data_, base_frame_; - boost::shared_ptr > reader_; + std::shared_ptr > reader_; template ReaderTraits(T path) @@ -94,7 +93,7 @@ struct ReaderTraits { } void load_file_data(FileData &fd) { RMF_INFO("Loading file data"); - boost::shared_ptr > reader = + std::shared_ptr > reader = base_file_data_.template get_reader(); avro2::load_file_data(*reader, fd); } @@ -117,20 +116,20 @@ struct FileReaderBase { FileReaderBase(std::string path) : path_(path) { get_reader(); } template - boost::shared_ptr > get_reader() { - return boost::make_shared >(path_.c_str(), + std::shared_ptr > get_reader() { + return std::make_shared >(path_.c_str(), get_schema()); } }; RMFEXPORT void flush_buffer( - boost::shared_ptr writer, - boost::shared_ptr stream, BufferHandle buffer); + std::shared_ptr writer, + std::shared_ptr stream, BufferHandle buffer); struct BufferWriterTraits { - boost::shared_ptr writer_; + std::shared_ptr writer_; BufferHandle buffer_; - boost::shared_ptr stream_; + std::shared_ptr stream_; BufferWriterTraits(BufferHandle buffer) : buffer_(buffer) { stream_ = internal_avro::memoryOutputStream(); writer_.reset(new internal_avro::DataFileWriterBase( @@ -165,11 +164,11 @@ struct BufferReaderBase { } } template - boost::shared_ptr > get_reader() { - boost::shared_ptr stream = + std::shared_ptr > get_reader() { + std::shared_ptr stream = internal_avro::memoryInputStream(buffer_.get_uint8_t().first, buffer_.get_uint8_t().second); - return boost::make_shared >(stream, + return std::make_shared >(stream, get_schema()); } }; diff --git a/src/backend/deprecated_avro/MultipleAvroFileReader.h b/src/backend/deprecated_avro/MultipleAvroFileReader.h index b9615538..73b291ac 100644 --- a/src/backend/deprecated_avro/MultipleAvroFileReader.h +++ b/src/backend/deprecated_avro/MultipleAvroFileReader.h @@ -10,7 +10,7 @@ #define RMF_INTERNAL_MULTIPLE_AVRO_FILE_READER_H #include "avrocpp/api/DataFile.hh" -#include +#include #include #include @@ -44,7 +44,7 @@ namespace avro_backend { class MultipleAvroFileReader : public MultipleAvroFileBase { typedef MultipleAvroFileBase P; struct CategoryData { - boost::shared_ptr > + std::shared_ptr > reader; // frame is always something valid RMF_avro_backend::Data data; diff --git a/src/backend/deprecated_avro/MultipleAvroFileWriter.h b/src/backend/deprecated_avro/MultipleAvroFileWriter.h index c0fac20b..4821f607 100644 --- a/src/backend/deprecated_avro/MultipleAvroFileWriter.h +++ b/src/backend/deprecated_avro/MultipleAvroFileWriter.h @@ -12,7 +12,7 @@ #include "avrocpp/api/DataFile.hh" #include "AllJSON.h" #include "FrameJSON.h" -#include +#include #include #include @@ -43,7 +43,7 @@ class MultipleAvroFileWriter : public MultipleAvroFileBase { std::vector static_categories_dirty_; struct CategoryData { - boost::shared_ptr > + std::shared_ptr > writer; RMF_avro_backend::Data data; bool dirty; @@ -53,7 +53,7 @@ class MultipleAvroFileWriter : public MultipleAvroFileBase { RMF_avro_backend::Data null_frame_data_; RMF_avro_backend::Data null_static_frame_data_; - boost::shared_ptr > + std::shared_ptr > frame_writer_; RMF_avro_backend::Frame frame_; diff --git a/src/backend/deprecated_avro/SingleAvroFile.cpp b/src/backend/deprecated_avro/SingleAvroFile.cpp index 8c3a727a..8d1b2579 100644 --- a/src/backend/deprecated_avro/SingleAvroFile.cpp +++ b/src/backend/deprecated_avro/SingleAvroFile.cpp @@ -50,7 +50,7 @@ SingleAvroFile::SingleAvroFile(std::string path, bool create, null_static_frame_data_.frame = -1; } -SingleAvroFile::SingleAvroFile(boost::shared_ptr > buffer, +SingleAvroFile::SingleAvroFile(std::shared_ptr > buffer, bool create, bool) : AvroKeysAndCategories("buffer"), dirty_(false), @@ -104,9 +104,9 @@ void SingleAvroFile::flush() { } else { buffer_->clear(); std::ostringstream oss(std::ios_base::binary); - boost::shared_ptr os = + std::shared_ptr os = internal_avro::ostreamOutputStream(oss); - boost::shared_ptr encoder = + std::shared_ptr encoder = internal_avro::binaryEncoder(); encoder->init(*os); internal_avro::encode(*encoder, all_); @@ -135,10 +135,10 @@ void SingleAvroFile::reload() { RMF_THROW(Message("Can't read input file on reload"), IOException); } } else if (!buffer_ && text_) { - boost::shared_ptr decoder = + std::shared_ptr decoder = internal_avro::jsonDecoder(internal_avro::compileJsonSchemaFromString( data_deprecated_avro::all_json)); - boost::shared_ptr stream = + std::shared_ptr stream = internal_avro::fileInputStream(get_file_path().c_str()); decoder->init(*stream); bool success = false; @@ -153,10 +153,10 @@ void SingleAvroFile::reload() { RMF_THROW(Message("Can't read input file on reload"), IOException); } } else { - boost::shared_ptr is = + std::shared_ptr is = internal_avro::memoryInputStream( reinterpret_cast(&(*buffer_)[0]), buffer_->size()); - boost::shared_ptr decoder = + std::shared_ptr decoder = internal_avro::binaryDecoder(); decoder->init(*is); internal_avro::decode(*decoder, all_); diff --git a/src/backend/deprecated_avro/SingleAvroFile.h b/src/backend/deprecated_avro/SingleAvroFile.h index a8c8a3ef..1b4ba8ee 100644 --- a/src/backend/deprecated_avro/SingleAvroFile.h +++ b/src/backend/deprecated_avro/SingleAvroFile.h @@ -10,7 +10,7 @@ #define RMF_INTERNAL_SINGLE_AVRO_FILE_H #include "AllJSON.h" -#include +#include #include #include #include @@ -33,7 +33,7 @@ class SingleAvroFile : public AvroKeysAndCategories { bool dirty_; bool text_; - boost::shared_ptr > buffer_; + std::shared_ptr > buffer_; RMF_avro_backend::Data null_frame_data_; RMF_avro_backend::Data null_static_frame_data_; @@ -146,7 +146,7 @@ class SingleAvroFile : public AvroKeysAndCategories { void reload(); SingleAvroFile(std::string path, bool create, bool read_only); - SingleAvroFile(boost::shared_ptr > buffer, bool create, + SingleAvroFile(std::shared_ptr > buffer, bool create, bool read_only); SingleAvroFile(); ~SingleAvroFile() { flush(); } diff --git a/src/backend/deprecated_avro/avro_schema_io.cpp b/src/backend/deprecated_avro/avro_schema_io.cpp index d5bea82a..140b3d00 100644 --- a/src/backend/deprecated_avro/avro_schema_io.cpp +++ b/src/backend/deprecated_avro/avro_schema_io.cpp @@ -21,7 +21,7 @@ namespace RMF { namespace avro_backend { void show(const RMF_avro_backend::Data& data, std::ostream& out) { - boost::shared_ptr< ::internal_avro::OutputStream> os = + std::shared_ptr< ::internal_avro::OutputStream> os = internal_avro::ostreamOutputStream(out); ::internal_avro::EncoderPtr encoder = internal_avro::jsonEncoder(internal_avro::compileJsonSchemaFromString( diff --git a/src/backend/deprecated_avro/avro_schema_io.h b/src/backend/deprecated_avro/avro_schema_io.h index 776badd4..19975869 100644 --- a/src/backend/deprecated_avro/avro_schema_io.h +++ b/src/backend/deprecated_avro/avro_schema_io.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -90,9 +90,9 @@ void write_text(const Data& data, internal_avro::ValidSchema schema, std::string path) { std::string temppath = path + ".new"; { - boost::shared_ptr encoder = + std::shared_ptr encoder = internal_avro::jsonEncoder(schema); - boost::shared_ptr stream = + std::shared_ptr stream = internal_avro::fileOutputStream(temppath.c_str()); encoder->init(*stream); try { diff --git a/src/backend/deprecated_avro/create.cpp b/src/backend/deprecated_avro/create.cpp index fea46707..c6fea31d 100644 --- a/src/backend/deprecated_avro/create.cpp +++ b/src/backend/deprecated_avro/create.cpp @@ -9,8 +9,7 @@ #include "factory.h" #include -#include -#include +#include #include #include #include @@ -48,13 +47,13 @@ struct SingleTextAvroFactory : public RMF::backends::IOFactory { virtual std::string get_file_extension() const override { return ".rmf-text"; } - virtual boost::shared_ptr read_file( + virtual std::shared_ptr read_file( const std::string& name) const override { - return boost::make_shared(name, false, true); + return std::make_shared(name, false, true); } - virtual boost::shared_ptr create_file( + virtual std::shared_ptr create_file( const std::string& name) const override { - return boost::make_shared(name, true, false); + return std::make_shared(name, true, false); } virtual ~SingleTextAvroFactory() {} }; @@ -63,18 +62,18 @@ struct SingleAvroFactory : public SingleTextAvroFactory { virtual std::string get_file_extension() const override { return ".rmfa"; } - /*virtual boost::shared_ptr create_buffer( + /*virtual std::shared_ptr create_buffer( BufferHandle buffer) const override { - return boost::make_shared(buffer); + return std::make_shared(buffer); }*/ - virtual boost::shared_ptr read_buffer( + virtual std::shared_ptr read_buffer( BufferConstHandle buffer) const override { try { - return boost::make_shared(buffer); + return std::make_shared(buffer); } catch (const std::exception &e) { RMF_INFO("Can't read buffer with old reader: " << e.what()); - return boost::shared_ptr(); + return std::shared_ptr(); } } virtual ~SingleAvroFactory() {} @@ -84,22 +83,22 @@ struct MultipleAvroFactory : public RMF::backends::IOFactory { virtual std::string get_file_extension() const override { return ".rmf-avro"; } - virtual boost::shared_ptr read_file( + virtual std::shared_ptr read_file( const std::string& name) const override { - return boost::make_shared(name, false, true); + return std::make_shared(name, false, true); } - virtual boost::shared_ptr create_file( + virtual std::shared_ptr create_file( const std::string& name) const override { - return boost::make_shared(name, true, false); + return std::make_shared(name, true, false); } virtual ~MultipleAvroFactory() {} }; } // namespace -std::vector > get_factories() { - std::vector > ret; - ret.push_back(boost::make_shared()); - ret.push_back(boost::make_shared()); - ret.push_back(boost::make_shared()); +std::vector > get_factories() { + std::vector > ret; + ret.push_back(std::make_shared()); + ret.push_back(std::make_shared()); + ret.push_back(std::make_shared()); return ret; } } // namespace avro_backend diff --git a/src/backend/deprecated_avro/factory.h b/src/backend/deprecated_avro/factory.h index 52f7670e..adbefb71 100644 --- a/src/backend/deprecated_avro/factory.h +++ b/src/backend/deprecated_avro/factory.h @@ -9,7 +9,7 @@ RMF_ENABLE_WARNINGS namespace RMF { namespace avro_backend { -RMFEXPORT std::vector > get_factories(); +RMFEXPORT std::vector > get_factories(); } } diff --git a/src/backend/deprecated_hdf5/HDF5SharedData.h b/src/backend/deprecated_hdf5/HDF5SharedData.h index e9ee640a..5d00b5e9 100644 --- a/src/backend/deprecated_hdf5/HDF5SharedData.h +++ b/src/backend/deprecated_hdf5/HDF5SharedData.h @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/src/backend/deprecated_hdf5/create.cpp b/src/backend/deprecated_hdf5/create.cpp index 78da7e9f..d236559c 100644 --- a/src/backend/deprecated_hdf5/create.cpp +++ b/src/backend/deprecated_hdf5/create.cpp @@ -8,8 +8,7 @@ #include "factory.h" -#include -#include +#include #include #include @@ -36,21 +35,21 @@ struct HDF5Factory : public RMF::backends::IOFactory { virtual std::string get_file_extension() const override { return ".rmf-hdf5"; } - virtual boost::shared_ptr read_file( + virtual std::shared_ptr read_file( const std::string& name) const override { - return boost::make_shared(name, false, true); + return std::make_shared(name, false, true); } - virtual boost::shared_ptr create_file( + virtual std::shared_ptr create_file( const std::string& name) const override { - return boost::make_shared(name, true, false); + return std::make_shared(name, true, false); } virtual ~HDF5Factory() {} }; } // namespace -std::vector > get_factories() { - return std::vector >( - 1, boost::make_shared()); +std::vector > get_factories() { + return std::vector >( + 1, std::make_shared()); } } // namespace avro_backend } // namespace RMF diff --git a/src/backend/deprecated_hdf5/factory.h b/src/backend/deprecated_hdf5/factory.h index 61739b19..4a792373 100644 --- a/src/backend/deprecated_hdf5/factory.h +++ b/src/backend/deprecated_hdf5/factory.h @@ -9,7 +9,7 @@ RMF_ENABLE_WARNINGS namespace RMF { namespace hdf5_backend { -RMFEXPORT std::vector > get_factories(); +RMFEXPORT std::vector > get_factories(); } } diff --git a/src/hdf5_wrapper.cpp b/src/hdf5_wrapper.cpp index 0f2958ce..06bdfdfb 100644 --- a/src/hdf5_wrapper.cpp +++ b/src/hdf5_wrapper.cpp @@ -16,9 +16,8 @@ #include #include #include -#include #include -#include +#include #include #include #include @@ -46,24 +45,24 @@ bool show_errors = false; void set_show_errors(bool tf) { show_errors = tf; } -Object::Object(boost::shared_ptr h) : h_(h) {} +Object::Object(std::shared_ptr h) : h_(h) {} File Object::get_file() const { RMF_HDF5_NEW_HANDLE(h, H5Iget_file_id(get_handle()), &H5Fclose); return File(h); } -Group::Group(boost::shared_ptr h) : P(h) {} +Group::Group(std::shared_ptr h) : P(h) {} -ConstGroup::ConstGroup(boost::shared_ptr h) : P(h) {} +ConstGroup::ConstGroup(std::shared_ptr h) : P(h) {} Group::Group(Group parent, std::string name) - : P(boost::make_shared(H5Gopen2(parent.get_handle(), + : P(std::make_shared(H5Gopen2(parent.get_handle(), name.c_str(), H5P_DEFAULT), &H5Gclose, name)) {} ConstGroup::ConstGroup(ConstGroup parent, std::string name) - : P(boost::make_shared(H5Gopen2(parent.get_handle(), + : P(std::make_shared(H5Gopen2(parent.get_handle(), name.c_str(), H5P_DEFAULT), &H5Gclose, name)) {} @@ -110,12 +109,12 @@ bool ConstGroup::get_child_is_group(unsigned int i) const { return get_child_is_group(get_child_name(i)); } ConstGroup ConstGroup::get_child_group(std::string name) const { - return ConstGroup(boost::make_shared + return ConstGroup(std::make_shared ( H5Gopen2(get_handle(), name.c_str(), H5P_DEFAULT), &H5Gclose, "open group")); } Group Group::get_child_group(std::string name) const { - return Group(boost::make_shared + return Group(std::make_shared (H5Gopen2(get_handle(), name.c_str(), H5P_DEFAULT), &H5Gclose, "open group")); } @@ -199,8 +198,8 @@ File open_file_read_only_returning_nonconst(std::string name) { return File(h); } -File::File(boost::shared_ptr h) : Group(h) {} -ConstFile::ConstFile(boost::shared_ptr h) : ConstGroup(h) {} +File::File(std::shared_ptr h) : Group(h) {} +ConstFile::ConstFile(std::shared_ptr h) : ConstGroup(h) {} ConstFile::ConstFile(File h) : ConstGroup(h.get_shared_handle()) {} void File::flush() { RMF_HDF5_CALL(H5Fflush(get_handle(), H5F_SCOPE_LOCAL)); } diff --git a/src/internal/SharedData.cpp b/src/internal/SharedData.cpp index e22c85d4..c527f222 100644 --- a/src/internal/SharedData.cpp +++ b/src/internal/SharedData.cpp @@ -32,7 +32,7 @@ namespace internal { namespace { RMF_LARGE_UNORDERED_SET open_for_writing; } -SharedData::SharedData(boost::shared_ptr io, std::string name, +SharedData::SharedData(std::shared_ptr io, std::string name, bool write, bool created) : path_(name), write_(write), io_(io) { if (!created) { diff --git a/src/internal/shared_data_factories.cpp b/src/internal/shared_data_factories.cpp index 7ca77527..fafc84ac 100644 --- a/src/internal/shared_data_factories.cpp +++ b/src/internal/shared_data_factories.cpp @@ -6,7 +6,7 @@ * */ -#include +#include #include #include "RMF/BufferConstHandle.h" @@ -22,36 +22,36 @@ RMF_ENABLE_WARNINGS namespace RMF { namespace internal { -boost::shared_ptr create_file(const std::string& name) { - boost::shared_ptr io = backends::create_file(name); +std::shared_ptr create_file(const std::string& name) { + std::shared_ptr io = backends::create_file(name); if (!io) { RMF_THROW(Message("Can't create file") << File(name), IOException); } - return boost::make_shared(io, name, true, true); + return std::make_shared(io, name, true, true); } -boost::shared_ptr create_buffer(BufferHandle buffer) { - boost::shared_ptr io = backends::create_buffer(buffer); +std::shared_ptr create_buffer(BufferHandle buffer) { + std::shared_ptr io = backends::create_buffer(buffer); if (!io) { RMF_THROW(Message("Can't create buffer"), IOException); } - return boost::make_shared(io, "buffer", true, true); + return std::make_shared(io, "buffer", true, true); } -boost::shared_ptr read_file(const std::string& name) { - boost::shared_ptr io = backends::read_file(name); +std::shared_ptr read_file(const std::string& name) { + std::shared_ptr io = backends::read_file(name); if (!io) { RMF_THROW(Message("Can't read file") << File(name), IOException); } - boost::shared_ptr ret = - boost::make_shared(io, name, false, false); + std::shared_ptr ret = + std::make_shared(io, name, false, false); return ret; } -boost::shared_ptr read_buffer(BufferConstHandle buffer) { - boost::shared_ptr io = backends::read_buffer(buffer); +std::shared_ptr read_buffer(BufferConstHandle buffer) { + std::shared_ptr io = backends::read_buffer(buffer); if (!io) { RMF_THROW(Message("Can't read buffer"), IOException); } - boost::shared_ptr ret = - boost::make_shared(io, "buffer", false, false); + std::shared_ptr ret = + std::make_shared(io, "buffer", false, false); return ret; } diff --git a/src/signature.cpp b/src/signature.cpp index 6107b727..23a5f444 100644 --- a/src/signature.cpp +++ b/src/signature.cpp @@ -8,7 +8,7 @@ #include "RMF/utility.h" -#include +#include #include #include #include diff --git a/src/utility.cpp b/src/utility.cpp index 95ad996d..cb2122d4 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -8,7 +8,7 @@ #include "RMF/utility.h" -#include +#include #include #include #include diff --git a/test/test_associations.cpp b/test/test_associations.cpp index f6628648..b16ac289 100644 --- a/test/test_associations.cpp +++ b/test/test_associations.cpp @@ -6,7 +6,7 @@ * */ #include -#include +#include #include #include #include @@ -44,11 +44,11 @@ void test(const char* fname) { assert(c0.get_association() == &a0); RMF::NodeHandle c2 = fh.get_root_node().add_child("c2", RMF::GEOMETRY); - boost::shared_ptr si(new int(3)); + std::shared_ptr si(new int(3)); c2.set_association(si); RMF::NodeHandle c2b = fh.get_node_from_association(si); assert(c2 == c2b); - boost::shared_ptr sib = c2.get_association >(); + std::shared_ptr sib = c2.get_association >(); assert(sib == si); RMF::NodeHandle c3 = fh.get_root_node().add_child("c3", RMF::GEOMETRY); diff --git a/test/test_avro2_low_level.cpp b/test/test_avro2_low_level.cpp index 2567dd66..c0e2c5cf 100644 --- a/test/test_avro2_low_level.cpp +++ b/test/test_avro2_low_level.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,7 +63,7 @@ void read_raw(std::string name) { int read = 0; while (reader.read(frame)) { internal_avro::EncoderPtr encoder = internal_avro::jsonEncoder(schema); - boost::shared_ptr os = + std::shared_ptr os = internal_avro::ostreamOutputStream(std::cout); encoder->init(*os); internal_avro::encode(*encoder, frame); diff --git a/test/test_avro2_validate.cpp b/test/test_avro2_validate.cpp index 22147648..029af4ea 100644 --- a/test/test_avro2_validate.cpp +++ b/test/test_avro2_validate.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -54,7 +54,7 @@ void validate_one(Tout fr, Tin) { fr.nodes.back().id = NodeID(1); fr.nodes.back().type = ROOT; fr.nodes.back().parents.push_back(NodeID(1)); - boost::shared_ptr out_stream = + std::shared_ptr out_stream = internal_avro::memoryOutputStream(); { internal_avro::EncoderPtr encoder = internal_avro::binaryEncoder(); @@ -65,7 +65,7 @@ void validate_one(Tout fr, Tin) { internal_avro::encode(*ve, fr); } { - boost::shared_ptr in_stream = + std::shared_ptr in_stream = internal_avro::memoryInputStream(*out_stream); internal_avro::DecoderPtr decoder = internal_avro::binaryDecoder(); decoder->init(*in_stream); @@ -78,7 +78,7 @@ void validate_one(Tout fr, Tin) { } template void validate_raw(T fr) { - boost::shared_ptr out_stream = + std::shared_ptr out_stream = internal_avro::memoryOutputStream(); { internal_avro::EncoderPtr encoder = internal_avro::binaryEncoder(); @@ -89,7 +89,7 @@ void validate_raw(T fr) { internal_avro::encode(*ve, fr); } { - boost::shared_ptr in_stream = + std::shared_ptr in_stream = internal_avro::memoryInputStream(*out_stream); internal_avro::DecoderPtr decoder = internal_avro::binaryDecoder(); decoder->init(*in_stream); diff --git a/test/test_json_encode_decode.cpp b/test/test_json_encode_decode.cpp index 97df5cb0..cdae7804 100644 --- a/test/test_json_encode_decode.cpp +++ b/test/test_json_encode_decode.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -18,10 +18,10 @@ ::internal_avro::ValidSchema get_valid_schema() { return ::internal_avro::compileJsonSchemaFromString(schema); } std::string encode(std::vector data) { - boost::shared_ptr encoder = + std::shared_ptr encoder = internal_avro::jsonEncoder(get_valid_schema()); std::ostringstream oss; - boost::shared_ptr stream = + std::shared_ptr stream = internal_avro::ostreamOutputStream(oss); encoder->init(*stream); internal_avro::encode(*encoder, data); @@ -30,10 +30,10 @@ std::string encode(std::vector data) { return oss.str(); } std::vector decode(std::string buffer) { - boost::shared_ptr decoder = + std::shared_ptr decoder = internal_avro::jsonDecoder(get_valid_schema()); std::istringstream iss(buffer); - boost::shared_ptr stream = + std::shared_ptr stream = internal_avro::istreamInputStream(iss); decoder->init(*stream); std::vector data; From 222f17f0a66f7992f69fcdb85a9fc853c6d00dc3 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Sat, 4 Feb 2023 22:10:47 -0800 Subject: [PATCH 13/29] Add workaround for older clang --- include/RMF/HDF5/handle.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/RMF/HDF5/handle.h b/include/RMF/HDF5/handle.h index 6b99342e..79afde59 100644 --- a/include/RMF/HDF5/handle.h +++ b/include/RMF/HDF5/handle.h @@ -70,7 +70,13 @@ class RMFEXPORT Handle : public boost::noncopyable { } h_ = -1; } +// Older clang does not like exception specification in combination +// with std::shared_ptr +#if defined(__clang__) && __clang_major__ <= 7 + ~Handle() { +#else ~Handle() RMF_CANEXCEPT { +#endif if (h_ != -1) { RMF_HDF5_CALL(f_(h_)); } From f25e13b96e1d7a79653cdb0923cfae47e09a0348 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Sun, 5 Feb 2023 11:23:33 -0800 Subject: [PATCH 14/29] Fix exception name for Python 2 IOError is a separate exception from OSError in Python 2, so update our tests to match. --- test/test_file_handle.py | 34 +++++++++++++++++----------------- test/test_file_level.py | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/test/test_file_handle.py b/test/test_file_handle.py index f6e207e5..d25feb37 100644 --- a/test/test_file_handle.py +++ b/test/test_file_handle.py @@ -15,26 +15,26 @@ def test_closed_file_methods(self): """Test methods on closed files""" fh = RMF.FileConstHandle() self.assertTrue(fh.get_is_closed()) - self.assertRaises(OSError, fh.set_current_frame, RMF.FrameID(0)) - self.assertRaises(OSError, fh.get_path) - self.assertRaises(OSError, fh.get_current_frame) - self.assertRaises(OSError, fh.get_type, RMF.FrameID(0)) - self.assertRaises(OSError, fh.get_name, RMF.FrameID(0)) - self.assertRaises(OSError, fh.get_children, RMF.FrameID(0)) - self.assertRaises(OSError, fh.get_parents, RMF.FrameID(0)) - self.assertRaises(OSError, fh.get_number_of_frames) - self.assertRaises(OSError, fh.get_number_of_nodes) - self.assertRaises(OSError, fh.get_file_type) - self.assertRaises(OSError, fh.get_root_node) + self.assertRaises(IOError, fh.set_current_frame, RMF.FrameID(0)) + self.assertRaises(IOError, fh.get_path) + self.assertRaises(IOError, fh.get_current_frame) + self.assertRaises(IOError, fh.get_type, RMF.FrameID(0)) + self.assertRaises(IOError, fh.get_name, RMF.FrameID(0)) + self.assertRaises(IOError, fh.get_children, RMF.FrameID(0)) + self.assertRaises(IOError, fh.get_parents, RMF.FrameID(0)) + self.assertRaises(IOError, fh.get_number_of_frames) + self.assertRaises(IOError, fh.get_number_of_nodes) + self.assertRaises(IOError, fh.get_file_type) + self.assertRaises(IOError, fh.get_root_node) fh = RMF.FileHandle() self.assertTrue(fh.get_is_closed()) - self.assertRaises(OSError, fh.get_root_node) - self.assertRaises(OSError, fh.add_frame, "f0") - self.assertRaises(OSError, fh.add_frame, "f1", RMF.FrameID(0)) - self.assertRaises(OSError, fh.set_description, "foo") - self.assertRaises(OSError, fh.set_producer, "foo") - self.assertRaises(OSError, fh.flush) + self.assertRaises(IOError, fh.get_root_node) + self.assertRaises(IOError, fh.add_frame, "f0") + self.assertRaises(IOError, fh.add_frame, "f1", RMF.FrameID(0)) + self.assertRaises(IOError, fh.set_description, "foo") + self.assertRaises(IOError, fh.set_producer, "foo") + self.assertRaises(IOError, fh.flush) if __name__ == '__main__': diff --git a/test/test_file_level.py b/test/test_file_level.py index 814ca7f6..4ad82128 100644 --- a/test/test_file_level.py +++ b/test/test_file_level.py @@ -120,7 +120,7 @@ def test_close(self): self.assertEqual(f.get_number_of_frames(), 1) f.close() self.assertTrue(f.get_is_closed()) - self.assertRaises(OSError, f.get_number_of_frames) + self.assertRaises(IOError, f.get_number_of_frames) f2 = RMF.open_rmf_file_read_only(path) self.assertEqual(f2.get_number_of_frames(), 1) @@ -134,7 +134,7 @@ def test_context_manager(self): f.add_frame("hi", RMF.FRAME) self.assertEqual(f.get_number_of_frames(), 1) self.assertTrue(f.get_is_closed()) - self.assertRaises(OSError, f.get_number_of_frames) + self.assertRaises(IOError, f.get_number_of_frames) with RMF.open_rmf_file_read_only(path) as f2: self.assertEqual(f2.get_number_of_frames(), 1) self.assertTrue(f2.get_is_closed()) From a3645031173295722affdb3b4f9d0a7d94d240b4 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Mon, 6 Feb 2023 14:57:00 -0800 Subject: [PATCH 15/29] Fix typos --- src/backend/avro/Frame.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/avro/Frame.json b/src/backend/avro/Frame.json index 3bc96d56..faa45762 100644 --- a/src/backend/avro/Frame.json +++ b/src/backend/avro/Frame.json @@ -64,7 +64,7 @@ "type": "record", "name": "KeyInfo", "fields":[ - { "name": "id", "type": "int"} + { "name": "id", "type": "int"}, { "name": "name", "type": "string"}, { "name": "category", "type": "int"}, { "name": "type", "type": { @@ -214,7 +214,7 @@ }} } ]}} - } + }, { "name": "vector4s_data", "type": { "type": "array", "items": { "type": "record", "name": "Vector4sNodeData", "fields": [ {"name": "key", "type": "int"}, From 52233aa8d18a9e3a7bf4d8a042a94f4d50b9bdd3 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Mon, 6 Feb 2023 15:20:16 -0800 Subject: [PATCH 16/29] Also benchmark HDF5 backend, if available --- benchmark/benchmark_rmf.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/benchmark/benchmark_rmf.cpp b/benchmark/benchmark_rmf.cpp index 709acc51..03a1f1e1 100644 --- a/benchmark/benchmark_rmf.cpp +++ b/benchmark/benchmark_rmf.cpp @@ -268,6 +268,21 @@ int main(int, char**) { } benchmark_size(name, "rmfz"); } +#if RMF_HAS_DEPRECATED_BACKENDS + { + const std::string name = name_base + ".rmf-hdf5"; + { + RMF::FileHandle fh = RMF::create_rmf_file(name); + benchmark_create(fh, "hdf5"); + } + { + RMF::FileConstHandle fh = benchmark_open(name, "hdf5"); + benchmark_traverse(fh, "hdf5"); + benchmark_load(fh, "hdf5"); + } + benchmark_size(name, "hdf5"); + } +#endif { RMF::BufferHandle buffer; { From 3fe2756dfb55e9db15070ac7f78c0a2401d1ae5a Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Mon, 6 Feb 2023 15:20:47 -0800 Subject: [PATCH 17/29] Make sure file is closed before opening Multiple opens of the same file can cause a segfault when using HDF5. --- benchmark/benchmark_rmf.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmark/benchmark_rmf.cpp b/benchmark/benchmark_rmf.cpp index 03a1f1e1..554c07fd 100644 --- a/benchmark/benchmark_rmf.cpp +++ b/benchmark/benchmark_rmf.cpp @@ -222,6 +222,7 @@ RMF::FileConstHandle benchmark_open(std::string path, std::string type) { RMF::FileConstHandle ret; double count = 0; while (timer.elapsed() < 1) { + ret.close(); ret = RMF::open_rmf_file_read_only(path); ++count; } From b05676c5aede0769552a86558c04bca70ff918ac Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 8 Feb 2023 10:47:13 -0800 Subject: [PATCH 18/29] Replace boost::timer with std::chrono Use standard library classes to replace the deprecated boost::timer. --- benchmark/benchmark_rmf.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/benchmark/benchmark_rmf.cpp b/benchmark/benchmark_rmf.cpp index 554c07fd..4dd8f909 100644 --- a/benchmark/benchmark_rmf.cpp +++ b/benchmark/benchmark_rmf.cpp @@ -7,9 +7,9 @@ #include #include -#include #include #include +#include #include #include @@ -45,6 +45,21 @@ std::string show_size(unsigned int sz) { return oss.str(); } +class Timer { + std::chrono::steady_clock::time_point start_time_; +public: + Timer() { + start_time_ = std::chrono::steady_clock::now(); + } + + double elapsed() const { + auto end_time = std::chrono::steady_clock::now(); + auto time_span = std::chrono::duration_cast< + std::chrono::duration >(end_time - start_time_); + return time_span.count(); + } +}; + void benchmark_size(std::string path, std::string type) { unsigned int size = 0; if (boost::filesystem::is_directory(path)) { @@ -181,11 +196,11 @@ double load(RMF::FileConstHandle file, const RMF::NodeIDs& nodes) { std::pair benchmark_create(RMF::FileHandle file, std::string type) { RMF::NodeIDs atoms; - boost::timer timer; + Timer timer; boost::tuple cur = create(file, atoms); std::cout << type << ", create, " << timer.elapsed() << ", " << cur.get<0>() << std::endl; - boost::timer frame_timer; + Timer frame_timer; boost::tuple frames = create_frames(file, atoms); std::cout << type << ", create frame, " << frame_timer.elapsed() / 20.0 << ", " << frames.get<0>() << std::endl; @@ -194,7 +209,7 @@ std::pair benchmark_create(RMF::FileHandle file, void benchmark_traverse(RMF::FileConstHandle file, std::string type) { file.set_current_frame(RMF::FrameID(0)); - boost::timer timer; + Timer timer; double count = 0; double t; while (timer.elapsed() < 1) { @@ -211,14 +226,14 @@ void benchmark_load(RMF::FileConstHandle file, std::string type) { for(RMF::NodeID n : file.get_node_ids()) { if (ipcf.get_is(file.get_node(n))) nodes.push_back(n); } - boost::timer timer; + Timer timer; double dist = load(file, nodes); std::cout << type << ", load, " << timer.elapsed() / 20.0 << ", " << dist << std::endl; } RMF::FileConstHandle benchmark_open(std::string path, std::string type) { - boost::timer timer; + Timer timer; RMF::FileConstHandle ret; double count = 0; while (timer.elapsed() < 1) { @@ -291,7 +306,7 @@ int main(int, char**) { benchmark_create(fh, "buffer"); } { - boost::timer timer; + Timer timer; RMF::FileConstHandle fh = RMF::open_rmf_buffer_read_only(buffer); std::cout << "buffer" << ", open, " << timer.elapsed() << ", 0" << std::endl; From 82c5088ad3c206129268a009f6345d665f117d12 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 8 Feb 2023 16:48:23 -0800 Subject: [PATCH 19/29] Replace boost::array with std::array --- include/RMF/Vector.h | 17 +++++---- include/RMF/decorator/bond.h | 2 +- include/RMF/decorator/reference.h | 2 +- include/RMF/decorator/representation.h | 2 +- include/RMF/internal/swig_helpers.h | 6 ++-- include/RMF/types.h | 2 +- include/RMF/utility.h | 4 +-- plugins/vmd/Data.cpp | 38 ++++++++++---------- plugins/vmd/Data.h | 34 +++++++++--------- src/avrocpp/api/DataFile.hh | 4 +-- src/avrocpp/api/Parser.hh | 2 +- src/avrocpp/api/Reader.hh | 2 +- src/avrocpp/api/Serializer.hh | 2 +- src/avrocpp/api/Specific.hh | 8 ++--- src/avrocpp/api/Writer.hh | 6 ++-- src/avrocpp/api/Zigzag.hh | 7 ++-- src/avrocpp/impl/BinaryDecoder.cc | 2 +- src/avrocpp/impl/BinaryEncoder.cc | 4 +-- src/avrocpp/impl/DataFile.cc | 4 +-- src/avrocpp/impl/Zigzag.cc | 4 +-- src/avrocpp/impl/avrogencpp.cc | 2 +- src/avrocpp/test/DataFileTests.cc | 2 +- src/avrocpp/test/SpecificTests.cc | 2 +- src/avrocpp/test/unittest.cc | 2 +- src/backend/BackwardsIO.cpp | 20 +++++------ src/backend/BackwardsIO.h | 34 +++++++++--------- src/backend/SharedDataAdaptor.h | 2 +- src/backend/deprecated_hdf5/HDF5SharedData.h | 4 +-- src/utility.cpp | 10 +++--- swig/RMF.i | 2 +- swig/RMF.range.i | 6 ++-- tools/build/_decorators.py | 4 +-- 32 files changed, 121 insertions(+), 121 deletions(-) diff --git a/include/RMF/Vector.h b/include/RMF/Vector.h index 0d6108ce..059e6891 100644 --- a/include/RMF/Vector.h +++ b/include/RMF/Vector.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include @@ -27,29 +27,28 @@ namespace RMF { #ifndef SWIG /** \brief Represent a point in some dimension. - [boost::array](http://www.boost.org/doc/libs/1_55_0/doc/html/array.html) - provides `operator[]()` and `begin()`/`end()` in C++. + std::array provides `operator[]()` and `begin()`/`end()` in C++. */ template class Vector - : public boost::array + : public std::array { - typedef boost::array P; + typedef std::array P; // work around swig template struct Convert {}; template struct Convert > >::type> { - static void convert(const R& r, boost::array& d) { d = r; } + R, std::array > >::type> { + static void convert(const R& r, std::array& d) { d = r; } }; template struct Convert< R, typename boost::enable_if > > >::type> { - static void convert(const R& r, boost::array& d) { + boost::is_convertible > > >::type> { + static void convert(const R& r, std::array& d) { std::copy(boost::begin(r), boost::end(r), d.begin()); } }; diff --git a/include/RMF/decorator/bond.h b/include/RMF/decorator/bond.h index ab93d6cb..d8b0c191 100644 --- a/include/RMF/decorator/bond.h +++ b/include/RMF/decorator/bond.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include RMF_ENABLE_WARNINGS diff --git a/include/RMF/decorator/reference.h b/include/RMF/decorator/reference.h index 21e6c088..c1d1bacf 100644 --- a/include/RMF/decorator/reference.h +++ b/include/RMF/decorator/reference.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include RMF_ENABLE_WARNINGS diff --git a/include/RMF/decorator/representation.h b/include/RMF/decorator/representation.h index 303c9e3b..fbd4d081 100644 --- a/include/RMF/decorator/representation.h +++ b/include/RMF/decorator/representation.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include RMF_ENABLE_WARNINGS diff --git a/include/RMF/internal/swig_helpers.h b/include/RMF/internal/swig_helpers.h index 68b4ad37..24fed748 100644 --- a/include/RMF/internal/swig_helpers.h +++ b/include/RMF/internal/swig_helpers.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -219,7 +219,7 @@ template struct ConvertSequence< T, ConvertT, typename enable_if, T> >::type> { + std::array, T> >::type> { static const int converter = 5; typedef ConvertSequenceHelper Helper; typedef typename ValueOrObject::type VT; @@ -254,7 +254,7 @@ struct ConvertSequence< template struct ConvertSequence, ConvertT> { static const int converter = 6; - typedef boost::array Intermediate; + typedef std::array Intermediate; typedef ConvertSequenceHelper Helper; typedef typename ValueOrObject::type VT; template diff --git a/include/RMF/types.h b/include/RMF/types.h index 2688bbfe..12c76ed6 100644 --- a/include/RMF/types.h +++ b/include/RMF/types.h @@ -53,7 +53,7 @@ typedef RMF_TYPES Vector3s; /** Many Vector4s */ typedef RMF_TYPES Vector4s; -typedef boost::array IntRange; +typedef std::array IntRange; } /* namespace RMF */ diff --git a/include/RMF/utility.h b/include/RMF/utility.h index deb84469..a9d6ab23 100644 --- a/include/RMF/utility.h +++ b/include/RMF/utility.h @@ -13,7 +13,7 @@ #include "RMF/config.h" #include "RMF/internal/errors.h" #include "Vector.h" -#include +#include RMF_ENABLE_WARNINGS @@ -65,7 +65,7 @@ RMFEXPORT void test_throw_exception(); /** Return a lower bound/upper bound pair that bounds the data stored in the * tree. */ -RMFEXPORT boost::array get_bounding_box(NodeConstHandle root); +RMFEXPORT std::array get_bounding_box(NodeConstHandle root); /** Return the diameter of the system. Unlike bounding box, this one can be called from python. */ diff --git a/plugins/vmd/Data.cpp b/plugins/vmd/Data.cpp index 313002d2..7e9b41c8 100644 --- a/plugins/vmd/Data.cpp +++ b/plugins/vmd/Data.cpp @@ -53,11 +53,11 @@ Data::Data(std::string name, int *num_atoms) bodies_.push_back(Body()); - boost::array default_chain = {{0}}; - boost::array default_resname = {{0}}; - boost::array default_altid = {{0}}; - boost::array default_segment = {{0}}; - boost::array na = + std::array default_chain = {{0}}; + std::array default_resname = {{0}}; + std::array default_altid = {{0}}; + std::array default_segment = {{0}}; + std::array na = fill_bodies(file_.get_root_node(), 0, default_chain, -1, default_resname, default_altid, default_segment, resolution_); fill_index(); @@ -143,13 +143,13 @@ int Data::handle_state(int body, RMF::NodeConstHandle cur) { } } -boost::tuple, boost::array > +boost::tuple, std::array > Data::handle_alternative(RMF::NodeConstHandle cur, int body, - boost::array chain, int resid, - boost::array resname, - boost::array altid, - boost::array segment, double resolution) { - boost::array count = {{0}}; + std::array chain, int resid, + std::array resname, + std::array altid, + std::array segment, double resolution) { + std::array count = {{0}}; if (resolution >= 0) { RMF::NodeConstHandle alt = altf_.get(cur).get_alternative(RMF::PARTICLE, resolution); @@ -160,7 +160,7 @@ Data::handle_alternative(RMF::NodeConstHandle cur, int body, for(RMF::NodeConstHandle c : boost::make_iterator_range(alts.begin() + 1, alts.end())) { altid[0] = 'A' + alt; - boost::array cur = fill_bodies(c, body, chain, resid, resname, + std::array cur = fill_bodies(c, body, chain, resid, resname, altid, segment, resolution); for (unsigned int i = 0; i < 2; ++i) { count[i] += cur[i]; @@ -172,13 +172,13 @@ Data::handle_alternative(RMF::NodeConstHandle cur, int body, } } -boost::array Data::fill_bodies(RMF::NodeConstHandle cur, int body, - boost::array chain, int resid, - boost::array resname, - boost::array altid, - boost::array segment, +std::array Data::fill_bodies(RMF::NodeConstHandle cur, int body, + std::array chain, int resid, + std::array resname, + std::array altid, + std::array segment, double resolution) { - boost::array ret = {{0}}; + std::array ret = {{0}}; // must be firest due to ret if (altf_.get_is(cur)) boost::tie(cur, altid, ret) = handle_alternative( @@ -203,7 +203,7 @@ boost::array Data::fill_bodies(RMF::NodeConstHandle cur, int body, } for(RMF::NodeConstHandle c : cur.get_children()) { - boost::array count = + std::array count = fill_bodies(c, body, chain, resid, resname, altid, segment, resolution); for (unsigned int i = 0; i < 2; ++i) { ret[i] += count[i]; diff --git a/plugins/vmd/Data.h b/plugins/vmd/Data.h index f2751290..02aaedd7 100644 --- a/plugins/vmd/Data.h +++ b/plugins/vmd/Data.h @@ -25,7 +25,7 @@ #include "RMF/infrastructure_macros.h" #include "RMF/types.h" #include "molfile_plugin.h" -#include +#include #include #include #include @@ -54,11 +54,11 @@ class Data { RMF::decorator::StateFactory stf_; struct AtomInfo { // can precompute the actual molfile_atom_t data to simplify things - boost::array chain_id; + std::array chain_id; int residue_index; - boost::array residue_name; - boost::array altid; - boost::array segment; + std::array residue_name; + std::array altid; + std::array segment; RMF::NodeID node_id; }; struct Body { @@ -80,29 +80,29 @@ class Data { RESTRAINTS = 2 }; int show_restraints_; - boost::array bounds_; + std::array bounds_; double max_radius_; bool done_; // find nodes to push to VMD - boost::array fill_bodies(RMF::NodeConstHandle cur, int body, - boost::array chain, int resid, - boost::array resname, - boost::array altid, - boost::array segment, + std::array fill_bodies(RMF::NodeConstHandle cur, int body, + std::array chain, int resid, + std::array resname, + std::array altid, + std::array segment, double resolution); void fill_index(); void fill_graphics(RMF::NodeConstHandle cur, RMF::CoordinateTransformer tr); void fill_bonds(RMF::NodeConstHandle cur); int handle_reference_frame(int body, RMF::NodeConstHandle cur); int handle_state(int body, RMF::NodeConstHandle cur); - boost::tuple, - boost::array > + boost::tuple, + std::array > handle_alternative(RMF::NodeConstHandle cur, int body, - boost::array chain, int resid, - boost::array resname, - boost::array altid, - boost::array segment, double resolution); + std::array chain, int resid, + std::array resname, + std::array altid, + std::array segment, double resolution); void handle_bond(RMF::NodeConstHandle cur); void handle_restraint(RMF::NodeConstHandle cur); double get_resolution(); diff --git a/src/avrocpp/api/DataFile.hh b/src/avrocpp/api/DataFile.hh index a257284c..ff7c7571 100644 --- a/src/avrocpp/api/DataFile.hh +++ b/src/avrocpp/api/DataFile.hh @@ -30,7 +30,7 @@ #include #include -#include "boost/array.hpp" +#include #include "boost/utility.hpp" #include #include @@ -46,7 +46,7 @@ enum Codec { /** * The sync value. */ -typedef boost::array DataFileSync; +typedef std::array DataFileSync; /** * Type-independent portion of DataFileWriter. diff --git a/src/avrocpp/api/Parser.hh b/src/avrocpp/api/Parser.hh index 1100522e..dae3faab 100644 --- a/src/avrocpp/api/Parser.hh +++ b/src/avrocpp/api/Parser.hh @@ -85,7 +85,7 @@ class Parser : private boost::noncopyable { } template - void readFixed(boost::array &val) { + void readFixed(std::array &val) { reader_.readFixed(val); } diff --git a/src/avrocpp/api/Reader.hh b/src/avrocpp/api/Reader.hh index a732cdd8..8cb2c5fd 100644 --- a/src/avrocpp/api/Reader.hh +++ b/src/avrocpp/api/Reader.hh @@ -110,7 +110,7 @@ class ReaderImpl : private boost::noncopyable { } template - void readFixed(boost::array &val) { + void readFixed(std::array &val) { this->readFixed(val.c_array(), N); } diff --git a/src/avrocpp/api/Serializer.hh b/src/avrocpp/api/Serializer.hh index b928ef04..66799b06 100644 --- a/src/avrocpp/api/Serializer.hh +++ b/src/avrocpp/api/Serializer.hh @@ -59,7 +59,7 @@ class Serializer : private boost::noncopyable { } template - void writeFixed(const boost::array &val) { + void writeFixed(const std::array &val) { writer_.writeFixed(val); } diff --git a/src/avrocpp/api/Specific.hh b/src/avrocpp/api/Specific.hh index 7c97e893..c04718e9 100644 --- a/src/avrocpp/api/Specific.hh +++ b/src/avrocpp/api/Specific.hh @@ -24,7 +24,7 @@ #include #include -#include "boost/array.hpp" +#include #include "Config.hh" #include "Encoder.hh" @@ -180,18 +180,18 @@ struct codec_traits > { * codec_traits for Avro fixed. */ template -struct codec_traits > { +struct codec_traits > { /** * Encodes a given value. */ - static void encode(Encoder& e, const boost::array& b) { + static void encode(Encoder& e, const std::array& b) { e.encodeFixed(&b[0], N); } /** * Decodes into a given value. */ - static void decode(Decoder& d, boost::array& s) { + static void decode(Decoder& d, std::array& s) { std::vector v(N); d.decodeFixed(N, v); std::copy(&v[0], &v[0] + N, &s[0]); diff --git a/src/avrocpp/api/Writer.hh b/src/avrocpp/api/Writer.hh index 4963cbfa..224433bf 100644 --- a/src/avrocpp/api/Writer.hh +++ b/src/avrocpp/api/Writer.hh @@ -49,7 +49,7 @@ class WriterImpl : private boost::noncopyable { void writeValue(int32_t val) { validator_.checkTypeExpected(AVRO_INT); - boost::array bytes; + std::array bytes; size_t size = encodeInt32(val, bytes); buffer_.writeTo(reinterpret_cast(bytes.data()), size); } @@ -98,7 +98,7 @@ class WriterImpl : private boost::noncopyable { } template - void writeFixed(const boost::array &val) { + void writeFixed(const std::array &val) { validator_.checkFixedSizeExpected(val.size()); buffer_.writeTo(reinterpret_cast(val.data()), val.size()); } @@ -143,7 +143,7 @@ class WriterImpl : private boost::noncopyable { private: void putLong(int64_t val) { - boost::array bytes; + std::array bytes; size_t size = encodeInt64(val, bytes); buffer_.writeTo(reinterpret_cast(bytes.data()), size); } diff --git a/src/avrocpp/api/Zigzag.hh b/src/avrocpp/api/Zigzag.hh index 646ebe99..593d1407 100644 --- a/src/avrocpp/api/Zigzag.hh +++ b/src/avrocpp/api/Zigzag.hh @@ -20,7 +20,8 @@ #define avro_Encoding_hh__ #include -#include +#include +#include #include "Config.hh" /// \file @@ -34,8 +35,8 @@ AVRO_DECL int64_t decodeZigzag64(uint64_t input); AVRO_DECL uint32_t encodeZigzag32(int32_t input); AVRO_DECL int32_t decodeZigzag32(uint32_t input); -AVRO_DECL size_t encodeInt32(int32_t input, boost::array &output); -AVRO_DECL size_t encodeInt64(int64_t input, boost::array &output); +AVRO_DECL size_t encodeInt32(int32_t input, std::array &output); +AVRO_DECL size_t encodeInt64(int64_t input, std::array &output); } // namespace internal_avro diff --git a/src/avrocpp/impl/BinaryDecoder.cc b/src/avrocpp/impl/BinaryDecoder.cc index f605ca0b..7a00db04 100644 --- a/src/avrocpp/impl/BinaryDecoder.cc +++ b/src/avrocpp/impl/BinaryDecoder.cc @@ -22,7 +22,7 @@ #include "Zigzag.hh" #include "Exception.hh" -#include +#include namespace internal_avro { diff --git a/src/avrocpp/impl/BinaryEncoder.cc b/src/avrocpp/impl/BinaryEncoder.cc index 256c221a..573f589d 100644 --- a/src/avrocpp/impl/BinaryEncoder.cc +++ b/src/avrocpp/impl/BinaryEncoder.cc @@ -18,7 +18,7 @@ #include "Encoder.hh" #include "Zigzag.hh" -#include +#include namespace internal_avro { @@ -113,7 +113,7 @@ void BinaryEncoder::startItem() {} void BinaryEncoder::encodeUnionIndex(size_t e) { doEncodeLong(e); } void BinaryEncoder::doEncodeLong(int64_t l) { - boost::array bytes; + std::array bytes; size_t size = encodeInt64(l, bytes); out_.writeBytes(bytes.data(), size); } diff --git a/src/avrocpp/impl/DataFile.cc b/src/avrocpp/impl/DataFile.cc index 58194beb..4308461d 100644 --- a/src/avrocpp/impl/DataFile.cc +++ b/src/avrocpp/impl/DataFile.cc @@ -35,7 +35,7 @@ using std::vector; using std::copy; using std::string; -using boost::array; +using std::array; const string AVRO_SCHEMA_KEY("avro.schema"); const string AVRO_CODEC_KEY("avro.codec"); @@ -396,7 +396,7 @@ void DataFileReaderBase::seekBlockBytes(int64_t offset) { objectCount_ = 0; // if we have leftover data from a previous iteration - boost::array old_data; + std::array old_data; const uint8_t *p = 0; size_t n = 0; diff --git a/src/avrocpp/impl/Zigzag.cc b/src/avrocpp/impl/Zigzag.cc index fc415c73..98032cbf 100644 --- a/src/avrocpp/impl/Zigzag.cc +++ b/src/avrocpp/impl/Zigzag.cc @@ -38,7 +38,7 @@ int32_t decodeZigzag32(uint32_t input) { ((input >> 1) ^ -(static_cast(input) & 1))); } -size_t encodeInt64(int64_t input, boost::array &output) { +size_t encodeInt64(int64_t input, std::array &output) { // get the zigzag encoding uint64_t val = encodeZigzag64(input); @@ -54,7 +54,7 @@ size_t encodeInt64(int64_t input, boost::array &output) { return bytesOut; } -size_t encodeInt32(int32_t input, boost::array &output) { +size_t encodeInt32(int32_t input, std::array &output) { // get the zigzag encoding uint32_t val = encodeZigzag32(input); diff --git a/src/avrocpp/impl/avrogencpp.cc b/src/avrocpp/impl/avrogencpp.cc index 85b9c1d9..82fbe451 100644 --- a/src/avrocpp/impl/avrogencpp.cc +++ b/src/avrocpp/impl/avrogencpp.cc @@ -168,7 +168,7 @@ string CodeGen::cppTypeOf(const NodePtr& n) { case internal_avro::AVRO_MAP: return "std::mapleafAt(1)) + " >"; case internal_avro::AVRO_FIXED: - return "boost::array(n->fixedSize()) + + return "std::array(n->fixedSize()) + ">"; case internal_avro::AVRO_SYMBOLIC: return cppTypeOf(resolveSymbol(n)); diff --git a/src/avrocpp/test/DataFileTests.cc b/src/avrocpp/test/DataFileTests.cc index 767abc3e..c79346eb 100644 --- a/src/avrocpp/test/DataFileTests.cc +++ b/src/avrocpp/test/DataFileTests.cc @@ -34,7 +34,7 @@ using std::map; using std::istringstream; using std::ostringstream; -using boost::array; +using std::array; using std::shared_ptr; using boost::unit_test::test_suite; diff --git a/src/avrocpp/test/SpecificTests.cc b/src/avrocpp/test/SpecificTests.cc index 56a79611..7c1cc4ad 100644 --- a/src/avrocpp/test/SpecificTests.cc +++ b/src/avrocpp/test/SpecificTests.cc @@ -25,7 +25,7 @@ using std::string; using std::vector; using std::map; -using boost::array; +using std::array; namespace internal_avro { diff --git a/src/avrocpp/test/unittest.cc b/src/avrocpp/test/unittest.cc index 74475622..186ea547 100644 --- a/src/avrocpp/test/unittest.cc +++ b/src/avrocpp/test/unittest.cc @@ -317,7 +317,7 @@ struct TestSchema { template void readFixed(Parser &p) { - boost::array input; + std::array input; p.readFixed(input); BOOST_CHECK_EQUAL(input.size(), 16U); diff --git a/src/backend/BackwardsIO.cpp b/src/backend/BackwardsIO.cpp index 4fbc3fb5..b1a8e2ef 100644 --- a/src/backend/BackwardsIO.cpp +++ b/src/backend/BackwardsIO.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include "BackwardsIO.h" @@ -8,17 +8,17 @@ RMF_ENABLE_WARNINGS namespace RMF { namespace backends { namespace { -boost::array make_array(std::string a, std::string b, +std::array make_array(std::string a, std::string b, std::string c) { - boost::array ret; + std::array ret; ret[0] = a; ret[1] = b; ret[2] = c; return ret; } -boost::array make_array(std::string a, std::string b, +std::array make_array(std::string a, std::string b, std::string c, std::string d) { - boost::array ret; + std::array ret; ret[0] = a; ret[1] = b; ret[2] = c; @@ -26,7 +26,7 @@ boost::array make_array(std::string a, std::string b, return ret; } } -typedef std::pair > P3; +typedef std::pair > P3; const P3 vector_3_names[] = { P3("coordinates", make_array("cartesian x", "cartesian y", "cartesian z")), P3("translation", @@ -40,11 +40,11 @@ const P3 vector_3_names[] = { "torque cartesian z"))}; const int vector_3_names_size = sizeof(vector_3_names) / - sizeof(std::pair >); + sizeof(std::pair >); V3N vector_3_names_map(vector_3_names, vector_3_names + vector_3_names_size); -typedef std::pair > P4; +typedef std::pair > P4; const P4 vector_4_names[] = { P4("orientation", make_array("orientation r", "orientation i", @@ -55,7 +55,7 @@ const P4 vector_4_names[] = { "reference frame orientation k"))}; const int vector_4_names_size = sizeof(vector_4_names) / - sizeof(std::pair >); + sizeof(std::pair >); V4N vector_4_names_map(vector_4_names, vector_4_names + vector_4_names_size); @@ -64,7 +64,7 @@ const P3 vectors_3_names[] = { make_array("cartesian xs", "cartesian ys", "cartesian zs"))}; const int vectors_3_names_size = sizeof(vectors_3_names) / - sizeof(std::pair >); + sizeof(std::pair >); V3N vectors_3_names_map(vectors_3_names, vectors_3_names + vectors_3_names_size); diff --git a/src/backend/BackwardsIO.h b/src/backend/BackwardsIO.h index c6f326b6..426f58e3 100644 --- a/src/backend/BackwardsIO.h +++ b/src/backend/BackwardsIO.h @@ -9,7 +9,7 @@ #ifndef RMF_INTERNAL_BACKWARDS_IO_H #define RMF_INTERNAL_BACKWARDS_IO_H -#include +#include #include #include #include @@ -41,11 +41,11 @@ RMF_ENABLE_WARNINGS namespace RMF { namespace backends { - typedef RMF_LARGE_UNORDERED_MAP > + typedef RMF_LARGE_UNORDERED_MAP > V3N; extern V3N vector_3_names_map; extern V3N vectors_3_names_map; - typedef RMF_LARGE_UNORDERED_MAP > + typedef RMF_LARGE_UNORDERED_MAP > V4N; extern V4N vector_4_names_map; @@ -92,13 +92,13 @@ RMF_ENABLE_WARNINGS namespace RMF { } template - inline boost::array get_vector_subkey_names( + inline std::array get_vector_subkey_names( std::string key_name, RMF_VECTOR) const { typename RMF_LARGE_UNORDERED_MAP< - std::string, boost::array >::const_iterator it = + std::string, std::array >::const_iterator it = get_vector_names_map(RMF_VECTOR()).find(key_name); if (it == get_vector_names_map(RMF_VECTOR()).end()) { - boost::array ret; + std::array ret; for (unsigned int i = 0; i < D; ++i) { std::ostringstream ossk; ossk << "_" << key_name << "_" << i; @@ -111,13 +111,13 @@ RMF_ENABLE_WARNINGS namespace RMF { } template - inline boost::array get_vectors_subkey_names( + inline std::array get_vectors_subkey_names( std::string key_name, RMF_VECTOR) const { typename RMF_LARGE_UNORDERED_MAP< - std::string, boost::array >::const_iterator it = + std::string, std::array >::const_iterator it = get_vectors_names_map(RMF_VECTOR()).find(key_name); if (it == get_vectors_names_map(RMF_VECTOR()).end()) { - boost::array ret; + std::array ret; for (unsigned int i = 0; i < D; ++i) { std::ostringstream ossk; ossk << "_" << key_name << "_" << i; @@ -139,7 +139,7 @@ RMF_ENABLE_WARNINGS namespace RMF { if (key != StringsKey()) { ret = sd_->get_static_value(NodeID(0), key); } - typedef std::pair > KP; + typedef std::pair > KP; for(KP kp : get_vector_names_map(RMF_VECTOR())) { ret.push_back(kp.first); } @@ -158,7 +158,7 @@ RMF_ENABLE_WARNINGS namespace RMF { if (key != StringsKey()) { ret = sd_->get_static_value(NodeID(0), key); } - typedef std::pair > KP; + typedef std::pair > KP; for(KP kp : get_vectors_names_map(RMF_VECTOR())) { ret.push_back(kp.first); } @@ -174,7 +174,7 @@ RMF_ENABLE_WARNINGS namespace RMF { RMF_LARGE_UNORDERED_MAP map; for(std::string key_name : get_vector_names(category_b, RMF_VECTOR())) { - boost::array subkey_names = + std::array subkey_names = get_vector_subkey_names(key_name, RMF_VECTOR()); for (unsigned int i = 0; i < D; ++i) { FloatKey cur_key = @@ -202,13 +202,13 @@ RMF_ENABLE_WARNINGS namespace RMF { typedef ID > > VectorKey; std::vector keys = sda->get_keys(category_a, Traits >()); - typedef boost::array, D> Data; + typedef std::array, D> Data; RMF_LARGE_UNORDERED_MAP map; Strings key_names; for(VectorKey k : keys) { std::string name = sda->get_name(k); key_names.push_back(name); - boost::array subkey_names = + std::array subkey_names = get_vector_subkey_names(name, RMF_VECTOR()); for (unsigned int i = 0; i < D; ++i) { map[k][i] = sdb->get_key(category_b, subkey_names[i], FloatTraits()); @@ -241,7 +241,7 @@ RMF_ENABLE_WARNINGS namespace RMF { RMF_LARGE_UNORDERED_MAP map; for(std::string key_name : get_vectors_names(category_b, RMF_VECTOR<3>())) { - boost::array subkey_names = + std::array subkey_names = get_vectors_subkey_names(key_name, RMF_VECTOR<3>()); for (unsigned int i = 0; i < 3; ++i) { FloatsKey cur_key = @@ -273,13 +273,13 @@ RMF_ENABLE_WARNINGS namespace RMF { Category category_b, H) { typedef Vector3sKey VectorKey; std::vector keys = sda->get_keys(category_a, Vector3sTraits()); - typedef boost::array, 3> Data; + typedef std::array, 3> Data; RMF_LARGE_UNORDERED_MAP map; Strings key_names; for(VectorKey k : keys) { std::string name = sda->get_name(k); key_names.push_back(name); - boost::array subkey_names = + std::array subkey_names = get_vectors_subkey_names(name, RMF_VECTOR<3>()); for (unsigned int i = 0; i < 3; ++i) { map[k][i] = sdb->get_key(category_b, subkey_names[i], FloatsTraits()); diff --git a/src/backend/SharedDataAdaptor.h b/src/backend/SharedDataAdaptor.h index 68460c13..6d498630 100644 --- a/src/backend/SharedDataAdaptor.h +++ b/src/backend/SharedDataAdaptor.h @@ -12,7 +12,7 @@ #include "RMF/config.h" #include "RMF/internal/SharedData.h" #include "RMF/log.h" -#include +#include RMF_ENABLE_WARNINGS diff --git a/src/backend/deprecated_hdf5/HDF5SharedData.h b/src/backend/deprecated_hdf5/HDF5SharedData.h index 5d00b5e9..6bce5006 100644 --- a/src/backend/deprecated_hdf5/HDF5SharedData.h +++ b/src/backend/deprecated_hdf5/HDF5SharedData.h @@ -10,7 +10,7 @@ #define RMF_INTERNAL_HDF_5SHARED_DATA_H #include -#include +#include #include #include #include @@ -183,7 +183,7 @@ class HDF5SharedData : public backends::BackwardsIOBase { // category, type, per_frame typedef HDF5DataSetCacheD DS; typedef boost::ptr_vector > PVDS; - typedef boost::array Pair; + typedef std::array Pair; mutable std::vector cache_; public: diff --git a/src/utility.cpp b/src/utility.cpp index cb2122d4..e8155b69 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -105,7 +105,7 @@ void test_throw_exception() { namespace { void handle_vector(const CoordinateTransformer &tr, const Vector3 &v, float r, - boost::array &bb) { + std::array &bb) { Vector3 trv = tr.get_global_coordinates(v); for (unsigned int i = 0; i < 3; ++i) { bb[0][i] = std::min(trv[i] - r, bb[0][i]); @@ -119,7 +119,7 @@ void get_bounding_box_impl(NodeConstHandle root, CoordinateTransformer tr, decorator::CylinderFactory cf, decorator::GaussianParticleFactory gpf, decorator::ReferenceFrameFactory rff, - boost::array &bb) { + std::array &bb) { if (rff.get_is(root)) { tr = CoordinateTransformer(tr, rff.get(root)); } @@ -150,8 +150,8 @@ void get_bounding_box_impl(NodeConstHandle root, CoordinateTransformer tr, } } -boost::array get_bounding_box(NodeConstHandle root) { - boost::array ret; +std::array get_bounding_box(NodeConstHandle root) { + std::array ret; float v = std::numeric_limits::max(); ret[0] = RMF::Vector3(v, v, v); ret[1] = RMF::Vector3(-v, -v, -v); @@ -165,7 +165,7 @@ boost::array get_bounding_box(NodeConstHandle root) { } float get_diameter(NodeConstHandle root) { - boost::array bb = get_bounding_box(root); + std::array bb = get_bounding_box(root); float max = 0; for (unsigned int i = 0; i < 3; ++i) { max = std::max(bb[1][i] - bb[0][i], max); diff --git a/swig/RMF.i b/swig/RMF.i index 363ac96c..7a9f0f79 100644 --- a/swig/RMF.i +++ b/swig/RMF.i @@ -68,7 +68,7 @@ // hack, I don't understand what swig is doing typedef RMF::Vector<3U> Vector3; typedef RMF::Vector<4U> Vector4; - typedef boost::array IntRange; + typedef std::array IntRange; %} %include "RMF.range.i" diff --git a/swig/RMF.range.i b/swig/RMF.range.i index 762ccb13..03184552 100644 --- a/swig/RMF.range.i +++ b/swig/RMF.range.i @@ -1,4 +1,4 @@ -namespace boost { +namespace std { template struct array { array(); @@ -7,7 +7,7 @@ struct array { }; } -%extend boost::array { +%extend std::array { %pythoncode %{ def __getitem__(self, d): if d >= self.size() or d < 0: @@ -18,4 +18,4 @@ struct array { return self.size() %} } -%template(IntRange) boost::array; +%template(IntRange) std::array; diff --git a/tools/build/_decorators.py b/tools/build/_decorators.py index bc9293ad..ec2890ee 100755 --- a/tools/build/_decorators.py +++ b/tools/build/_decorators.py @@ -211,7 +211,7 @@ def __init__(self, name, function_name=None): class AttributePair(Base): def __init__(self, name, data_type, return_type, begin, end): - Base.__init__(self, name, "boost::array<%sKey, 2>" % + Base.__init__(self, name, "std::array<%sKey, 2>" % data_type, return_type) self.helpers = """ template DATA get_NAME_keys(H fh) const { DATA ret; @@ -556,7 +556,7 @@ def make_header(name, infos, deps): #include #include #include -#include +#include #include """ % {"name": name, "NAME": name.upper()}) for d in deps: From 13c5be63b96163ef4b99340998604cf1a9d90e42 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Thu, 16 Feb 2023 10:54:43 -0800 Subject: [PATCH 20/29] Require MSVS 2015, use 'noexcept' keyword All of our Windows builds now use MSVS 2015, not 2012, so we should have (and can require) full C++11 support, and can use the 'noexcept' keyword. --- ChangeLog.md | 5 +++++ include/RMF/HDF5/handle.h | 2 +- include/RMF/compiler_macros.h | 17 ++--------------- include/RMF/exceptions.h | 12 ++++++------ src/exceptions.cpp | 12 ++++++------ 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5112e7ee..79200b27 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,11 @@ Change Log {#changelog} ========== +# HEAD +- Windows builds now require MS Visual Studio 2015 or later (for full C++11 + support). The following macros for pre-C++11 environments are no longer + needed and are deprecated: `RMF_NOEXCEPT`, `RMF_CANEXCEPT`. + # 1.4.1 - 2022-11-21 # {#changelog_1_4_1} - Build fixes to work with SWIG 4.1. - Various internal build scripts now use 'python3' rather than diff --git a/include/RMF/HDF5/handle.h b/include/RMF/HDF5/handle.h index 79afde59..9a7b5d28 100644 --- a/include/RMF/HDF5/handle.h +++ b/include/RMF/HDF5/handle.h @@ -75,7 +75,7 @@ class RMFEXPORT Handle : public boost::noncopyable { #if defined(__clang__) && __clang_major__ <= 7 ~Handle() { #else - ~Handle() RMF_CANEXCEPT { + ~Handle() noexcept(false) { #endif if (h_ != -1) { RMF_HDF5_CALL(f_(h_)); diff --git a/include/RMF/compiler_macros.h b/include/RMF/compiler_macros.h index ecbcd589..5231c981 100644 --- a/include/RMF/compiler_macros.h +++ b/include/RMF/compiler_macros.h @@ -27,26 +27,13 @@ // Deprecated; just use 'final' keyword instead #define RMF_FINAL final -#if defined(__GNUC__) && __cplusplus >= 201103L -#define RMF_HAS_NOEXCEPT 1 -#elif defined(__clang__) && defined(__has_feature) -#define RMF_HAS_NOEXCEPT __has_feature(cxx_noexcept) -#else -#define RMF_HAS_NOEXCEPT 0 -#endif - -#if RMF_HAS_NOEXCEPT +// Deprecated; just use 'noexcept' keyword instead #define RMF_NOEXCEPT noexcept #define RMF_CANEXCEPT noexcept(false) + #define RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(Name) \ Name(const Name &) = default; \ Name &operator=(const Name &) = default -#else -// probably should be finer here -#define RMF_NOEXCEPT throw() -#define RMF_CANEXCEPT -#define RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(Name) -#endif #if defined(__clang__) || defined(__GNUC__) #define RMF_PRAGMA(x) _Pragma(RMF_STRINGIFY(x)) diff --git a/include/RMF/exceptions.h b/include/RMF/exceptions.h index 85b3c989..088e7fe0 100644 --- a/include/RMF/exceptions.h +++ b/include/RMF/exceptions.h @@ -31,8 +31,8 @@ class RMFEXPORT Exception : public virtual std::exception, public: RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(Exception); Exception(); - const char* what() const RMF_NOEXCEPT override; - virtual ~Exception() RMF_NOEXCEPT; + const char* what() const noexcept override; + virtual ~Exception() noexcept; }; /** Use this instead of the more standard what() to get the @@ -49,7 +49,7 @@ class RMFEXPORT UsageException : public Exception { public: RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(UsageException); UsageException(); - ~UsageException() RMF_NOEXCEPT; + ~UsageException() noexcept; }; /** IOExceptions are thrown when some operation on a disk file fails. @@ -58,7 +58,7 @@ class RMFEXPORT IOException : public Exception { public: RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(IOException); IOException(); - ~IOException() RMF_NOEXCEPT; + ~IOException() noexcept; }; /** Internal exceptions are thrown when the library discovers that some @@ -69,7 +69,7 @@ class RMFEXPORT InternalException : public Exception { public: RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(InternalException); InternalException(); - ~InternalException() RMF_NOEXCEPT; + ~InternalException() noexcept; }; /** IndexExceptions are thrown when you walk off the end of something. @@ -78,7 +78,7 @@ class RMFEXPORT IndexException : public Exception { public: RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(IndexException); IndexException(); - ~IndexException() RMF_NOEXCEPT; + ~IndexException() noexcept; }; } diff --git a/src/exceptions.cpp b/src/exceptions.cpp index 761ced4e..65ebe3c7 100644 --- a/src/exceptions.cpp +++ b/src/exceptions.cpp @@ -19,7 +19,7 @@ RMF_ENABLE_WARNINGS namespace RMF { Exception::Exception() {} -const char* Exception::what() const RMF_NOEXCEPT { +const char* Exception::what() const noexcept { try { if (message_.empty()) { message_ = get_message(*this); @@ -30,7 +30,7 @@ const char* Exception::what() const RMF_NOEXCEPT { return message_.c_str(); } -Exception::~Exception() RMF_NOEXCEPT {} +Exception::~Exception() noexcept {} std::string get_message(const Exception& e) { using namespace RMF::internal::ErrorInfo; try { @@ -95,16 +95,16 @@ std::string get_message(const Exception& e) { } } UsageException::UsageException() : Exception() {} -UsageException::~UsageException() RMF_NOEXCEPT {} +UsageException::~UsageException() noexcept {} IOException::IOException() : Exception() {} -IOException::~IOException() RMF_NOEXCEPT {} +IOException::~IOException() noexcept {} IndexException::IndexException() : Exception() {} -IndexException::~IndexException() RMF_NOEXCEPT {} +IndexException::~IndexException() noexcept {} InternalException::InternalException() : Exception() {} -InternalException::~InternalException() RMF_NOEXCEPT {} +InternalException::~InternalException() noexcept {} } /* namespace RMF */ From 4b9d222827c0918573b77ca80df7a03ca713d972 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 22 Feb 2023 16:10:04 -0800 Subject: [PATCH 21/29] Replace boost with std classes Use enable_if, is_convertible, is_base_of and is_pointer from std rather than boost. --- include/RMF/internal/swig_helpers.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/include/RMF/internal/swig_helpers.h b/include/RMF/internal/swig_helpers.h index 24fed748..385d23f1 100644 --- a/include/RMF/internal/swig_helpers.h +++ b/include/RMF/internal/swig_helpers.h @@ -13,12 +13,7 @@ #include "RMF/infrastructure_macros.h" #include "RMF/exceptions.h" #include -#include -#include -#include -#include -#include -#include +#include #include #include #include @@ -63,12 +58,10 @@ typedef PyPointer PyOwnerPointer; } \ } -using boost::enable_if; -using boost::mpl::and_; -using boost::mpl::not_; -using boost::is_convertible; -using boost::is_base_of; -using boost::is_pointer; +using std::enable_if; +using std::is_convertible; +using std::is_base_of; +using std::is_pointer; // using namespace boost; // using namespace boost::mpl; @@ -219,7 +212,7 @@ template struct ConvertSequence< T, ConvertT, typename enable_if, T> >::type> { + std::array, T>::value >::type> { static const int converter = 5; typedef ConvertSequenceHelper Helper; typedef typename ValueOrObject::type VT; From 48f02ac1d3c474a859c6ecb9ddb1f4f5a420ecb6 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 10 Mar 2023 15:31:29 -0800 Subject: [PATCH 22/29] Use numpy at runtime if it is available --- CMakeLists.txt | 5 +++++ config.h.in | 1 + swig/CMakeLists.txt | 4 ++++ swig/RMF.i | 1 + swig/RMF.numpy.i | 17 +++++++++++++++++ 5 files changed, 28 insertions(+) create mode 100644 swig/RMF.numpy.i diff --git a/CMakeLists.txt b/CMakeLists.txt index 6316af57..4a0c64d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,6 +119,11 @@ else() link_directories(${Log4CXX_LIBRARY_DIR}) endif() +if(${PYTHON_NUMPY_FOUND}) + set(RMF_HAS_NUMPY "1" CACHE BOOL "Whether to include numpy support" FORCE) +else() + set(RMF_HAS_NUMPY "0" CACHE BOOL "Whether to include numpy support" FORCE) +endif() include(GNUInstallDirs) diff --git a/config.h.in b/config.h.in index 4b0b6318..6ce2e0a1 100644 --- a/config.h.in +++ b/config.h.in @@ -36,6 +36,7 @@ #define RMF_VERSION_MICRO @RMF_VERSION_MICRO@ #define RMF_HAS_LOG4CXX @RMF_HAS_LOG4CXX@ +#define RMF_HAS_NUMPY @RMF_HAS_NUMPY@ #define RMF_HAS_DEPRECATED_BACKENDS @RMF_DEPRECATED_BACKENDS@ diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index a735b978..45714107 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -9,6 +9,10 @@ include_directories(${HDF5_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS}) +if(${PYTHON_NUMPY_FOUND}) + include_directories(${PYTHON_NUMPY_INCLUDE_DIR}) +endif() + FILE(GLOB rmf_headers "${PROJECT_SOURCE_DIR}/include/RMF/*.h" "${PROJECT_BINARY_DIR}/include/RMF/*.h" "${PROJECT_BINARY_DIR}/include/RMF/decorator/*.h") FILE(GLOB SWIG_INCLUDES "${PROJECT_SOURCE_DIR}/swig/RMF.*.i") diff --git a/swig/RMF.i b/swig/RMF.i index 7a9f0f79..0357bc7a 100644 --- a/swig/RMF.i +++ b/swig/RMF.i @@ -162,3 +162,4 @@ RMF_SWIG_VECTOR(RMF, TraverseHelper) %include "RMF.python.i" +%include "RMF.numpy.i" diff --git a/swig/RMF.numpy.i b/swig/RMF.numpy.i new file mode 100644 index 00000000..c85dbd2d --- /dev/null +++ b/swig/RMF.numpy.i @@ -0,0 +1,17 @@ +#if RMF_HAS_NUMPY +%begin %{ +static int numpy_import_retval; +%} + +%{ +// Silence warnings about old NumPy API +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include +%} + +%init { + numpy_import_retval = _import_array(); + /* If numpy was not found, continue anyway without numpy support */ + PyErr_Clear(); +} +#endif From 607990203bdb31af68820665cb4870660b19b7f6 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 15 Mar 2023 10:41:00 -0700 Subject: [PATCH 23/29] Fix typo --- include/RMF/NodeConstHandle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/RMF/NodeConstHandle.h b/include/RMF/NodeConstHandle.h index 78be2d9f..584910a0 100644 --- a/include/RMF/NodeConstHandle.h +++ b/include/RMF/NodeConstHandle.h @@ -1,6 +1,6 @@ /** * \file RMF/NodeConstHandle.h - * \brief Declaration of NodeConstHandlke. + * \brief Declaration of NodeConstHandle. * * Copyright 2007-2022 IMP Inventors. All rights reserved. * From 7cc9c4199c2000a4bff6a5e7921536d0308d3079 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 15 Mar 2023 11:12:29 -0700 Subject: [PATCH 24/29] Add function to put coordinates into a NumPy array --- include/RMF/numpy_util.h | 39 +++++++++++++ swig/RMF.exceptions.i | 6 ++ swig/RMF.i | 1 + swig/RMF.numpy.i | 115 +++++++++++++++++++++++++++++++++++++++ test/test_numpy.py | 51 +++++++++++++++++ 5 files changed, 212 insertions(+) create mode 100644 include/RMF/numpy_util.h create mode 100644 test/test_numpy.py diff --git a/include/RMF/numpy_util.h b/include/RMF/numpy_util.h new file mode 100644 index 00000000..ee4633c8 --- /dev/null +++ b/include/RMF/numpy_util.h @@ -0,0 +1,39 @@ +/** + * \file RMF/numpy_util.h + * \brief Utility functions to access data from Python with numpy. + * + * Copyright 2007-2023 IMP Inventors. All rights reserved. + * + */ + +#ifndef RMF_NUMPY_UTIL_H +#define RMF_NUMPY_UTIL_H + +#include "RMF/config.h" + +namespace RMF { + +// We only document the functions here. The implementations are provided +// in swig/RMF.numpy.i + +#ifdef RMF_DOXYGEN + +//! Get global XYZ coordinates for everything under the given node. +/** This will traverse the subset of the RMF file rooted at the given node + in a depth first manner and put the XYZ coordinates for all appropriate + nodes into the provided NumPy array, which must be an N*3 float array + where N is the number of XYZ particles. The coordinates are global, i.e. + they are transformed by any parent ReferenceFrame nodes. + + This function is primarily intended to extract trajectory frames + for visualization packages such as ChimeraX. It is only available to + Python and if RMF is built with NumPy support. + */ +void get_all_global_coordinates( + FileConstHandle &fh, NodeConstHandle &nh, PyObject *coord); + +#endif + +} /* namespace RMF */ + +#endif /* RMF_NUMPY_UTIL_H */ diff --git a/swig/RMF.exceptions.i b/swig/RMF.exceptions.i index 0e039d95..9a479e39 100644 --- a/swig/RMF.exceptions.i +++ b/swig/RMF.exceptions.i @@ -9,6 +9,12 @@ void handle_imp_exception(void) { // for windows where there may be multiple std::exceptions // the order is to avoid warnings about redundancy PyErr_SetString(PyExc_IOError, e.what()); + } catch (const std::domain_error &e) { + PyErr_SetString(PyExc_ValueError, e.what()); + } catch (const std::runtime_error &e) { + PyErr_SetString(PyExc_RuntimeError, e.what()); + } catch (const std::invalid_argument &e) { + PyErr_SetString(PyExc_TypeError, e.what()); } catch (const std::exception &e) { PyErr_SetString(PyExc_IOError, e.what()); } catch (...) { diff --git a/swig/RMF.i b/swig/RMF.i index 0357bc7a..d21cf1ac 100644 --- a/swig/RMF.i +++ b/swig/RMF.i @@ -34,6 +34,7 @@ #include #include +#include #include "RMF/internal/swig_helpers.h" #include "RMF.h" diff --git a/swig/RMF.numpy.i b/swig/RMF.numpy.i index c85dbd2d..09166918 100644 --- a/swig/RMF.numpy.i +++ b/swig/RMF.numpy.i @@ -14,4 +14,119 @@ static int numpy_import_retval; /* If numpy was not found, continue anyway without numpy support */ PyErr_Clear(); } + +%{ +// Return true iff `o` is a numpy array of the given type laid out in +// a contiguous chunk of memory +bool is_native_numpy_array(PyObject *o, int numpy_type) { + if (!o || !PyArray_Check(o)) { return false; }// not a numpy array + + PyArrayObject *a = (PyArrayObject *)o; + int array_type = PyArray_TYPE(a); + if (array_type != NPY_NOTYPE + && !PyArray_EquivTypenums(array_type, numpy_type)) { + return false; // data type does not match + } + + return PyArray_ISCONTIGUOUS(a) && PyArray_ISNOTSWAPPED(a); +} + +// Return true iff `o` is a 2D numpy array of the given type laid out in +// a contiguous chunk of memory +bool is_native_numpy_2d_array(PyObject *o, int numpy_type, npy_intp ncol) { + if (is_native_numpy_array(o, numpy_type)) { + PyArrayObject *a = (PyArrayObject *)o; + return PyArray_NDIM(a) == 2 && PyArray_DIM(a, 1) == ncol; + } else { + return false; + } +} + +// Utility class to visit RMF nodes and extract XYZ coordinates +class _OurVisitor { + RMF::decorator::ReferenceFrameConstFactory refframef_; + RMF::decorator::ParticleConstFactory particlef_; + RMF::decorator::BallConstFactory ballf_; + RMF::decorator::AlternativesConstFactory altf_; + // Dimension of the NumPy array + npy_intp ncoord_; + // Raw data in the N*3 NumPy array + float *data_; + + void add_coordinates(const RMF::Vector3 &v) { + numxyz++; + if (numxyz > ncoord_) { + std::ostringstream oss; + oss << "More XYZ particles were found in the RMF file than " + << "were provided (" << ncoord_ << ") in the numpy array"; + throw std::domain_error(oss.str()); + } + *data_++ = v[0]; + *data_++ = v[1]; + *data_++ = v[2]; + } + +public: + _OurVisitor(RMF::FileConstHandle fh, npy_intp ncoord, float *data) + : refframef_(fh), particlef_(fh), ballf_(fh), altf_(fh), + ncoord_(ncoord), data_(data) {} + + void handle_node(RMF::NodeConstHandle &nh, RMF::CoordinateTransformer tran) { + if (refframef_.get_is(nh)) { + tran = RMF::CoordinateTransformer(tran, refframef_.get(nh)); + } + if (ballf_.get_is(nh)) { + RMF::Vector3 coord = tran.get_global_coordinates( + ballf_.get(nh).get_coordinates()); + add_coordinates(coord); + } else if (particlef_.get_is(nh)) { + RMF::Vector3 coord = tran.get_global_coordinates( + particlef_.get(nh).get_coordinates()); + add_coordinates(coord); + } + for (auto &child : nh.get_children()) { + handle_node(child, tran); + } + if (altf_.get_is(nh)) { + RMF::decorator::AlternativesConst alt = altf_.get(nh); + RMF::NodeConstHandles altp = alt.get_alternatives(RMF::PARTICLE); + // Skip first element (already handled above by get_children()) + for (auto altpi = altp.begin() + 1; altpi < altp.end(); ++altpi) { + handle_node(*altpi, tran); + } + for (auto &childg : alt.get_alternatives(RMF::GAUSSIAN_PARTICLE)) { + handle_node(childg, tran); + } + } + } + + size_t numxyz = 0; +}; + +%} + +%inline %{ +void get_all_global_coordinates( + RMF::FileConstHandle &fh, RMF::NodeConstHandle &nh, PyObject *coord) { + if (numpy_import_retval != 0) { + throw std::runtime_error("NumPy did not initialize"); + } + if (!is_native_numpy_2d_array(coord, NPY_FLOAT, 3)) { + throw std::invalid_argument("NumPy array is not a native N*3 float array"); + } + + PyArrayObject *acoord = (PyArrayObject *)coord; + npy_intp ncoord = PyArray_DIM(acoord, 0); + float *data = (float *)PyArray_DATA(acoord); + + _OurVisitor v(fh, ncoord, data); + v.handle_node(nh, RMF::CoordinateTransformer()); + if (v.numxyz != ncoord) { + std::ostringstream oss; + oss << "Fewer XYZ particles were found in the RMF file (" << v.numxyz + << ") than were provided (" << ncoord << ") in the numpy array"; + throw std::domain_error(oss.str()); + } +} +%} #endif diff --git a/test/test_numpy.py b/test/test_numpy.py new file mode 100644 index 00000000..f9dc837e --- /dev/null +++ b/test/test_numpy.py @@ -0,0 +1,51 @@ +from __future__ import print_function +import RMF +import unittest +if RMF.RMF_HAS_NUMPY: + import numpy + + +def _make_rmf(): + b = RMF.BufferHandle() + rmf = RMF.create_rmf_buffer(b) + pf = RMF.ParticleFactory(rmf) + rf = RMF.ReferenceFrameFactory(rmf) + root = rmf.get_root_node() + p = root.add_child("particle", RMF.REPRESENTATION) + pf.get(p).set_radius(1.0) + pf.get(p).set_mass(1.0) + pf.get(p).set_coordinates(RMF.Vector3(1, 2, 3)) + refframe = root.add_child("refframe", RMF.REPRESENTATION) + rf.get(refframe).set_translation(RMF.Vector3(4, 1, 1)) + rf.get(refframe).set_rotation(RMF.Vector4(1, 0, 0, 0)) + p = refframe.add_child("particle", RMF.REPRESENTATION) + pf.get(p).set_radius(1.0) + pf.get(p).set_mass(1.0) + pf.get(p).set_coordinates(RMF.Vector3(4, 5, 6)) + return rmf + + +class Tests(unittest.TestCase): + + @unittest.skipUnless(RMF.RMF_HAS_NUMPY, "No numpy support") + def test_get_global_coordinates(self): + """Test get global coordinates as numpy array""" + rmf = _make_rmf() + root = rmf.get_root_node() + # coord array of wrong type + self.assertRaises(TypeError, RMF.get_all_global_coordinates, rmf, + root, "foo") + # coord array of wrong dimension + self.assertRaises(ValueError, RMF.get_all_global_coordinates, rmf, + root, numpy.empty((1, 3), numpy.float32)) + self.assertRaises(ValueError, RMF.get_all_global_coordinates, rmf, + root, numpy.empty((8, 3), numpy.float32)) + coord = numpy.empty((2, 3), numpy.float32) + RMF.get_all_global_coordinates(rmf, root, coord) + # Second coordinate should be transformed by the reference frame + expected_coord = numpy.array([[1., 2., 3.], [8., 6., 7.]]) + self.assertLess(numpy.linalg.norm(coord - expected_coord), 1e-4) + + +if __name__ == '__main__': + unittest.main() From 07d55af1dded555a8b7b28afb1876b20410b224c Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 15 Mar 2023 11:44:31 -0700 Subject: [PATCH 25/29] Use float64 numpy array, not float32 The primary purpose of this function is to supply coordinates to ChimeraX, which requires a 'float' numpy array (corresponding to a C++ double) not a 'float32' (C++ float), so match the desired type. --- swig/RMF.numpy.i | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/swig/RMF.numpy.i b/swig/RMF.numpy.i index 09166918..6018f18f 100644 --- a/swig/RMF.numpy.i +++ b/swig/RMF.numpy.i @@ -51,7 +51,7 @@ class _OurVisitor { // Dimension of the NumPy array npy_intp ncoord_; // Raw data in the N*3 NumPy array - float *data_; + double *data_; void add_coordinates(const RMF::Vector3 &v) { numxyz++; @@ -67,7 +67,7 @@ class _OurVisitor { } public: - _OurVisitor(RMF::FileConstHandle fh, npy_intp ncoord, float *data) + _OurVisitor(RMF::FileConstHandle fh, npy_intp ncoord, double *data) : refframef_(fh), particlef_(fh), ballf_(fh), altf_(fh), ncoord_(ncoord), data_(data) {} @@ -111,13 +111,13 @@ void get_all_global_coordinates( if (numpy_import_retval != 0) { throw std::runtime_error("NumPy did not initialize"); } - if (!is_native_numpy_2d_array(coord, NPY_FLOAT, 3)) { - throw std::invalid_argument("NumPy array is not a native N*3 float array"); + if (!is_native_numpy_2d_array(coord, NPY_DOUBLE, 3)) { + throw std::invalid_argument("NumPy array is not a native N*3 double array"); } PyArrayObject *acoord = (PyArrayObject *)coord; npy_intp ncoord = PyArray_DIM(acoord, 0); - float *data = (float *)PyArray_DATA(acoord); + double *data = (double *)PyArray_DATA(acoord); _OurVisitor v(fh, ncoord, data); v.handle_node(nh, RMF::CoordinateTransformer()); From 30e8a01914632a9a63cd3199d3fa9126179ada06 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 15 Mar 2023 12:06:45 -0700 Subject: [PATCH 26/29] Add recent changes --- ChangeLog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 79200b27..4248006a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,13 @@ Change Log {#changelog} - Windows builds now require MS Visual Studio 2015 or later (for full C++11 support). The following macros for pre-C++11 environments are no longer needed and are deprecated: `RMF_NOEXCEPT`, `RMF_CANEXCEPT`. +- All RMF binaries now report the full version (including micro version) + when the --version flag is used (e.g. "1.4.1", not "1.4"). +- If built with NumPy, some Python-specific functions are now provided to + allow direct access to RMF data via NumPy arrays. +- File handles can now be explicitly closed (via a `close` method). Most IO + operations on a closed handle will now raise an error. In Python file handles + now support the context manager protocol so can be used in 'with' blocks. # 1.4.1 - 2022-11-21 # {#changelog_1_4_1} - Build fixes to work with SWIG 4.1. From 8144eda41000ebd2707c4cd989dacd04c50f4835 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 15 Mar 2023 12:17:26 -0700 Subject: [PATCH 27/29] NumPy array should now be a double array --- test/test_numpy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_numpy.py b/test/test_numpy.py index f9dc837e..990d52b0 100644 --- a/test/test_numpy.py +++ b/test/test_numpy.py @@ -37,10 +37,10 @@ def test_get_global_coordinates(self): root, "foo") # coord array of wrong dimension self.assertRaises(ValueError, RMF.get_all_global_coordinates, rmf, - root, numpy.empty((1, 3), numpy.float32)) + root, numpy.empty((1, 3))) self.assertRaises(ValueError, RMF.get_all_global_coordinates, rmf, - root, numpy.empty((8, 3), numpy.float32)) - coord = numpy.empty((2, 3), numpy.float32) + root, numpy.empty((8, 3))) + coord = numpy.empty((2, 3)) RMF.get_all_global_coordinates(rmf, root, coord) # Second coordinate should be transformed by the reference frame expected_coord = numpy.array([[1., 2., 3.], [8., 6., 7.]]) From 8024417b8ddf033ba6d7bebcebf84fd3fda7bd8d Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 15 Mar 2023 14:37:01 -0700 Subject: [PATCH 28/29] Use std::enable_if rather than boost::enable_if --- include/RMF/Vector.h | 12 +++++------- swig/RMF_HDF5.i | 3 +-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/RMF/Vector.h b/include/RMF/Vector.h index 059e6891..73b0846e 100644 --- a/include/RMF/Vector.h +++ b/include/RMF/Vector.h @@ -14,8 +14,7 @@ #include "exceptions.h" #include #include -#include -#include +#include #include #include #include @@ -39,15 +38,14 @@ class Vector struct Convert {}; template - struct Convert > >::type> { + struct Convert >::value>::type> { static void convert(const R& r, std::array& d) { d = r; } }; template - struct Convert< - R, typename boost::enable_if > > >::type> { + struct Convert >::value>::type> { static void convert(const R& r, std::array& d) { std::copy(boost::begin(r), boost::end(r), d.begin()); } diff --git a/swig/RMF_HDF5.i b/swig/RMF_HDF5.i index 847f427d..671d7236 100644 --- a/swig/RMF_HDF5.i +++ b/swig/RMF_HDF5.i @@ -14,8 +14,7 @@ RMF_VC_PRAGMA(warning( disable: 4503 )) #include #include -#include -#include +#include #include #include "RMF/internal/swig_helpers.h" From 6224231401c970806391c91d439da8bf30ee4e7d Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Tue, 21 Mar 2023 22:43:47 -0700 Subject: [PATCH 29/29] Prepare for 1.5.0 release --- CMakeLists.txt | 4 ++-- ChangeLog.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a0c64d4..4bcc9c5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,8 +139,8 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) # Version information set (RMF_VERSION_MAJOR 1) -set (RMF_VERSION_MINOR 4) -set (RMF_VERSION_MICRO 1) +set (RMF_VERSION_MINOR 5) +set (RMF_VERSION_MICRO 0) set(RMF_SOVERSION "${RMF_VERSION_MAJOR}.${RMF_VERSION_MINOR}" CACHE INTERNAL "" FORCE) set(RMF_HAS_DEBUG_VECTOR 0 CACHE BOOL "Whether to use a bounds checked vector") diff --git a/ChangeLog.md b/ChangeLog.md index 4248006a..46f1dfd7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,7 +1,7 @@ Change Log {#changelog} ========== -# HEAD +# 1.5.0 - 2023-03-22 # {#changelog_1_5_0} - Windows builds now require MS Visual Studio 2015 or later (for full C++11 support). The following macros for pre-C++11 environments are no longer needed and are deprecated: `RMF_NOEXCEPT`, `RMF_CANEXCEPT`.