// NOTE Unlike replaceWith(b), replaceAllDepsWith(b) has no restriction
void replaceAllDepsWith(Bag *);
+public:
+ // WARN Only Dep is allowed to access this method
+ DepSet *deps(void) { return &_deps; }
+ // WARN Only Read is allowed to access this method
+ ReadSet *reads(void) { return &_reads; }
+ // WARN Only Update is allowed to access this method
+ UpdateSet *updates(void) { return &_updates; }
+
private:
std::unique_ptr<BagInfo> _info;
+
+private:
+ /** @brief Links to dependent Object(s) */
+ DepSet _deps;
+ /** @brief Direct reads (not through Object) */
+ ReadSet _reads;
+ /** @brief Direct updates (not through Object) */
+ UpdateSet _updates;
};
// @brief Return a set of objects that depends on a given bag
uint32_t const _size;
public:
- DepSet *deps(void) { return &_deps; }
- const DepSet *deps(void) const { return &_deps; }
-
-public:
- ReadSet *reads(void) { return &_reads; }
- const ReadSet *reads(void) const { return &_reads; }
-
-public:
- UpdateSet *updates(void) { return &_updates; }
- const UpdateSet *updates(void) const { return &_updates; }
-
-public:
BagMask *mask(void) { return &_mask; }
const BagMask *mask(void) const { return &_mask; }
private:
- /** @brief Links to dependent Object(s) */
- DepSet _deps;
- /** @brief Direct reads (not through Object) */
- ReadSet _reads;
- /** @brief Direct updates (not through Object) */
- UpdateSet _updates;
-
BagMask _mask;
};
Bag::~Bag()
{
// All the references over a bag SHOULD be dropped before its destruction
- assert(_info->deps()->size() == 0);
- assert(_info->reads()->size() == 0);
- assert(_info->updates()->size() == 0);
+ assert(deps()->size() == 0);
+ assert(reads()->size() == 0);
+ assert(updates()->size() == 0);
}
uint32_t Bag::size(void) const { return _info->size(); }
bool Bag::isInput(void) const { return _info->mask()->masked(BagMask::Input); }
bool Bag::isOutput(void) const { return _info->mask()->masked(BagMask::Output); }
-const DepSet *Bag::deps(void) const { return _info->deps(); }
-const ReadSet *Bag::reads(void) const { return _info->reads(); }
-const UpdateSet *Bag::updates(void) const { return _info->updates(); }
+const DepSet *Bag::deps(void) const { return &_deps; }
+const ReadSet *Bag::reads(void) const { return &_reads; }
+const UpdateSet *Bag::updates(void) const { return &_updates; }
void Bag::replaceWith(Bag *b)
{
// Remove bag <-> dep link
// TODO Remove unnecessary indentation
{
- auto info = _bag->_info.get();
- assert(info != nullptr);
- assert(info->deps()->find(this) != info->deps()->end());
-
- info->deps()->erase(this);
+ assert(_bag->deps()->find(this) != _bag->deps()->end());
+ _bag->deps()->erase(this);
}
// Reset _bag
// Create bag <-> dep link
// TODO Remove unnecessary indentation
{
- auto info = _bag->_info.get();
- assert(info != nullptr);
- info->deps()->insert(this);
+ _bag->deps()->insert(this);
}
}
{
// TODO Remove unnecessary indentation
{
- auto info = _bag->_info.get();
- assert(info != nullptr);
- info->reads()->erase(this);
+ _bag->reads()->erase(this);
}
_bag = nullptr;
}
_bag = bag;
// TODO Remove unnecessary indentation
{
- auto info = _bag->_info.get();
- assert(info != nullptr);
- info->reads()->insert(this);
+ _bag->reads()->insert(this);
}
}
{
// TODO Remove unnecessary indentation
{
- auto info = _bag->_info.get();
- assert(info != nullptr);
- info->updates()->erase(this);
+ _bag->updates()->erase(this);
}
_bag = nullptr;
}
_bag = bag;
// TODO Remove unnecessary indentation
{
- auto info = _bag->_info.get();
- assert(info != nullptr);
- info->updates()->insert(this);
+ _bag->updates()->insert(this);
}
}