add missing PRange / PRangeFactory member implementations

This commit is contained in:
Christian Zimmermann 2023-03-15 12:20:48 +01:00
parent 0e1ec2e95a
commit 40a86441cb
2 changed files with 99 additions and 2 deletions

View file

@ -14,7 +14,7 @@ namespace CNORXZ
PIndex<Index>::PIndex(const RangePtr& range, SizeT pos) : PIndex<Index>::PIndex(const RangePtr& range, SizeT pos) :
IndexInterface<Index,typename Index::MetaType>(pos), IndexInterface<Index,typename Index::MetaType>(pos),
mRangePtr(rangeCast<RangeType>(range)), mRangePtr(rangeCast<RangeType>(range)),
mOrig(mRangePtr->orig(),mRangePtr->parts()[pos]) mOrig(std::make_shared<Index>(mRangePtr->orig(),mRangePtr->parts()[pos]))
{} {}
template <class Index> template <class Index>
@ -208,6 +208,101 @@ namespace CNORXZ
CXZ_ERROR("meta position '" << mOrig->meta() << "' not part of range"); CXZ_ERROR("meta position '" << mOrig->meta() << "' not part of range");
} }
/*********************
* PRangeFactory *
*********************/
template <class Range>
PRangeFactory<Range>::PRangeFactory(const Sptr<Range>& range, const Vector<SizeT>& _parts) :
mRange(range), mParts(_parts)
{}
template <class Range>
void PRangeFactory<Range>::make()
{
const Vector<Uuid> key = { mRange->id() };
const auto& info = typeid(PRange<Range>);
mProd = this->fromCreated(info, key);
if(mProd == nullptr) {
mProd = std::make_shared<PRange<Range>>( new PRange(mRange, mParts) );
this->addToCreated(info, key, mProd);
}
}
/**************
* PRange *
**************/
template <class Range>
SizeT PRange<Range>::size() const
{
return mParts.size();
}
template <class Range>
SizeT PRange<Range>::dim() const
{
return 1;
}
template <class Range>
String PRange<Range>::stringMeta(SizeT pos) const
{
return mRange->stringMeta( mParts[pos] );
}
template <class Range>
const TypeInfo& PRange<Range>::type() const
{
return typeid(PRange<Range>);
}
template <class Range>
const TypeInfo& PRange<Range>::metaType() const
{
return mRange->metaType();
}
template <class Range>
RangePtr PRange<Range>::extend(const RangePtr& r) const
{
CXZ_ERROR("implement!!!");
return nullptr;
}
template <class Range>
RangePtr PRange<Range>::orig() const
{
return mRange;
}
template <class Range>
const Vector<SizeT>& PRange<Range>::parts() const
{
return mParts;
}
template <class Range>
RangePtr PRange<Range>::derive() const
{
Vector<MetaType> meta(this->size());
auto i = mRange->begin();
for(const auto& p: mParts){
meta = *(i = p);
}
return URangeFactory<MetaType>( meta ).create();
}
/************************
* PRange (private) *
************************/
template <class Range>
PRange<Range>::PRange(const Sptr<Range>& range, const Vector<SizeT>& _parts) :
mRange(range), mParts(_parts)
{}
} }
#endif #endif

View file

@ -77,7 +77,8 @@ namespace CNORXZ
PRangeFactory() = default; PRangeFactory() = default;
virtual void make() override final; virtual void make() override final;
RangePtr mRef; RangePtr mRange;
Vector<SizeT> mParts;
}; };
template <class Range> template <class Range>
@ -86,6 +87,7 @@ namespace CNORXZ
public: public:
typedef RangeBase RB; typedef RangeBase RB;
typedef PIndex<typename Range::IndexType> IndexType; typedef PIndex<typename Range::IndexType> IndexType;
typedef typename Range::MetaType MetaType;
friend PRangeFactory<Range>; friend PRangeFactory<Range>;