Skip to content

Commit

Permalink
Started with a very first attempt for the OR operator
Browse files Browse the repository at this point in the history
Update #127
  • Loading branch information
eugenwintersberger committed Nov 10, 2017
1 parent 160019d commit 7b9cb27
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/dataspace/selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ void Hyperslab::apply(const Dataspace &space,SelectionOperation ops) const
}
}

SelectionList operator|(const Hyperslab &a,const Hyperslab &b)
{
return {{SelectionOperation::SET,Selection::SharedPointer(new Hyperslab(a))},
{SelectionOperation::OR,Selection::SharedPointer(new Hyperslab(b))}
};
}

SelectionList &operator|(SelectionList &selections,const Hyperslab &b)
{
selections.push_back({SelectionOperation::SET,
Selection::SharedPointer(new Hyperslab(b))});
return selections;
}


Points::Points():
Selection()
Expand Down
15 changes: 15 additions & 0 deletions src/include/h5cpp/dataspace/selection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <h5cpp/dataspace/dataspace.hpp>
#include <h5cpp/types.hpp>
#include <h5cpp/windows.hpp>
#include <memory>
#include <list>

namespace hdf5 {
namespace dataspace {
Expand All @@ -38,6 +40,13 @@ namespace dataspace {
class DLL_EXPORT Selection
{
public:
//!
//! \brief pointer for selection stacks
//!
//! As selections use virtual functions for being applied we have to
using UniquePointer = std::unique_ptr<Selection>;
using SharedPointer = std::shared_ptr<Selection>;

//!
//! \brief default constructor
//!
Expand Down Expand Up @@ -73,6 +82,9 @@ class DLL_EXPORT Selection
SelectionOperation ops) const = 0;
};

using SelectionPair = std::pair<SelectionOperation,Selection::SharedPointer>;
using SelectionList = std::list<SelectionPair>;

//!
//! \brief hyperslab selection class
//!
Expand Down Expand Up @@ -308,6 +320,9 @@ class DLL_EXPORT Hyperslab : public Selection

};

SelectionList operator|(const Hyperslab &a,const Hyperslab &b);
SelectionList& operator|(SelectionList &selections,const Hyperslab &b);


class DLL_EXPORT Points : public Selection
{
Expand Down

0 comments on commit 7b9cb27

Please sign in to comment.