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
};

tutorials/tutorial14/include/tutorial14/dispatch/DispatchMessage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ auto dispatchMessage(
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
};

tutorials/tutorial14/include/tutorial14/dispatch/DispatchServerInputMessage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ auto dispatchServerInputMessage(
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
};

tutorials/tutorial14/include/tutorial14/factory/AllMessagesDynMemMsgFactory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class AllMessagesDynMemMsgFactory
6666
switch (id) {
6767
case tutorial14::MsgId_M1: return MsgPtr(new tutorial14::message::Msg1<TInterface, TProtOptions>);
6868
case tutorial14::MsgId_M2: return MsgPtr(new tutorial14::message::Msg2<TInterface, TProtOptions>);
69+
case tutorial14::MsgId_M3: return MsgPtr(new tutorial14::message::Msg3<TInterface, TProtOptions>);
6970
default: break;
7071
}
7172

@@ -96,6 +97,7 @@ class AllMessagesDynMemMsgFactory
9697
{
9798
case tutorial14::MsgId_M1: return 1U;
9899
case tutorial14::MsgId_M2: return 1U;
100+
case tutorial14::MsgId_M3: return 1U;
99101
default: break;
100102
}
101103

tutorials/tutorial14/include/tutorial14/factory/ClientInputMessagesDynMemMsgFactory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class ClientInputMessagesDynMemMsgFactory
6666
switch (id) {
6767
case tutorial14::MsgId_M1: return MsgPtr(new tutorial14::message::Msg1<TInterface, TProtOptions>);
6868
case tutorial14::MsgId_M2: return MsgPtr(new tutorial14::message::Msg2<TInterface, TProtOptions>);
69+
case tutorial14::MsgId_M3: return MsgPtr(new tutorial14::message::Msg3<TInterface, TProtOptions>);
6970
default: break;
7071
}
7172

@@ -96,6 +97,7 @@ class ClientInputMessagesDynMemMsgFactory
9697
{
9798
case tutorial14::MsgId_M1: return 1U;
9899
case tutorial14::MsgId_M2: return 1U;
100+
case tutorial14::MsgId_M3: return 1U;
99101
default: break;
100102
}
101103

tutorials/tutorial14/include/tutorial14/factory/ServerInputMessagesDynMemMsgFactory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class ServerInputMessagesDynMemMsgFactory
6666
switch (id) {
6767
case tutorial14::MsgId_M1: return MsgPtr(new tutorial14::message::Msg1<TInterface, TProtOptions>);
6868
case tutorial14::MsgId_M2: return MsgPtr(new tutorial14::message::Msg2<TInterface, TProtOptions>);
69+
case tutorial14::MsgId_M3: return MsgPtr(new tutorial14::message::Msg3<TInterface, TProtOptions>);
6970
default: break;
7071
}
7172

@@ -96,6 +97,7 @@ class ServerInputMessagesDynMemMsgFactory
9697
{
9798
case tutorial14::MsgId_M1: return 1U;
9899
case tutorial14::MsgId_M2: return 1U;
100+
case tutorial14::MsgId_M3: return 1U;
99101
default: break;
100102
}
101103

tutorials/tutorial14/include/tutorial14/field/MsgId.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MsgId : public
2828
tutorial14::field::MsgIdCommon::ValueType,
2929
TExtraOpts...,
3030
comms::option::def::HasName,
31-
comms::option::def::ValidNumValueRange<1, 2>
31+
comms::option::def::ValidNumValueRange<1, 3>
3232
>
3333
{
3434
using Base =
@@ -37,7 +37,7 @@ class MsgId : public
3737
tutorial14::field::MsgIdCommon::ValueType,
3838
TExtraOpts...,
3939
comms::option::def::HasName,
40-
comms::option::def::ValidNumValueRange<1, 2>
40+
comms::option::def::ValidNumValueRange<1, 3>
4141
>;
4242
public:
4343
/// @brief Re-definition of the value type.

tutorials/tutorial14/include/tutorial14/field/MsgIdCommon.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ struct MsgIdCommon
5656
static const char* Map[] = {
5757
nullptr,
5858
"Message 1",
59-
"Message 2"
59+
"Message 2",
60+
"Message 3"
6061
};
6162
static const std::size_t MapSize = std::extent<decltype(Map)>::value;
6263

tutorials/tutorial14/include/tutorial14/input/AllMessages.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <tuple>
99
#include "tutorial14/message/Msg1.h"
1010
#include "tutorial14/message/Msg2.h"
11+
#include "tutorial14/message/Msg3.h"
1112
#include "tutorial14/options/DefaultOptions.h"
1213

1314
namespace tutorial14
@@ -23,7 +24,8 @@ template <typename TBase, typename TOpt = tutorial14::options::DefaultOptions>
2324
using AllMessages =
2425
std::tuple<
2526
tutorial14::message::Msg1<TBase, TOpt>,
26-
tutorial14::message::Msg2<TBase, TOpt>
27+
tutorial14::message::Msg2<TBase, TOpt>,
28+
tutorial14::message::Msg3<TBase, TOpt>
2729
>;
2830

2931
} // namespace input
@@ -37,7 +39,8 @@ using AllMessages =
3739
/// @param opts_ Type of the used protocol definition options.
3840
#define TUTORIAL14_ALIASES_FOR_ALL_MESSAGES(prefix_, suffix_, interface_, opts_) \
3941
using prefix_ ## Msg1 ## suffix_ = tutorial14::message::Msg1<interface_, opts_>; \
40-
using prefix_ ## Msg2 ## suffix_ = tutorial14::message::Msg2<interface_, opts_>;
42+
using prefix_ ## Msg2 ## suffix_ = tutorial14::message::Msg2<interface_, opts_>; \
43+
using prefix_ ## Msg3 ## suffix_ = tutorial14::message::Msg3<interface_, opts_>;
4144

