libcwdversion 2.0.0
The C++ Debugging Support Library
Loading...
Searching...
No Matches
ChannelSet.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2000-2007, 2018, 2020, 2023, 2026 Carlo Wood
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
9
10#ifndef LIBCWD_CLASS_CHANNEL_SET_H
11#define LIBCWD_CLASS_CHANNEL_SET_H
12
13#include "control_flag.h"
15#include "libcwd/config.h"
16
17namespace libcwd {
18
19class DebugObject;
20struct DebugObject_ThreadSpecificData;
21class Channel;
22class FatalChannel;
23
24//===================================================================================================
25// struct ChannelSetData
26//
27// The attributes of ChannelSetBootstrap, ChannelSet and ContinuedChannelSet
28//
29
30struct ChannelSetData
31{
32 char const* label;
33 // The label of the most left channel that is turned on.
34
35 control_flag_t mask;
36 // The bit-wise OR mask of all control flags and special channels.
37
38 bool on;
39 // Set if at least one of the provided channels is turned on.
40
41 DebugObject_ThreadSpecificData* debug_object_tsd_ptr;
42 // Thread specific data of current debug object.
43
44#if CWDEBUG_DEBUG
45 ChannelSetData() : debug_object_tsd_ptr(nullptr) { }
46#endif
47};
48
49//===================================================================================================
50// class ChannelSetBootstrap
51//
52// This is the left-most type of channel 'control' series
53// existing of <ChannelSetBootstrap>|<one or more channels>|<optional control flags>.
54// It is used in macro LibcwDoutScopeBegin.
55//
56// LibcwdDoutFatalScopeBegin uses FatalChannelSetBootstrap,
57// to make sure it was used with dc::fatal or dc::core.
58//
59// The return type is a cast of this object to
60// either a ChannelSet (the normal case) or a
61// ContinuedChannelSet in the case that the
62// special debug channel dc::continued was used.
63//
64
65class Channel;
66class FatalChannel;
67class ContinuedChannel;
68class AlwaysChannel;
69class ChannelSet;
70class ContinuedChannelSet;
71
72class ChannelSetBootstrap : public ChannelSetData
73{
74 // Warning: This struct may not have attributes of its own!
75 public:
76 ChannelSetBootstrap(DebugObject_ThreadSpecificData& debug_object_tsd, LIBCWD_TSD_PARAM_UNUSED)
77 {
78 debug_object_tsd_ptr = &debug_object_tsd;
79 }
80
81 //-------------------------------------------------------------------------------------------------
82 // Operators that combine channels/control bits.
83 //
84
85 ChannelSet& operator|(Channel const& dc);
86 ChannelSet& operator|(AlwaysChannel const& adc);
87 ContinuedChannelSet& operator|(ContinuedChannel const& cdc);
88};
89
90class FatalChannelSetBootstrap : public ChannelSetData
91{
92 // Warning: This struct may not have attributes of its own!
93 public:
94 FatalChannelSetBootstrap(DebugObject_ThreadSpecificData& debug_object_tsd, LIBCWD_TSD_PARAM_UNUSED)
95 {
96 debug_object_tsd_ptr = &debug_object_tsd;
97 }
98
99 //-------------------------------------------------------------------------------------------------
100 // Operators that combine channels/control bits.
101 //
102 ChannelSet& operator|(FatalChannel const& fdc);
103};
104
105//===================================================================================================
106// class ChannelSet
107//
108// The debug output target; a combination of channels and control bits.
109// The final result of a series of <channel>|<control flag>|...
110// is passed to struct_debug_tsd_st::start().
111//
112
113class ChannelSet : public ChannelSetData
114{
115 // Warning: This class may not have attributes of its own!
116 public:
117 ChannelSet& operator|(control_flag_t cf);
118 ChannelSet& operator|(Channel const& dc);
119 ChannelSet& operator|(FatalChannel const& fdc);
120 ContinuedChannelSet& operator|(continued_cf_nt);
121};
122
123//===================================================================================================
124// class ContinuedChannelSet
125//
126// The channel set type used for a series that starts with dc::continued.
127//
128
129class ContinuedChannelSet : public ChannelSetData
130{
131 // Warning: This class may not have attributes of its own!
132 public:
133 ContinuedChannelSet& operator|(control_flag_t cf);
134};
135
136} // namespace libcwd
137
138#endif // LIBCWD_CLASS_CHANNEL_SET_H
This object represents a debug channel, it has a fixed label. A debug channel can be viewed upon as a...
Definition Channel.h:74
The Debug Object class, this object represents one output device (ostream).
Definition DebugObject.h:110
unsigned int control_flag_t
Definition control_flag.h:21
continued_cf_nt
continued_cf has its own type for overloading purposes.
Definition control_flag.h:66
namespace for libcwd.