im com
This commit is contained in:
parent
17c9f76b4b
commit
7cbd2a139d
4 changed files with 34 additions and 4 deletions
|
@ -172,7 +172,10 @@ namespace MultiArrayTools
|
|||
{
|
||||
private:
|
||||
typedef vector<std::pair<std::shared_ptr<IndexW>,size_t>> IVecT;
|
||||
|
||||
typedef std::map<std::string,std::shared_ptr<IndexW>> IMapT;
|
||||
|
||||
static IMapT sIMap;
|
||||
|
||||
IVecT mIVec;
|
||||
bool mIvecInit = false;
|
||||
|
||||
|
@ -184,6 +187,7 @@ namespace MultiArrayTools
|
|||
|
||||
DynamicIndex(const std::shared_ptr<RangeType>& range);
|
||||
|
||||
static void clearIMap() { sIMap.clear(); }
|
||||
static constexpr IndexType sType() { return IndexType::SINGLE; }
|
||||
static constexpr size_t totalDim() { return 1; }
|
||||
static constexpr size_t sDim() { return 1; }
|
||||
|
@ -198,6 +202,7 @@ namespace MultiArrayTools
|
|||
|
||||
DynamicIndex& operator()(const IVecT& ivec);
|
||||
DynamicIndex& operator()(const vector<std::shared_ptr<IndexW>>& ivec);
|
||||
DynamicIndex& operator()(const vector<std::string>& inames);
|
||||
|
||||
template <class... Indices>
|
||||
DynamicIndex& operator()(const std::shared_ptr<Indices>&... is);
|
||||
|
|
|
@ -91,6 +91,7 @@ namespace MultiArrayTools
|
|||
virtual DataHeader dataHeader() const = 0;
|
||||
|
||||
virtual std::shared_ptr<RangeBase> sub(size_t num) const { return std::shared_ptr<RangeBase>(); }
|
||||
virtual std::shared_ptr<IndexWrapperBase> aindex() const = 0;
|
||||
|
||||
friend RangeFactoryBase;
|
||||
|
||||
|
@ -112,6 +113,9 @@ namespace MultiArrayTools
|
|||
|
||||
virtual Index begin() const = 0;
|
||||
virtual Index end() const = 0;
|
||||
virtual std::shared_ptr<IndexWrapperBase> aindex() const override final
|
||||
//{ auto i = std::make_shared<Index>(this->begin()); return std::make_shared<IndexWrapper<Index>>(i); } //!!!
|
||||
{ auto i = std::make_shared<Index>(this->begin()); return nullptr; } //!!!
|
||||
|
||||
protected:
|
||||
RangeInterface() = default;
|
||||
|
|
|
@ -103,8 +103,12 @@ namespace MultiArrayTools
|
|||
//class AnonymousRange;
|
||||
|
||||
// dynamic_range.h
|
||||
//class AbstractIW;
|
||||
|
||||
class IndexWrapperBase;
|
||||
|
||||
// dynamic_range.h
|
||||
template <class Index>
|
||||
class IndexWrapper;
|
||||
|
||||
// dynamic_range.h
|
||||
//template <class EC>
|
||||
class DynamicIndex;
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace MultiArrayTools
|
|||
// INSTANCIATE IF NEEDED!!
|
||||
|
||||
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > DynamicRangeFactory::mAleadyCreated;
|
||||
|
||||
DynamicIndex::IMapT DynamicIndex::sIMap;
|
||||
|
||||
std::shared_ptr<RangeBase> DynamicRangeFactory::checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec)
|
||||
{
|
||||
|
@ -168,6 +168,23 @@ namespace MultiArrayTools
|
|||
return *this;
|
||||
}
|
||||
|
||||
DynamicIndex& DynamicIndex::operator()(const vector<std::string>& inames)
|
||||
{
|
||||
mIvecInit = true;
|
||||
assert(mIVec.size() == inames.size());
|
||||
for(size_t i = 0; i != mIVec.size(); ++i){
|
||||
const std::string& iname = inames[i];
|
||||
if(sIMap.count(iname) != 0){
|
||||
assert(this->range()->sub(i) == sIMap.at(iname)->range());
|
||||
}
|
||||
else {
|
||||
sIMap[iname] = this->range()->sub(i)->aindex();
|
||||
}
|
||||
mIVec[i].first = sIMap.at(iname);
|
||||
}
|
||||
sync();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
int DynamicIndex::pp(std::intptr_t idxPtrNum)
|
||||
|
|
Loading…
Reference in a new issue