ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
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
13
14#include "alib/boxing/enum.hpp"
16
17namespace 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//==================================================================================================
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.
57ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING( alib::lang::Message*, boxing::TBoxes<MonoAllocator>* )
58
59
60#endif // HPP_ALIB_CAMP_MESSAGE_MESSAGE
61
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:223
#define ALIB_BOXING_CUSTOMIZE_TYPE_MAPPING(TSource, TTarget)
Message(const CallerInfo &ci, MonoAllocator &monoAllocator, const Enum &type, TBoxables &&... args)
Definition message.hpp:43
CallerInfo CI
The source code location that this message relates to.
Definition message.hpp:34