File: LoggingBits.hh

package info (click to toggle)
eclipse-titan 8.2.0-1
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 103,544 kB
  • sloc: cpp: 271,008; ansic: 33,683; yacc: 23,419; makefile: 15,483; lex: 9,204; java: 4,848; perl: 4,555; sh: 2,242; xml: 1,378; javascript: 85; awk: 48; php: 32; python: 13
file content (94 lines) | stat: -rw-r--r-- 2,936 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/******************************************************************************
 * Copyright (c) 2000-2021 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Raduly, Csaba
 *
 ******************************************************************************/
#ifndef LOGOPTIONS_HH
#define LOGOPTIONS_HH

#include "Logger.hh"
#include "memory.h"

/** @brief Collection of logging severities to log.

Each log severity which had a corresponding bit in an integer,
now has a boolean in an array.

@note This class must be a POD type. Because it will be a member of a union,
it must not have a constructor or a copy assignment operator.
The compiler-generated copy constructor and assignment
are fine for this class.

\b Warning! This class has no default constructor. An expression like @code
Logging_Bits x; @endcode will result in \c x being \b uninitialised.
To avoid surprises, initialise Logging_Bits objects as an aggregate: @code
Logging_Bits d = { 0,0,........,0 }; @endcode or copy-initialise from
one of the predefined constants e.g. @code
Logging_Bits d = Logging_Bits::log_nothing; @endcode or call Logging_Bits::clear()
immediately after constructing.

*/
struct Logging_Bits
{
  boolean bits[TTCN_Logger::NUMBER_OF_LOGSEVERITIES];

  static const Logging_Bits log_nothing;
  static const Logging_Bits log_all;
  static const Logging_Bits log_everything;
  static const Logging_Bits default_console_mask;

  boolean operator ==( const Logging_Bits& other ) const;
  boolean operator !=( const Logging_Bits& other ) const
  {
    return ! operator==( other );
  }

  /** @brief Sets all bits to false.

  @post *this == Logging_Bits::log_nothing
  */
  void clear();

  /** @brief Sets one bit corresponding to a TTCN_Logger::Severity.


  @pre \p sev >= 0
  @pre \p sev < TTCN_Logger::NUMBER_OF_LOGSEVERITIES
  @param sev log severity
  @post  bits[sev] is true

  @note All other bits remain unchanged. To have set \b only the specified bit,
  call clear() first.
  */
  void add_sev ( TTCN_Logger::Severity sev );

  /** @brief Merge two Logging_Bits objects

  Bits which are set in \p sev will become set in \p *this. \n
  Bits which were already set in \p *this remain unchanged. \n
  Bits which weren't set in either \p *this or \p other remain unset.

  @param other Logging_Bits
  */
  void merge   ( const Logging_Bits & other );

  /** @brief Return a string corresponding to the bits set in this object.

  @return an \c expstring_t containing a textual description.
  The caller is responsible for calling Free().
  The returned string is suitable for use in the Titan config file.

  */
  expstring_t describe() const;

private:
};

#endif