Merge "implemented decmatch (artf724241)"
[deliverable/titan.core.git] / core / LoggingBits.hh
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Raduly, Csaba
11 *
12 ******************************************************************************/
13 #ifndef LOGOPTIONS_HH
14 #define LOGOPTIONS_HH
15
16 #include "Logger.hh"
17 #include "memory.h"
18
19 /** @brief Collection of logging severities to log.
20
21 Each log severity which had a corresponding bit in an integer,
22 now has a boolean in an array.
23
24 @note This class must be a POD type. Because it will be a member of a union,
25 it must not have a constructor or a copy assignment operator.
26 The compiler-generated copy constructor and assignment
27 are fine for this class.
28
29 \b Warning! This class has no default constructor. An expression like @code
30 Logging_Bits x; @endcode will result in \c x being \b uninitialised.
31 To avoid surprises, initialise Logging_Bits objects as an aggregate: @code
32 Logging_Bits d = { 0,0,........,0 }; @endcode or copy-initialise from
33 one of the predefined constants e.g. @code
34 Logging_Bits d = Logging_Bits::log_nothing; @endcode or call Logging_Bits::clear()
35 immediately after constructing.
36
37 */
38 struct Logging_Bits
39 {
40 bool bits[TTCN_Logger::NUMBER_OF_LOGSEVERITIES];
41
42 static const Logging_Bits log_nothing;
43 static const Logging_Bits log_all;
44 static const Logging_Bits log_everything;
45 static const Logging_Bits default_console_mask;
46
47 bool operator ==( const Logging_Bits& other ) const;
48 bool operator !=( const Logging_Bits& other ) const
49 {
50 return ! operator==( other );
51 }
52
53 /** @brief Sets all bits to false.
54
55 @post *this == Logging_Bits::log_nothing
56 */
57 void clear();
58
59 /** @brief Sets one bit corresponding to a TTCN_Logger::Severity.
60
61
62 @pre \p sev >= 0
63 @pre \p sev < TTCN_Logger::NUMBER_OF_LOGSEVERITIES
64 @param sev log severity
65 @post bits[sev] is true
66
67 @note All other bits remain unchanged. To have set \b only the specified bit,
68 call clear() first.
69 */
70 void add_sev ( TTCN_Logger::Severity sev );
71
72 /** @brief Merge two Logging_Bits objects
73
74 Bits which are set in \p sev will become set in \p *this. \n
75 Bits which were already set in \p *this remain unchanged. \n
76 Bits which weren't set in either \p *this or \p other remain unset.
77
78 @param other Logging_Bits
79 */
80 void merge ( const Logging_Bits & other );
81
82 /** @brief Return a string corresponding to the bits set in this object.
83
84 @return an \c expstring_t containing a textual description.
85 The caller is responsible for calling Free().
86 The returned string is suitable for use in the Titan config file.
87
88 */
89 expstring_t describe() const;
90
91 private:
92 };
93
94 #endif
This page took 0.032766 seconds and 5 git commands to generate.