Skip to content

Commit

Permalink
eckit::geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Aug 7, 2023
1 parent fc596b7 commit eee1161
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 469 deletions.
2 changes: 0 additions & 2 deletions src/eckit/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ list( APPEND eckit_geometry_srcs
Grid.h
Increments.cc
Increments.h
Iterator.cc
Iterator.h
KPoint.cc
KPoint.h
Point.cc
Expand Down
57 changes: 49 additions & 8 deletions src/eckit/geometry/Grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#pragma once

#include <iosfwd>
#include <memory>
#include <string>
#include <vector>

Expand All @@ -31,7 +32,40 @@ namespace eckit::geometry {
class Grid {
public:
// -- Types
// None

struct Iterator {
explicit Iterator(const Grid& grid) :
grid_(grid) {}

Iterator(const Iterator&) = delete;
Iterator(Iterator&&) = delete;

virtual ~Iterator() = default;

void operator=(const Iterator&) = delete;
void operator=(Iterator&&) = delete;

bool operator!=(const Iterator& other) const { return &grid_ != &other.grid_ || index_ != other.index_; }

bool operator++() {
index_++;
return operator bool();
}

virtual explicit operator bool() = 0;
virtual const Point& operator*() const = 0;

size_t size() const { return grid_.size(); }
size_t index() const { return index_; }

private:
const Grid& grid_;
size_t index_ = 0;
};


using iterator = std::unique_ptr<Iterator>;
using const_iterator = std::unique_ptr<const Iterator>;

// -- Exceptions
// None
Expand All @@ -40,8 +74,8 @@ class Grid {

explicit Grid(const Configuration&);

Grid(const Grid&) = default;
Grid(Grid&&) = default;
Grid(const Grid&) = delete;
Grid(Grid&&) = delete;

// -- Destructor

Expand All @@ -53,11 +87,20 @@ class Grid {
// -- Operators
// None

Grid& operator=(const Grid&) = default;
Grid& operator=(Grid&&) = default;
Grid& operator=(const Grid&) = delete;
Grid& operator=(Grid&&) = delete;

// -- Methods

virtual iterator begin() = 0;
virtual iterator end() = 0;

virtual const_iterator cbegin() const = 0;
virtual const_iterator cend() const = 0;

virtual const_iterator begin() const = 0;
virtual const_iterator end() const = 0;

virtual const area::BoundingBox& boundingBox() const;

virtual size_t size() const = 0;
Expand All @@ -78,9 +121,7 @@ class Grid {
protected:
// -- Constructors

Grid(const area::BoundingBox&);

// None
explicit Grid(const area::BoundingBox&);

// -- Methods

Expand Down
99 changes: 0 additions & 99 deletions src/eckit/geometry/Iterator.cc

This file was deleted.

190 changes: 0 additions & 190 deletions src/eckit/geometry/Iterator.h

This file was deleted.

Loading

0 comments on commit eee1161

Please sign in to comment.