Skip to content

Commit 5cbd75b

Browse files
authored
Update virtual table policy diagram.md
1 parent 571afc1 commit 5cbd75b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

design/virtual table policy diagram.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
## Note: Some of the identifiers in the framework come from very old times, when the concepts where more primitive.
44

5+
## Terms
6+
7+
`template<typename Policy> AnyContainer<Policy>`: The type erasure wrapper/manager
8+
Policy: A type that has members that configure `AnyContainer`.
9+
For the sub-framework of virtual-table type switching, `zoo::Policy`, the user can specify the parameters of the local buffer and all the capabilities of the wrapper/manager:
10+
`Policy<StorageModel, A1, A2, A2>` indicates that the local buffer has the size and alignment of `StorageModel`, typically some `void *[N]`. The `A`s are *affordances*, the capabilities of the
11+
`AnyContainer` wrapper/manager.
12+
The **implementation** uses the following members of a policy:
13+
1. `MemoryLayout`: this is the **base value manager**. It's size and alignment are that of the `zoo::Policy` storage model.
14+
2. `template<typename ValueToManage> Builder`: indicates the concrete value manager for the given type
15+
3. `template<typename ConcreteAnyContainer> Affordances`: this provide bases from the affordances to the `AnyContainer`, this is how they add things to the interface of `AnyContainer`, via their template members `UserAffordance`, that use the CRTP [^user affordance CRTP]
16+
517
## The base value manager
618

719
The *policy* tells `AnyContainer` what its local storage is going to be, via the member `MemoryLayout`. You may think of the "Memory Layout" as the base ***value manager***.
@@ -26,3 +38,10 @@ The most important feature of this flavor of the framework is to use virtual tab
2638
```
2739
[from here](https://github.com/thecppzoo/zoo/blob/d6435fc984ee0bde31979f7908a73473f61ac4bd/inc/zoo/Any/VTablePolicy.h#L274-L276).
2840

41+
[^user affordance CRTP]: The curiously recurring template pattern accomplishes the following:
42+
For `AnyContainer<Policy<StorageModel, A1, A2, A2>>`:
43+
```c++
44+
using M = AnyContainer<Policy<StorageModel, A1, A2, A2>>;
45+
```
46+
then `A1::UserAffordance<M>` is a base class of `M`; if there is a function member `std::string stringize() const` in `A1::UserAffordance<M>`, then for an object `m` of `M`, you can invoke `m.stringize()`.
47+

0 commit comments

Comments
 (0)