Embedded Template Library
1.0
Loading...
Searching...
No Matches
message.h
1
/******************************************************************************
2
The MIT License(MIT)
3
4
Embedded Template Library.
5
https://github.com/ETLCPP/etl
6
https://www.etlcpp.com
7
8
Copyright(c) 2017 John Wellbelove
9
10
Permission is hereby granted, free of charge, to any person obtaining a copy
11
of this software and associated documentation files(the "Software"), to deal
12
in the Software without restriction, including without limitation the rights
13
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
14
copies of the Software, and to permit persons to whom the Software is
15
furnished to do so, subject to the following conditions :
16
17
The above copyright notice and this permission notice shall be included in all
18
copies or substantial portions of the Software.
19
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
23
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
SOFTWARE.
27
******************************************************************************/
28
29
#ifndef ETL_MESSAGE_INCLUDED
30
#define ETL_MESSAGE_INCLUDED
31
32
#include "
platform.h
"
33
#include "
error_handler.h
"
34
#include "
exception.h
"
35
#include "message_types.h"
36
#include "
type_traits.h
"
37
#include "static_assert.h"
38
39
#include <stdint.h>
40
41
namespace
etl
42
{
43
//***************************************************************************
44
class
message_exception
:
public
etl::exception
45
{
46
public
:
47
48
message_exception
(
string_type
reason_
,
string_type
file_name_
,
numeric_type
line_number_
)
49
:
exception
(
reason_
,
file_name_
,
line_number_
)
50
{
51
}
52
};
53
54
//***************************************************************************
55
class
unhandled_message_exception
:
public
etl::message_exception
56
{
57
public
:
58
59
unhandled_message_exception
(
string_type
file_name_
,
numeric_type
line_number_
)
60
:
message_exception
(ETL_ERROR_TEXT(
"message:unknown"
, ETL_MESSAGE_FILE_ID
"A"
),
file_name_
,
line_number_
)
61
{
62
}
63
};
64
65
//***************************************************************************
66
// Message interface.
67
//***************************************************************************
68
class
imessage
69
{
70
public
:
71
72
virtual
~imessage
()
73
{
74
}
75
76
ETL_NODISCARD
virtual
etl::message_id_t
get_message_id()
const
ETL_NOEXCEPT = 0;
77
};
78
79
//***************************************************************************
80
// Message type.
81
//***************************************************************************
82
template
<etl::message_
id
_t ID_,
typename
TParent = etl::imessage>
83
class
message
:
public
TParent
84
{
85
ETL_STATIC_ASSERT((
etl::is_base_of<etl::imessage, TParent>::value
),
"TParent is not derived from etl::imessage"
);
86
87
public
:
88
89
static
ETL_CONSTANT
etl::message_id_t
ID =
ID_
;
90
91
ETL_NODISCARD
etl::message_id_t
get_message_id()
const
ETL_NOEXCEPT ETL_OVERRIDE
92
{
93
return
ID;
94
}
95
};
96
97
template
<etl::message_
id
_t ID_,
typename
TParent>
98
ETL_CONSTANT
etl::message_id_t
message<ID_, TParent>::ID
;
99
}
100
101
#endif
etl::imessage
Definition
message.h:69
etl::message_exception
Definition
message.h:45
etl::message
Definition
message.h:84
etl::unhandled_message_exception
Definition
message.h:56
error_handler.h
exception.h
etl::exception
Definition
exception.h:47
etl::is_base_of
is_base_of
Definition
type_traits_generator.h:1252
etl
bitset_ext
Definition
absolute.h:38
etl::message_id_t
uint_least8_t message_id_t
Allow alternative type for message id.
Definition
message_types.h:40
platform.h
etl::pair
pair holds two objects of arbitrary type
Definition
utility.h:164
type_traits.h
include
etl
message.h
Generated on Wed Oct 4 2023 20:11:17 for Embedded Template Library by
1.9.8