ALib C++ Library
by
Library Version:
2412 R0
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
lang
message
message.hpp
Go to the documentation of this file.
1
//==================================================================================================
2
/// \file
3
/// This header file is part of module \alib_basecamp of the \aliblong.
4
///
5
/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6
/// Published under \ref mainpage_license "Boost Software License".
7
//==================================================================================================
8
#ifndef HPP_ALIB_CAMP_MESSAGE_MESSAGE
9
#define HPP_ALIB_CAMP_MESSAGE_MESSAGE 1
10
#pragma once
11
#include "
alib/strings/cstring.hpp
"
12
ALIB_ASSERT_MODULE
(CAMP)
13
14
#include "alib/boxing/enum.hpp"
15
#include "
alib/monomem/sharedmonoval.hpp
"
16
17
namespace
alib::lang
{
18
19
//==================================================================================================
20
/// This struct stores a list of information objects of arbitrary types, by publicly inheriting type
21
/// \alib{BoxesMA}.
22
/// In addition, the \alib{lang;CallerInfo} is attached, which usually refers to the place
23
/// (and thread) tat constructed an instance of this type.<br>
24
/// Finally, a type identifier is available with field #Type.
25
///
26
/// Note that while message data might be passed with construction, informational data may be added,
27
/// changed or removed during the life-cycle of an instance using the inherited interface of
28
/// class \alib{boxing;TBoxes}.
29
///
30
/// Inside \alib, the struct is used with types \alib{lang;Exception} and \alib{lang;Report}.
31
//==================================================================================================
32
struct
Message
:
BoxesMA
33
{
34
CallerInfo
CI
;
///< The source code location that this message relates to.
35
Enum
Type
;
///< A type identifier, defined with construction by providing an element
36
///< of an arbitrary enumeration type.
37
/// Constructor.
38
/// @param ci Information about the scope of invocation.
39
/// @param monoAllocator The allocator to store the arguments in.
40
/// @param type The message type.
41
/// @param args Variadic, templated list of arguments.
42
template
<
typename
... TBoxables>
43
Message
(
const
CallerInfo
& ci,
44
MonoAllocator
& monoAllocator,
45
const
Enum
& type, TBoxables&&... args )
46
:
TBoxes
( monoAllocator )
47
,
CI
(ci)
48
,
Type
(type)
49
{
Add
( std::forward<TBoxables>(args)... ); }
50
};
51
52
}
// namespace [alib::lang]
53
54
55
// Customize boxing of type Message to its parent type Boxes. This allows "flattening" all
56
// arguments stored in a message when added to an instance of Boxes.
57
ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING
(
alib::lang::Message
*, boxing::TBoxes<MonoAllocator>* )
58
59
60
#endif
// HPP_ALIB_CAMP_MESSAGE_MESSAGE
61
alib::boxing::TBoxes< MonoAllocator >
alib::boxing::TBoxes< MonoAllocator >::Add
TBoxes & Add()
Definition
boxes.inl:74
alib::boxing::TBoxes< MonoAllocator >::TBoxes
TBoxes()
Definition
boxes.inl:51
alib::monomem::TMonoAllocator< lang::HeapAllocator >
cstring.hpp
ALIB_ASSERT_MODULE
#define ALIB_ASSERT_MODULE(modulename)
Definition
alib.hpp:223
ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING
#define ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING(TSource, TTarget)
Definition
typetraits.inl:526
alib::lang
Definition
alib.cpp:313
sharedmonoval.hpp
alib::boxing::Enum
Definition
enum.hpp:54
alib::lang::CallerInfo
Definition
alib.hpp:1129
alib::lang::Message
Definition
message.hpp:33
alib::lang::Message::Message
Message(const CallerInfo &ci, MonoAllocator &monoAllocator, const Enum &type, TBoxables &&... args)
Definition
message.hpp:43
alib::lang::Message::CI
CallerInfo CI
The source code location that this message relates to.
Definition
message.hpp:34
alib::lang::Message::Type
Enum Type
Definition
message.hpp:35