// NOTE Unlike replaceWith(b), replaceAllDepsWith(b) has no restriction
void replaceAllDepsWith(Bag *);
-public:
+private:
+ // "mutable_" prefix is deliberately introduced below to avoid resolution issue.
+ //
+ // Let's assume that two "deps" are overloaded in Bag as follows:
+ // class Bag
+ // {
+ // private:
+ // DepSet *deps(void); <-- 1
+ // public:
+ // const DepSet *deps(void) const; <-- 2
+ // };
+ //
+ // C++ compiler tries to invoke method 1 unless a bag itself is const. Thus, any "deps" calls
+ // over non-const bags except those calls from friend classes will introduce build error.
+
// WARN Only Dep is allowed to access this method
- DepSet *deps(void) { return &_deps; }
+ DepSet *mutable_deps(void) { return &_deps; }
// WARN Only Read is allowed to access this method
- ReadSet *reads(void) { return &_reads; }
+ ReadSet *mutable_reads(void) { return &_reads; }
// WARN Only Update is allowed to access this method
- UpdateSet *updates(void) { return &_updates; }
+ UpdateSet *mutable_updates(void) { return &_updates; }
private:
// WARN Only Input is allowed to access this method
// TODO Remove unnecessary indentation
{
assert(_bag->deps()->find(this) != _bag->deps()->end());
- _bag->deps()->erase(this);
+ _bag->mutable_deps()->erase(this);
}
// Reset _bag
// Create bag <-> dep link
// TODO Remove unnecessary indentation
{
- _bag->deps()->insert(this);
+ _bag->mutable_deps()->insert(this);
}
}
{
// TODO Remove unnecessary indentation
{
- _bag->reads()->erase(this);
+ _bag->mutable_reads()->erase(this);
}
_bag = nullptr;
}
_bag = bag;
// TODO Remove unnecessary indentation
{
- _bag->reads()->insert(this);
+ _bag->mutable_reads()->insert(this);
}
}
{
// TODO Remove unnecessary indentation
{
- _bag->updates()->erase(this);
+ _bag->mutable_updates()->erase(this);
}
_bag = nullptr;
}
_bag = bag;
// TODO Remove unnecessary indentation
{
- _bag->updates()->insert(this);
+ _bag->mutable_updates()->insert(this);
}
}