flow: set-with-mode function to ease the transition of the observer class
This commit is contained in:
@@ -175,6 +175,17 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Assigns a resource to the current task with a given access mode.
|
||||
* @param res Resource identifier.
|
||||
* @param is_rw Access mode.
|
||||
* @return This flow builder.
|
||||
*/
|
||||
basic_flow &set(const id_type res, bool is_rw = false) {
|
||||
emplace(res, is_rw);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Assigns a read-only resource to the current task.
|
||||
* @param res Resource identifier.
|
||||
|
||||
@@ -120,6 +120,19 @@ TEST(Flow, Clear) {
|
||||
ASSERT_EQ(flow.size(), 0u);
|
||||
}
|
||||
|
||||
TEST(Flow, Set) {
|
||||
entt::flow flow{};
|
||||
flow.bind(0).set(10, true).bind(1).set(10, true).set(11, false);
|
||||
auto graph = flow.graph();
|
||||
|
||||
ASSERT_EQ(flow.size(), 2u);
|
||||
ASSERT_EQ(flow.size(), graph.size());
|
||||
ASSERT_NE(graph.edges().cbegin(), graph.edges().cend());
|
||||
|
||||
ASSERT_TRUE(graph.contains(0u, 1u));
|
||||
ASSERT_FALSE(graph.contains(1u, 0u));
|
||||
}
|
||||
|
||||
TEST(Flow, RO) {
|
||||
entt::flow flow{};
|
||||
flow.bind(0).ro(10).bind(1).ro(10).ro(11);
|
||||
|
||||
Reference in New Issue
Block a user