mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Removed using directive in derived message router classes.
This commit is contained in:
parent
27f200e49d
commit
e422be6464
3
.gitignore
vendored
3
.gitignore
vendored
@ -388,3 +388,6 @@ support/time remaining test.xlsx
|
|||||||
test/vs2022/Debug MSVC C++20 - Force C++03
|
test/vs2022/Debug MSVC C++20 - Force C++03
|
||||||
test/vs2022/Release MSVC C++20 - No STL - Optimised -O2 - Sanitiser
|
test/vs2022/Release MSVC C++20 - No STL - Optimised -O2 - Sanitiser
|
||||||
test/test_file_list.txt
|
test/test_file_list.txt
|
||||||
|
examples/QueuedMessageRouter/vs2022/.vs/QueuedMessageRouter/CopilotIndices
|
||||||
|
examples/QueuedMessageRouter/vs2022/.vs/QueuedMessageRouter/FileContentIndex
|
||||||
|
examples/QueuedMessageRouter/vs2022/.vs/QueuedMessageRouter/v17
|
||||||
|
|||||||
@ -52,8 +52,6 @@ public:
|
|||||||
|
|
||||||
typedef etl::message_router<Router, Message1, Message2, Message3> Base_t;
|
typedef etl::message_router<Router, Message1, Message2, Message3> Base_t;
|
||||||
|
|
||||||
using Base_t::receive;
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
Router()
|
Router()
|
||||||
: message_router(1)
|
: message_router(1)
|
||||||
|
|||||||
@ -29,26 +29,26 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -253,6 +253,77 @@ namespace
|
|||||||
int sender_id;
|
int sender_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
// Router that handles messages 1, 2, 3.
|
||||||
|
// 'receive' is overridden.
|
||||||
|
//***************************************************************************
|
||||||
|
class Router3 : public etl::message_router<Router3, Message1, Message2, Message3>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
using base = etl::message_router<Router3, Message1, Message2, Message3>;
|
||||||
|
|
||||||
|
Router3()
|
||||||
|
: message_router(ROUTER3)
|
||||||
|
, message1_received(false)
|
||||||
|
, message2_received(false)
|
||||||
|
, message3_received(false)
|
||||||
|
, unknown_message_received(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void receive(const etl::imessage& msg) override
|
||||||
|
{
|
||||||
|
switch (msg.get_message_id())
|
||||||
|
{
|
||||||
|
case MESSAGE1:
|
||||||
|
{
|
||||||
|
message1_received = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MESSAGE2:
|
||||||
|
{
|
||||||
|
message2_received = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MESSAGE3:
|
||||||
|
{
|
||||||
|
message3_received = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
unknown_message_received = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_receive(const Message1& msg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_receive(const Message2& msg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_receive(const Message3& msg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_receive_unknown(const etl::imessage&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool message1_received;
|
||||||
|
bool message2_received;
|
||||||
|
bool message3_received;
|
||||||
|
bool unknown_message_received;
|
||||||
|
};
|
||||||
|
|
||||||
etl::imessage_router* p_router;
|
etl::imessage_router* p_router;
|
||||||
|
|
||||||
SUITE(test_message_router)
|
SUITE(test_message_router)
|
||||||
@ -641,5 +712,27 @@ namespace
|
|||||||
CHECK_EQUAL(0, r1.message4_count);
|
CHECK_EQUAL(0, r1.message4_count);
|
||||||
CHECK_EQUAL(0, r1.message_unknown_count);
|
CHECK_EQUAL(0, r1.message_unknown_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//*************************************************************************
|
||||||
|
TEST(message_router_with_overloaded_receive)
|
||||||
|
{
|
||||||
|
Router3 router;
|
||||||
|
etl::imessage_router& irouter = router;
|
||||||
|
|
||||||
|
Message1 message1(router);
|
||||||
|
Message2 message2(router);
|
||||||
|
Message3 message3(router);
|
||||||
|
|
||||||
|
router.receive(message1);
|
||||||
|
CHECK_TRUE(router.message1_received);
|
||||||
|
|
||||||
|
router.receive(message2);
|
||||||
|
CHECK_TRUE(router.message2_received);
|
||||||
|
|
||||||
|
router.receive(message3);
|
||||||
|
CHECK_TRUE(router.message3_received);
|
||||||
|
|
||||||
|
CHECK_FALSE(router.unknown_message_received);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user