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: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 734992b3..4bcc9c5e 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) @@ -134,7 +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_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 5112e7ee..46f1dfd7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,18 @@ Change Log {#changelog} ========== +# 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`. +- 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. - Various internal build scripts now use 'python3' rather than 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/benchmark/benchmark_rmf.cpp b/benchmark/benchmark_rmf.cpp index 709acc51..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,17 +226,18 @@ 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) { + ret.close(); ret = RMF::open_rmf_file_read_only(path); ++count; } @@ -268,6 +284,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; { @@ -275,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; 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/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/config.h.in b/config.h.in index 69e3e080..6ce2e0a1 100644 --- a/config.h.in +++ b/config.h.in @@ -33,8 +33,10 @@ // 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@ +#define RMF_HAS_NUMPY @RMF_HAS_NUMPY@ #define RMF_HAS_DEPRECATED_BACKENDS @RMF_DEPRECATED_BACKENDS@ 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). 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. 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 518fea48..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,17 +108,43 @@ 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 NodeConstHandle get_root_node() const { + RMF_USAGE_CHECK(!get_is_closed(), "Operation on closed file."); return NodeConstHandle(NodeID(0), shared_); } - std::string get_name() const { return shared_->get_file_name(); } + //! Return True iff the file is closed + bool get_is_closed() const { + 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(); + } else { + return "(closed RMF file handle)"; + } + } - 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 @@ -193,22 +219,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 " @@ -222,6 +257,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(); } @@ -231,6 +267,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(); } @@ -239,7 +276,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..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,17 +53,20 @@ 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. - 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/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/handle.h b/include/RMF/HDF5/handle.h index 6b99342e..9a7b5d28 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; } - ~Handle() RMF_CANEXCEPT { +// Older clang does not like exception specification in combination +// with std::shared_ptr +#if defined(__clang__) && __clang_major__ <= 7 + ~Handle() { +#else + ~Handle() noexcept(false) { +#endif if (h_ != -1) { RMF_HDF5_CALL(f_(h_)); } 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..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. * @@ -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/Vector.h b/include/RMF/Vector.h index 0d6108ce..73b0846e 100644 --- a/include/RMF/Vector.h +++ b/include/RMF/Vector.h @@ -14,9 +14,8 @@ #include "exceptions.h" #include #include -#include -#include -#include +#include +#include #include #include @@ -27,29 +26,27 @@ 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; } + struct Convert >::value>::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) { + 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/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/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/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/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/internal/swig_helpers.h b/include/RMF/internal/swig_helpers.h index 68b4ad37..385d23f1 100644 --- a/include/RMF/internal/swig_helpers.h +++ b/include/RMF/internal/swig_helpers.h @@ -13,13 +13,8 @@ #include "RMF/infrastructure_macros.h" #include "RMF/exceptions.h" #include -#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; @@ -254,7 +247,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/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/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/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/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/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 5d569c6b..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 { @@ -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/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..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. @@ -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/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/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/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/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/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/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..7a00db04 100644 --- a/src/avrocpp/impl/BinaryDecoder.cc +++ b/src/avrocpp/impl/BinaryDecoder.cc @@ -22,12 +22,11 @@ #include "Zigzag.hh" #include "Exception.hh" -#include -#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..573f589d 100644 --- a/src/avrocpp/impl/BinaryEncoder.cc +++ b/src/avrocpp/impl/BinaryEncoder.cc @@ -18,13 +18,12 @@ #include "Encoder.hh" #include "Zigzag.hh" -#include -#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_; @@ -114,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/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..4308461d 100644 --- a/src/avrocpp/impl/DataFile.cc +++ b/src/avrocpp/impl/DataFile.cc @@ -28,14 +28,14 @@ #include namespace internal_avro { -using boost::shared_ptr; +using std::shared_ptr; using std::ostringstream; using std::istringstream; 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"); @@ -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; } @@ -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/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/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/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..c79346eb 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; @@ -35,8 +34,8 @@ using std::map; using std::istringstream; using std::ostringstream; -using boost::array; -using boost::shared_ptr; +using std::array; +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..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 { @@ -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..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); @@ -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/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/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/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/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"}, 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..6bce5006 100644 --- a/src/backend/deprecated_hdf5/HDF5SharedData.h +++ b/src/backend/deprecated_hdf5/HDF5SharedData.h @@ -10,8 +10,7 @@ #define RMF_INTERNAL_HDF_5SHARED_DATA_H #include -#include -#include +#include #include #include #include @@ -184,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/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/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 */ 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 0672d414..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) { @@ -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()); } 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..e8155b69 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -8,7 +8,7 @@ #include "RMF/utility.h" -#include +#include #include #include #include @@ -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/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.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/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 dd6566cf..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" @@ -68,7 +69,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" @@ -94,7 +95,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(); } %} @@ -161,3 +163,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..6018f18f --- /dev/null +++ b/swig/RMF.numpy.i @@ -0,0 +1,132 @@ +#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(); +} + +%{ +// 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 + double *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, double *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_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); + double *data = (double *)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/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/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" 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_file_handle.py b/test/test_file_handle.py new file mode 100644 index 00000000..d25feb37 --- /dev/null +++ b/test/test_file_handle.py @@ -0,0 +1,41 @@ +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) + + def test_closed_file_methods(self): + """Test methods on closed files""" + fh = RMF.FileConstHandle() + self.assertTrue(fh.get_is_closed()) + 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(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__': + unittest.main() diff --git a/test/test_file_level.py b/test/test_file_level.py index c40922fc..4ad82128 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") @@ -109,6 +110,35 @@ 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(IOError, f.get_number_of_frames) + 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(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()) + +if __name__ == '__main__': unittest.main() 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; diff --git a/test/test_numpy.py b/test/test_numpy.py new file mode 100644 index 00000000..990d52b0 --- /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))) + self.assertRaises(ValueError, RMF.get_all_global_coordinates, rmf, + 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.]]) + self.assertLess(numpy.linalg.norm(coord - expected_coord), 1e-4) + + +if __name__ == '__main__': + unittest.main() 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: 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__': 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: