Skip to content

Commit 79f917b

Browse files
committed
Added mention of the ".x_body" code injection fiels in the tutorial14.
1 parent a855ec0 commit 79f917b

22 files changed

+297
-12
lines changed

tutorials/tutorial14/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,22 @@ The `Msg1` definition of the schema uses these properties:
256256
...
257257
</message>
258258
```
259+
260+
To avoid an explicit implementation of the function signature the **v7.0** of the [commsdsl2comms](https://github.com/commschamp/commsdsl)
261+
allows usage of the **&lt;class&gt;.h.&lt;op&gt;_body** files (instead of **&lt;class&gt;.h.&lt;op&gt;** ones) contents
262+
of which is expected to be only a body of the function without the signature.
263+
264+
- **.read_body** - Overwrites default read function body.
265+
- **.write_body** - Overwrites default write function body.
266+
- **.length_body** - Overwrites default serialization length function body.
267+
- **.valid_body** - Overwrites default validity check function body.
268+
- **.refresh_body** - Overwrites default refresh function body.
269+
- **.name_body** - Overwrites default name retrieval function body.
270+
271+
There are multiple **Msg3.h.X_body** files inside [dsl_src/include/tutorial14/message](dsl_src/include/tutorial14/message) folder that
272+
demonstrate usage of the suffixes above and the injected code finds its way to
273+
[include/tutorial14/message/Msg3.h](include/tutorial14/message/Msg3.h).
274+
259275
----
260276

261277
## Summary

tutorials/tutorial14/dsl/schema.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
<fields>
44
<string name="Msg1Name" defaultValue="Message 1" />
55
<string name="Msg2Name" defaultValue="Message 2" />
6+
<string name="Msg3Name" defaultValue="Message 3" />
67

78
<enum name="MsgId" type="uint8" semanticType="messageId">
89
<validValue name="M1" val="1" displayName="^Msg1Name" />
910
<validValue name="M2" val="2" displayName="^Msg2Name" />
11+
<validValue name="M3" val="3" displayName="^Msg3Name" />
1012
</enum>
1113

1214
</fields>
@@ -45,6 +47,10 @@
4547

4648
<message name="Msg2" id="MsgId.M2" displayName="^Msg2Name">
4749
<int name="F1" type="uint16" />
48-
</message>
50+
</message>
51+
52+
<message name="Msg3" id="MsgId.M3" displayName="^Msg3Name">
53+
<int name="F1" type="uint32" />
54+
</message>
4955

5056
</schema>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <iostream>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
std::cout << "Call of custom " << __FUNCTION__ << std::endl;
2+
return Base::doLength();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
std::cout << "Call of custom " << __FUNCTION__ << std::endl;
2+
return Base::doRead(iter, len);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
std::cout << "Call of custom " << __FUNCTION__ << std::endl;
2+
return Base::doRefresh();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
std::cout << "Call of custom " << __FUNCTION__ << std::endl;
2+
return Base::doValid();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
std::cout << "Call of custom " << __FUNCTION__ << std::endl;
2+
return Base::doWrite(iter, len);

tutorials/tutorial14/include/tutorial14/MsgId.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ enum MsgId : std::uint8_t
1515
{
1616
MsgId_M1 = 1, ///< message id of <b>Message 1</b> message.
1717
MsgId_M2 = 2, ///< message id of <b>Message 2</b> message.
18+
MsgId_M3 = 3, ///< message id of <b>Message 3</b> message.
1819

1920
// --- Extra values generated for convenience ---
2021
MsgId_FirstValue = 1, ///< First defined value.
21-
MsgId_LastValue = 2, ///< Last defined value.
22-
MsgId_ValuesLimit = 3, ///< Upper limit for defined values.
22+
MsgId_LastValue = 3, ///< Last defined value.
23+
MsgId_ValuesLimit = 4, ///< Upper limit for defined values.
2324
};
2425

2526
} // namespace tutorial14

tutorials/tutorial14/include/tutorial14/dispatch/DispatchClientInputMessage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ auto dispatchClientInputMessage(
5757
using MsgType = tutorial14::message::Msg2<InterfaceType, TProtOptions>;
5858
return handler.handle(static_cast<MsgType&>(msg));
5959
}
60+
case tutorial14::MsgId_M3:
61+
{
62+
using MsgType = tutorial14::message::Msg3<InterfaceType, TProtOptions>;
63+
return handler.handle(static_cast<MsgType&>(msg));
64+
}
6065
default:
6166
break;
6267
};

0 commit comments

Comments
 (0)