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