4245
/// @brief Create type aliases for the all messages of the protocol using default options.
4346
/// @param prefix_ Prefix of the alias message type.

tutorials/tutorial14/include/tutorial14/input/ClientInputMessages.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <tuple>
99
#include "tutorial14/message/Msg1.h"
1010
#include "tutorial14/message/Msg2.h"
11+
#include "tutorial14/message/Msg3.h"
1112
#include "tutorial14/options/DefaultOptions.h"
1213

1314
namespace tutorial14
@@ -23,7 +24,8 @@ template <typename TBase, typename TOpt = tutorial14::options::DefaultOptions>
2324
using ClientInputMessages =
2425
std::tuple<
2526
tutorial14::message::Msg1<TBase, TOpt>,
26-
tutorial14::message::Msg2<TBase, TOpt>
27+
tutorial14::message::Msg2<TBase, TOpt>,
28+
tutorial14::message::Msg3<TBase, TOpt>
2729
>;
2830

2931
} // namespace input
@@ -37,7 +39,8 @@ using ClientInputMessages =
3739
/// @param opts_ Type of the used protocol definition options.
3840
#define TUTORIAL14_ALIASES_FOR_CLIENT_INPUT_MESSAGES(prefix_, suffix_, interface_, opts_) \
3941
using prefix_ ## Msg1 ## suffix_ = tutorial14::message::Msg1<interface_, opts_>; \
40-
using prefix_ ## Msg2 ## suffix_ = tutorial14::message::Msg2<interface_, opts_>;
42+
using prefix_ ## Msg2 ## suffix_ = tutorial14::message::Msg2<interface_, opts_>; \
43+
using prefix_ ## Msg3 ## suffix_ = tutorial14::message::Msg3<interface_, opts_>;
4144

4245
/// @brief Create type aliases for the client input messages of the protocol using default options.
4346
/// @param prefix_ Prefix of the alias message type.

tutorials/tutorial14/include/tutorial14/input/ServerInputMessages.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <tuple>
99
#include "tutorial14/message/Msg1.h"
1010
#include "tutorial14/message/Msg2.h"
11+
#include "tutorial14/message/Msg3.h"
1112
#include "tutorial14/options/DefaultOptions.h"
1213

1314
namespace tutorial14
@@ -23,7 +24,8 @@ template <typename TBase, typename TOpt = tutorial14::options::DefaultOptions>
2324
using ServerInputMessages =
2425
std::tuple<
2526
tutorial14::message::Msg1<TBase, TOpt>,
26-
tutorial14::message::Msg2<TBase, TOpt>
27+
tutorial14::message::Msg2<TBase, TOpt>,
28+
tutorial14::message::Msg3<TBase, TOpt>
2729
>;
2830

2931
} // namespace input
@@ -37,7 +39,8 @@ using ServerInputMessages =
3739
/// @param opts_ Type of the used protocol definition options.
3840
#define TUTORIAL14_ALIASES_FOR_SERVER_INPUT_MESSAGES(prefix_, suffix_, interface_, opts_) \
3941
using prefix_ ## Msg1 ## suffix_ = tutorial14::message::Msg1<interface_, opts_>; \
40-
using prefix_ ## Msg2 ## suffix_ = tutorial14::message::Msg2<interface_, opts_>;
42+
using prefix_ ## Msg2 ## suffix_ = tutorial14::message::Msg2<interface_, opts_>; \
43+
using prefix_ ## Msg3 ## suffix_ = tutorial14::message::Msg3<interface_, opts_>;
4144

4245
/// @brief Create type aliases for the server input messages of the protocol using default options.
4346
/// @param prefix_ Prefix of the alias message type.

0 commit comments

Comments
 (0)