sub() function in range base
This commit is contained in:
parent
ca2e47b986
commit
f17d807d1a
3 changed files with 37 additions and 4 deletions
|
@ -186,6 +186,8 @@ namespace MultiArrayTools
|
|||
template <size_t N>
|
||||
auto getPtr() const -> decltype( std::get<N>( mSpace ) )&;
|
||||
|
||||
virtual std::shared_ptr<RangeBase> sub(size_t num) const override;
|
||||
|
||||
virtual size_t dim() const final;
|
||||
virtual size_t size() const final;
|
||||
|
||||
|
@ -304,7 +306,7 @@ namespace MultiArrayTools
|
|||
{
|
||||
return std::get<N>(mIPack);
|
||||
}
|
||||
|
||||
|
||||
template <class... Indices>
|
||||
MultiIndex<Indices...>& MultiIndex<Indices...>::operator()(std::shared_ptr<Indices>&... indices)
|
||||
{
|
||||
|
@ -535,6 +537,12 @@ namespace MultiArrayTools
|
|||
return std::get<N>(mSpace);
|
||||
}
|
||||
|
||||
template <class... Indices>
|
||||
std::shared_ptr<RangeBase> MultiRange<Indices...>::sub(size_t num) const
|
||||
{
|
||||
return RPackNum<sizeof...(Indices)-1>::getSub(mSpace, num);
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
size_t MultiRange<Ranges...>::dim() const
|
||||
{
|
||||
|
|
|
@ -85,6 +85,8 @@ namespace MultiArrayTools
|
|||
|
||||
virtual SpaceType spaceType() const = 0;
|
||||
virtual DataHeader dataHeader() const = 0;
|
||||
|
||||
virtual std::shared_ptr<RangeBase> sub(size_t num) const { return std::shared_ptr<RangeBase>(); }
|
||||
//virtual bool regular() const = 0; // integer distance (e.g. 2,3,4,...)
|
||||
//virtual bool linear() const = 0; // 1dim valuable (e.g. 2.45, 3.12, 3.56,...)
|
||||
//virtual bool multi() const = 0; // mdim
|
||||
|
|
|
@ -152,14 +152,25 @@ namespace MultiArrayHelper
|
|||
std::get<N>(target) = std::get<N>(source)->meta();
|
||||
RPackNum<N-1>::getMetaPos(target, source);
|
||||
}
|
||||
|
||||
|
||||
template <class IndexPack, typename MetaType>
|
||||
static void setMeta(IndexPack& target, const MetaType& source)
|
||||
{
|
||||
std::get<N>(target)->at( std::get<N>(source) );
|
||||
RPackNum<N-1>::setMeta(target, source);
|
||||
}
|
||||
|
||||
|
||||
template <class SpaceClass>
|
||||
inline static std::shared_ptr<RangeBase> getSub(const SpaceClass& space, size_t num)
|
||||
{
|
||||
if(num == N){
|
||||
return std::get<N>(space);
|
||||
}
|
||||
else {
|
||||
return RPackNum<N-1>::getSub(space, num);
|
||||
}
|
||||
}
|
||||
|
||||
template <class IndexPack>
|
||||
static void setIndexPack(IndexPack& iPack, size_t pos)
|
||||
{
|
||||
|
@ -413,7 +424,19 @@ namespace MultiArrayHelper
|
|||
{
|
||||
std::get<0>(target)->at( std::get<0>( source ) );
|
||||
}
|
||||
|
||||
|
||||
template <class SpaceClass>
|
||||
inline static std::shared_ptr<RangeBase> getSub(const SpaceClass& space, size_t num)
|
||||
{
|
||||
if(num == 0){
|
||||
return std::get<0>(space);
|
||||
}
|
||||
else {
|
||||
assert(0);
|
||||
return std::shared_ptr<RangeBase>();
|
||||
}
|
||||
}
|
||||
|
||||
template <class IndexPack>
|
||||
static void setIndexPack(IndexPack& iPack, size_t pos)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue