File tree Expand file tree Collapse file tree
src/nunavut/lang/cpp/templates Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,3 +58,6 @@ nunavut_out
5858.hypothesis
5959
6060.ropeproject
61+
62+ # clangd
63+ .cache
Original file line number Diff line number Diff line change @@ -25,11 +25,19 @@ struct {{service_name}}
2525 struct _traits_
2626 {
2727 _traits_() = delete;
28+ {% - if T .has_fixed_port_id %}
29+ static constexpr bool HasFixedPortID = true;
30+ static constexpr {{ typename_unsigned_port }} FixedPortId = {{ T.fixed_port_id }}U;
31+ {% - else %}
32+ static constexpr bool HasFixedPortID = false;
33+ {% - endif %}
2834
2935 static constexpr bool IsServiceType = true;
3036 static constexpr bool IsService = true;
3137 static constexpr bool IsRequest = false;
3238 static constexpr bool IsResponse = false;
39+
40+ static constexpr const char* FullNameAndVersion() { return "{{ T }}"; }
3341 };
3442};
3543
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ const bool regulated::basics::Service::Response_0_1::_traits_::IsResponse;
3030const bool regulated::basics::Service::Response_0_1::_traits_::IsServiceType;
3131const bool regulated::basics::Service_0_1::_traits_::IsService;
3232const bool regulated::basics::Service_0_1::_traits_::IsServiceType;
33+ const bool regulated::basics::Service_0_1::_traits_::HasFixedPortID;
34+ const std::uint16_t regulated::basics::Service_0_1::_traits_::FixedPortId;
3335
3436const std::size_t regulated::basics::Struct__0_1::_traits_::ArrayCapacity::i10_4;
3537const std::size_t regulated::basics::Struct__0_1::_traits_::ArrayCapacity::f16_le2;
@@ -101,6 +103,10 @@ TEST(ConstantTests, Service)
101103 // Type parameters.
102104 EXPECT_TRUE (regulated::basics::Service_0_1::_traits_::IsService);
103105 EXPECT_TRUE (regulated::basics::Service_0_1::_traits_::IsServiceType);
106+ EXPECT_TRUE (regulated::basics::Service_0_1::_traits_::HasFixedPortID);
107+ EXPECT_THAT (regulated::basics::Service_0_1::_traits_::FixedPortId, 300 );
108+ EXPECT_THAT (regulated::basics::Service_0_1::_traits_::FullNameAndVersion (),
109+ StrEq (" regulated.basics.Service.0.1" ));
104110
105111 EXPECT_FALSE (regulated::basics::Service::Request_0_1::_traits_::IsService);
106112 EXPECT_TRUE (regulated::basics::Service::Request_0_1::_traits_::IsServiceType);
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ static_assert(
2929 regulated::basics::Service_0_1::_traits_::IsServiceType,
3030 " Service is a service type" );
3131
32+ static_assert (
33+ regulated::basics::Service_0_1::_traits_::HasFixedPortID,
34+ " Service has a fixed port ID" );
35+
3236static_assert (
3337 not regulated::basics::Service_0_1::Request::_traits_::IsService,
3438 " Request is not a service" );
You can’t perform that action at this time.
0 commit comments