From f954f5db58b85eaaed9ea47aeef80f9ee5091e7d Mon Sep 17 00:00:00 2001 From: Ubpa <641614112@qq.com> Date: Sun, 24 May 2020 10:46:20 +0800 Subject: [PATCH] update doc --- README.md | 20 ++++++++++---------- doc/API.md | 17 ++++++++++++++++- doc/comparison.md | 5 ++--- include/UECS/RTDCmptViewer.h | 10 +++++++--- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index bb74ef1..193d39a 100644 --- a/README.md +++ b/README.md @@ -26,19 +26,19 @@ struct Position { float val; }; struct Velocity { float val; }; struct MoverSystem { - static void OnUpdate(Ubpa::Schedule& schedule) { - schedule.Request( - [](const Velocity* v, Position* p) { - p->val += v->val; - }, "Mover"); - } + static void OnUpdate(Ubpa::Schedule& schedule) { + schedule.Request( + [](const Velocity* v, Position* p) { + p->val += v->val; + }, "Mover"); + } }; int main() { - Ubpa::World w; - w.systemMngr.Register(); - w.entityMngr.CreateEntity(); - w.Update(); + Ubpa::World w; + w.systemMngr.Register(); + w.entityMngr.CreateEntity(); + w.Update(); } ``` diff --git a/doc/API.md b/doc/API.md index 525afbc..44da6dc 100644 --- a/doc/API.md +++ b/doc/API.md @@ -293,4 +293,19 @@ manage entities - `void Update()`: schedule -> gen job graph -> run job graph in worker threads -> run commands in main thread -- `std::string DumpUpdateJobGraph() const`: after `Update()`, you can use graphviz to vistualize the graph \ No newline at end of file +- `std::string DumpUpdateJobGraph() const`: after `Update()`, you can use graphviz to vistualize the graph + +## `RTDCmptViewer` + +use `RTDCmptViewer::Iterator` to read CmptPtr + +no read/write control + +### Methods + +- `RTDCmptViewer(EntityLocator* locator, void** cmpts)` +- `Iterator begin() const` +- `Iterator end() const` +- `const std::set& CmptTypes() const` +- `void* const* Components()` + diff --git a/doc/comparison.md b/doc/comparison.md index 1a4ba80..98305df 100644 --- a/doc/comparison.md +++ b/doc/comparison.md @@ -96,14 +96,13 @@ use `CmptTag::LastFrame (like const *)`, `CmptTag::Write == */ { public: using iterator_category = std::forward_iterator_tag; @@ -17,7 +21,7 @@ namespace Ubpa { using pointer = CmptPtr*; using reference = CmptPtr&; - Iterator(std::set::iterator typeIter = std::set::iterator{}, void** ptr_cmpt = nullptr) + Iterator(std::set::iterator typeIter = std::set::iterator{}, void* const* ptr_cmpt = nullptr) : typeIter(typeIter), ptr_cmpt{ ptr_cmpt } {} bool operator==(const Iterator& rhs) const noexcept { return ptr_cmpt == rhs.ptr_cmpt; @@ -37,7 +41,7 @@ namespace Ubpa { } private: std::set::iterator typeIter; - void** ptr_cmpt; + void* const* ptr_cmpt; mutable CmptPtr cmptptr{ CmptType::Invalid(), nullptr }; }; @@ -52,6 +56,6 @@ namespace Ubpa { private: EntityLocator* locator; - void** cmpts; + void* const* cmpts; }; }