A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
fatal-impl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 NICTA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Quincy Tse <quincy.tse@nicta.com.au>
7 */
8
9#ifndef FATAL_IMPL_H
10#define FATAL_IMPL_H
11
12#include <ostream>
13
14/**
15 * \file
16 * \ingroup fatalimpl
17 * ns3::FatalImpl::RegisterStream(), ns3::FatalImpl::UnregisterStream(),
18 * and ns3::FatalImpl::FlushStreams() declarations.
19 */
20
21/**
22 * \ingroup fatal
23 * \defgroup fatalimpl Fatal Implementation.
24 */
25
26namespace ns3
27{
28
29/**
30 * \ingroup fatalimpl
31 * \brief Implementation namespace for fatal error handlers.
32 */
33namespace FatalImpl
34{
35
36/**
37 * \ingroup fatalimpl
38 *
39 * \brief Register a stream to be flushed on abnormal exit.
40 *
41 * If a \c std::terminate() call is encountered after the
42 * stream had been registered and before it has been
43 * unregistered, \c stream->flush() will be called. Users of
44 * this function should ensure the stream remains valid until
45 * it had been unregistered.
46 *
47 * \param [in] stream The stream to be flushed on abnormal exit.
48 */
49void RegisterStream(std::ostream* stream);
50
51/**
52 * \ingroup fatalimpl
53 *
54 * \brief Unregister a stream for flushing on abnormal exit.
55 *
56 * After a stream had been unregistered, \c stream->flush()
57 * will no longer be called should abnormal termination be
58 * encountered.
59 *
60 * If the stream is not registered, nothing will happen.
61 *
62 * \param [in] stream The stream to be unregistered.
63 */
64void UnregisterStream(std::ostream* stream);
65
66/**
67 * \ingroup fatalimpl
68 *
69 * \brief Flush all currently registered streams.
70 *
71 * This function iterates through each registered stream and
72 * unregisters them. The default \c SIGSEGV handler is overridden
73 * when this function is being executed, and will be restored
74 * when this function returns.
75 *
76 * If a \c SIGSEGV is encountered (most likely due to a bad \c ostream*
77 * being registered, or a registered \c osteam* pointing to an
78 * \c ostream that had already been destroyed), this function will
79 * skip the bad \c ostream* and continue to flush the next stream.
80 * The function will then terminate raising \c SIGIOT (aka \c SIGABRT)
81 *
82 * DO NOT call this function until the program is ready to crash.
83 */
84void FlushStreams();
85
86} // namespace FatalImpl
87} // namespace ns3
88
89#endif
void UnregisterStream(std::ostream *stream)
Unregister a stream for flushing on abnormal exit.
void RegisterStream(std::ostream *stream)
Register a stream to be flushed on abnormal exit.
void FlushStreams()
Flush all currently registered streams.
Every class exported by the ns3 library is enclosed in the ns3 namespace.