anonymous range should be complete now (still UNTESTED)
This commit is contained in:
parent
1347615cb3
commit
1b251e5867
5 changed files with 64 additions and 15 deletions
|
@ -19,7 +19,13 @@ namespace MultiArrayTools
|
|||
typedef AnonymousRange oType;
|
||||
|
||||
AnonymousRangeFactory() = delete;
|
||||
AnonymousRangeFactory(const std::shared_ptr<Ranges>... origs);
|
||||
|
||||
template <class... Ranges>
|
||||
AnonymousRangeFactory(const std::tuple<std::shared_ptr<Ranges>...>& origs);
|
||||
|
||||
template <class... Ranges>
|
||||
AnonymousRangeFactory(std::shared_ptr<Ranges>... origs);
|
||||
|
||||
std::shared_ptr<RangeBase> create();
|
||||
|
||||
};
|
||||
|
@ -48,7 +54,10 @@ namespace MultiArrayTools
|
|||
AnonymousRange(const AnonymousRange& in) = delete;
|
||||
|
||||
template <class Ranges...>
|
||||
AnonymousRange(const std::shared_ptr<Ranges>... origs);
|
||||
AnonymousRange(const std::tuple<std::shared_ptr<Ranges>...>& origs)
|
||||
|
||||
template <class Ranges...>
|
||||
AnonymousRange(std::shared_ptr<Ranges>... origs);
|
||||
|
||||
size_t mSize;
|
||||
|
||||
|
@ -68,9 +77,16 @@ namespace MultiArrayTools
|
|||
* AnonymousRange *
|
||||
***********************/
|
||||
|
||||
AnonymousRangeFactory::AnonymousRangeFactory(const std::shared_ptr<Ranges>... origs)
|
||||
template <class... Ranges>
|
||||
AnonymousRangeFactory::AnonymousRangeFactory(const std::tuple<std::shared_ptr<Ranges>...>& origs)
|
||||
{
|
||||
mProd = std::shared_ptr<oType>( new AnonymousRange( space ) );
|
||||
mProd = std::shared_ptr<oType>( new AnonymousRange( origs ) );
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
AnonymousRangeFactory::AnonymousRangeFactory(std::shared_ptr<Ranges>... origs)
|
||||
{
|
||||
mProd = std::shared_ptr<oType>( new AnonymousRange( origs... ) );
|
||||
}
|
||||
|
||||
std::shared_ptr<RangeBase> AnonymousRangeFactory::create()
|
||||
|
@ -84,13 +100,22 @@ namespace MultiArrayTools
|
|||
***********************/
|
||||
|
||||
template <class... Ranges>
|
||||
AnonymousRange::AnonymousRange(const std::shared_ptr<Ranges>... origs) :
|
||||
AnonymousRange::AnonymousRange(const std::tuple<std::shared_ptr<Ranges>...>& origs) :
|
||||
RangeInterface<AnonymousIndex>()
|
||||
{
|
||||
mOrig.resize(sizeof...(Ranges));
|
||||
PackNum<sizeof...(Ranges)-1>::RangesToVec();
|
||||
// mOrig !!!!
|
||||
// mSize !!! = (prod origs.size...)
|
||||
PackNum<sizeof...(Ranges)-1>::RangesToVec( origs, mOrig );
|
||||
PackNum<sizeof...(Ranges)-1>::getSize( rst );
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
AnonymousRange::AnonymousRange(std::shared_ptr<Ranges>... origs) :
|
||||
RangeInterface<AnonymousIndex>()
|
||||
{
|
||||
auto rst = std::make_tuple(origs...);
|
||||
mOrig.resize(sizeof...(Ranges));
|
||||
PackNum<sizeof...(Ranges)-1>::RangesToVec( rst, mOrig );
|
||||
PackNum<sizeof...(Ranges)-1>::getSize( rst );
|
||||
}
|
||||
|
||||
size_t AnonymousRange::get(size_t pos) const
|
||||
|
|
|
@ -106,6 +106,12 @@ namespace MultiArrayTools
|
|||
template <class... Indices>
|
||||
class ContainerIndex;
|
||||
|
||||
// anonymous_range.h
|
||||
class AnonymousRangeFactory;
|
||||
|
||||
// anonymous_range.h
|
||||
class AnonymousRange;
|
||||
|
||||
// multi_array.h
|
||||
template <typename T, class... SRanges>
|
||||
class MultiArrayBase;
|
||||
|
|
|
@ -151,8 +151,10 @@ namespace {
|
|||
mrptr = std::dynamic_pointer_cast<MRange>(rfbptr->create());
|
||||
}
|
||||
|
||||
const size_t vs1 = 10000;
|
||||
const size_t vs2 = 1000;
|
||||
//const size_t vs1 = 10000;
|
||||
//const size_t vs2 = 1000;
|
||||
const size_t vs1 = 4000;
|
||||
const size_t vs2 = 2500;
|
||||
|
||||
std::shared_ptr<RangeFactoryBase> rfbptr;
|
||||
std::shared_ptr<SRange> sr1ptr;
|
||||
|
|
|
@ -245,12 +245,12 @@ namespace MultiArrayHelper
|
|||
PackNum<N-1>::printTuple(out, tp);
|
||||
}
|
||||
|
||||
template <class RangeType, class... Ranges>
|
||||
static void RangesToVec(const std::shared_ptr<RangeType> r,
|
||||
const std::shared_ptr<Ranges>... rs,
|
||||
template <class... Ranges>
|
||||
static void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
||||
std::vector<RangeBase> v)
|
||||
{
|
||||
|
||||
v[N] = std::get<N>(rst);
|
||||
PackNum<N>::RangesToVec(rst, v);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -433,6 +433,13 @@ namespace MultiArrayHelper
|
|||
out << std::get<sizeof...(T)-1>(tp);
|
||||
}
|
||||
|
||||
template <class... Ranges>
|
||||
static void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
||||
std::vector<RangeBase> v)
|
||||
{
|
||||
v[0] = std::get<0>(rst);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
|
||||
#ifdef include_range_type
|
||||
#define __incl_this__
|
||||
#endif
|
||||
#ifdef __single_range_h__
|
||||
// singel_range is template which is specialized here
|
||||
// therefore it must be defined before...
|
||||
#define __incl_this__
|
||||
#endif
|
||||
|
||||
#ifdef __incl_this__
|
||||
|
||||
#ifndef __ranges_header__
|
||||
#define __ranges_header__
|
||||
|
@ -10,3 +17,5 @@
|
|||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef __incl_this__
|
||||
|
|
Loading…
Reference in a new issue