diff --git a/src/swcio.hpp b/src/swcio.hpp index 6b5db68dd913db031fe07bd6862d1cae7d6e1d97..44b8a2b1610e6d6eba22cd184c8e102907c024f0 100644 --- a/src/swcio.hpp +++ b/src/swcio.hpp @@ -13,14 +13,14 @@ namespace io { -class cell_record +class cell_record { public: using id_type = int; // FIXME: enum's are not completely type-safe, since they can accept // anything that can be casted to their underlying type. - // + // // More on SWC files: http://research.mssm.edu/cnic/swc.html enum kind { undefined = 0, @@ -34,7 +34,7 @@ public: }; // cell records assume zero-based indexing; root's parent remains -1 - cell_record(kind type, int id, + cell_record(kind type, int id, float x, float y, float z, float r, int parent_id) : type_(type) @@ -47,7 +47,7 @@ public: { check_consistency(); } - + cell_record() : type_(cell_record::undefined) , id_(0) @@ -212,6 +212,7 @@ std::istream &operator>>(std::istream &is, cell_record &cell); // std::vector<cell_record> swc_read_cells(std::istream &is); + class cell_record_stream_iterator : public std::iterator<std::forward_iterator_tag, cell_record> { @@ -309,6 +310,25 @@ private: std::istream &is_; }; +class cell_record_range_clean +{ +}; + +struct swc_io_raw +{ + using cell_range_type = cell_record_range_raw; +}; + +struct swc_io_clean +{ + using cell_range_type = cell_record_range_raw; +}; + +template<typename T = swc_io_clean> + typename T::cell_range_type get_cell_records(std::istream &is) +{ + return typename T::cell_range_type(is); +} } // end of nestmc::io } // end of nestmc diff --git a/tests/test_swcio.cpp b/tests/test_swcio.cpp index 2ca3563abdf6b412a9a14ac3cdd67802fcfc5f92..975840f79712e0b3bd22a2b9e0e990f1238d1925 100644 --- a/tests/test_swcio.cpp +++ b/tests/test_swcio.cpp @@ -311,10 +311,10 @@ TEST(cell_record_ranges, raw) is << "4 1 14.566132 34.873772 7.857000 0.717830 1\n"; std::vector<cell_record> cells; - for (auto &&c : cell_record_range_raw(is)) { + for (auto c : get_cell_records<swc_io_raw>(is)) { cells.push_back(c); } - EXPECT_EQ(4, cells.size()); + EXPECT_EQ(4u, cells.size()); } }