#include "coco/IR/ObjectSet.h"
#include "coco/IR/DepSet.h"
#include "coco/IR/ReadSet.h"
+#include "coco/IR/UpdateSet.h"
#include "coco/IR/Locatable.h"
#include <set>
const DepSet *deps(void) const;
// @brief Return the set of Read links that point to this bag
const ReadSet *reads(void) const;
- // WARN This method will be dpercated. Please use below "updaters" instead
- UpdaterSet updates(void) const;
+ // @brief Return the set of Update links that point to this bag
+ const UpdateSet *updates(void) const;
private:
std::unique_ptr<BagInfo> _info;
--- /dev/null
+#ifndef __COCO_IR_UPDATE_FORWARD_H__
+#define __COCO_IR_UPDATE_FORWARD_H__
+
+namespace coco
+{
+
+class Update;
+
+} // namespace coco
+
+#endif // __COCO_IR_UPDATE_FORWARD_H__
#ifndef __COCO_IR_UPDATE_SET_H__
#define __COCO_IR_UPDATE_SET_H__
-#include "coco/IR/Update.h"
+#include "coco/IR/Update.forward.h"
#include <set>
#include "coco/IR/Object.h"
#include "coco/IR/Read.h"
+#include "coco/IR/Update.h"
#include <nncc/foundation/Memory.h>
const DepSet *Bag::deps(void) const { return _info->deps(); }
const ReadSet *Bag::reads(void) const { return _info->reads(); }
-
-Bag::UpdaterSet Bag::updates(void) const
-{
- Bag::UpdaterSet res;
-
- for (auto obj : dependent_objects(this))
- {
- if (obj->def())
- {
- res.insert(obj->def());
- }
- }
-
- for (auto update : *_info->updates())
- {
- auto updater = update->updater();
- assert(updater != nullptr);
- res.insert(updater);
- }
-
- return res;
-}
+const UpdateSet *Bag::updates(void) const { return _info->updates(); }
ObjectSet dependent_objects(const Bag *b)
{
return res;
}
-Bag::UpdaterSet updaters(const Bag *b) { return b->updates(); }
+Bag::UpdaterSet updaters(const Bag *b)
+{
+ Bag::UpdaterSet res;
+
+ for (auto obj : dependent_objects(b))
+ {
+ if (obj->def())
+ {
+ res.insert(obj->def());
+ }
+ }
+
+ for (auto update : *b->updates())
+ {
+ auto updater = update->updater();
+ assert(updater != nullptr);
+ res.insert(updater);
+ }
+
+ return res;
+}
} // namespace coco
// Bag has no read/updates at the beginning
EXPECT_EQ(b.reads()->size(), 0);
- EXPECT_EQ(b.updates().size(), 0);
+ EXPECT_EQ(b.updates()->size(), 0);
}
ASSERT_EQ(slot.bag(), bag);
- {
- auto updates = bag->updates();
-
- ASSERT_EQ(updates.size(), 1);
- ASSERT_NE(updates.find(&update), updates.end());
- }
+ ASSERT_EQ(bag->updates()->size(), 1);
+ ASSERT_NE(bag->updates()->find(&slot), bag->updates()->end());
slot.bag(nullptr);
- {
- auto updates = bag->updates();
-
- ASSERT_EQ(slot.bag(), nullptr);
+ ASSERT_EQ(slot.bag(), nullptr);
- ASSERT_EQ(updates.size(), 0);
- }
+ ASSERT_EQ(bag->updates()->size(), 0);
}
TEST_F(UpdateTest, unlink_on_destruction)
{
coco::Update update{&bag_link, &updater};
update.bag(bag);
- ASSERT_EQ(bag->updates().size(), 1);
+ ASSERT_EQ(bag->updates()->size(), 1);
}
- ASSERT_EQ(bag->updates().size(), 0);
+ ASSERT_EQ(bag->updates()->size(), 0);
}