#include "coco/IR/BagInfo.forward.h"
#include "coco/IR/ObjectSet.h"
+#include "coco/IR/DepSet.h"
#include "coco/IR/Locatable.h"
#include <set>
bool isOutput(void) const;
public:
- // WARN This method will be deprecated. Please use below "dependent_objects" instead
- // @brief Return the set of objects that depends on this bag
- ObjectSet deps(void) const;
+ // @brief Return the set of Dep links that point to this bag
+ const DepSet *deps(void) const;
// WARN This method will be deprecated. Please below "readers" instead
ReaderSet reads(void) const;
// WARN This method will be dpercated. Please use below "updaters" instead
--- /dev/null
+#ifndef __COCO_IR_DEP_FORWARD_H__
+#define __COCO_IR_DEP_FORWARD_H__
+
+namespace coco
+{
+
+class Dep;
+
+} // namespace coco
+
+#endif // __COCO_IR_DEP_FORWARD_H__
#ifndef __COCO_IR_DEP_SET_H__
#define __COCO_IR_DEP_SET_H__
-#include "coco/IR/Dep.h"
+#include "coco/IR/Dep.forward.h"
#include <set>
bool Bag::isInput(void) const { return _info->mask()->masked(BagMask::Input); }
bool Bag::isOutput(void) const { return _info->mask()->masked(BagMask::Output); }
-ObjectSet Bag::deps(void) const
-{
- ObjectSet res;
-
- for (const auto &dep : *(_info->deps()))
- {
- if (auto obj = dep->object())
- {
- res.insert(obj);
- }
- }
-
- return res;
-}
+const DepSet *Bag::deps(void) const { return _info->deps(); }
Bag::ReaderSet Bag::reads(void) const
{
Bag::ReaderSet res;
- for (auto obj : deps())
+ for (auto obj : dependent_objects(this))
{
for (auto use : *obj->user())
{
{
Bag::UpdaterSet res;
- for (auto obj : deps())
+ for (auto obj : dependent_objects(this))
{
if (obj->def())
{
return res;
}
-ObjectSet dependent_objects(const Bag *b) { return b->deps(); }
+ObjectSet dependent_objects(const Bag *b)
+{
+ ObjectSet res;
+
+ for (const auto &dep : *(b->deps()))
+ {
+ if (auto obj = dep->object())
+ {
+ res.insert(obj);
+ }
+ }
+
+ return res;
+}
+
Bag::ReaderSet readers(const Bag *b) { return b->reads(); }
Bag::UpdaterSet updaters(const Bag *b) { return b->updates(); }
dep.bag(bag);
- auto deps = bag->deps();
+ auto deps = coco::dependent_objects(bag);
ASSERT_EQ(deps.size(), 1);
ASSERT_NE(deps.count(obj), 0);
// User SHOULD be able to access dependent objects through 'bag'
{
- auto deps = bag->deps();
+ auto deps = coco::dependent_objects(bag);
ASSERT_EQ(deps.size(), 1);
ASSERT_EQ(deps.count(&obj), 1);
}
ASSERT_EQ(obj.bag(), nullptr);
{
- auto deps = bag->deps();
+ auto deps = coco::dependent_objects(bag);
ASSERT_EQ(deps.size(), 0);
}
}
// Object SHOULD be unlinked from Bag on destruction
{
- auto deps = bag->deps();
+ auto deps = coco::dependent_objects(bag);
ASSERT_EQ(deps.size(), 0);
}
}