You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: TODO_SCTP.md
+7-14Lines changed: 7 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,26 +48,19 @@ else if (auto* barItem = std::get_if<std::unique_ptr<BarItem>>(&item))
48
48
// However we can check item->GetType() instead and do a switch().
49
49
```
50
50
51
-
## Parsing of subclasses FooItem
52
-
53
-
- Must initialize Value Length field in the constructor.
54
-
- Must provide with a `virtual bool FooItem::Verify() const = 0` method in which subclasses verify if header, flags, value length and value is ok.
55
-
- Must probably remove `GetValue()` and `SetValue()` in parent `FooItem` class or make then protected.
56
-
57
-
NO! Instead:
58
-
59
-
- Must remove static `Parse()` and `Factory()` in FooItem and implement
60
-
- them into each subclass.
61
-
62
51
## Optimize creation of packets with items
63
52
64
53
- Add some `GetNextItemPtr(size_t& remainingBufferLength)` in a packert class that returns a pointer to the position in which a new item would take place and modifies the given `remainingBufferLength` with the remaining length of the buffer after that position.
65
54
- Then create a `Item` via `Item::Factory()` by passing `ptr` as `buffer` and `remainingBufferLength` as `bufferLength`.
66
55
- Then also add `packet->AddInPlaceItem(item, ptr)` (or whatever) so the packet doesn't serialize (doesn't memcpy) the bytes of the `Item` into its buffer.
67
56
- Another related option is to add specialized `AddXxxxItem()` methods in the packet class.
68
57
69
-
## FooItem subclasses
58
+
## FooPacket and FooItem TODO
70
59
71
-
- If we have a FooDataItem, the app should not be able to change its id via `SetId()`, AKA make `SetId()` protected since app should use `FooXxxxItem::Factory()` static methods.
72
-
- `FooItem` constructor: It doesn't make sense that it fills things since we want to rely on subclasses' `Parse()`, `Factory()` and constructors (that will override these calls anyway).
73
60
- If `FooItem` has valid but unknown id, that's correct, but let's remove the `SetValue()` method so those unknown items can only be parsed but not created.
61
+
- Remove `FooItem::GetValue()` and `GetValueLength()`.
62
+
- Document that having `auto item = FooPacket::GetIem(idx)`, the caller needs to cast to specific `FooItem` subclass by checking `item->GetId()` and then doing this, HOEWEVER this will **invalidate** the `FooItem` in the `FooPacket`!!!:
63
+
```c++
64
+
auto numericItem = std::unique_ptr<FooNumericItem>(static_cast<FooNumericItem*>(item.release()));
0 commit comments