Debian Codegraph @

include/deal.II/base/job_identifier.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 1998 - 2023 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // Part of the source code is dual licensed under Apache-2.0 WITH
9 // LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10 // governing the source code and code contributions can be found in
11 // LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12 //
13 // ------------------------------------------------------------------------
14
15 #ifndef dealii_job_identifier_h
16 #define dealii_job_identifier_h
17
18
19 #include <deal.II/base/config.h>
20
21 #include <string>
22
23 DEAL_II_NAMESPACE_OPEN
24 /**
25 * Identification of a program run. <tt>JobIdentifier</tt> determines the
26 * start time of a program run and stores it as a program identifier. There
27 * exists a library object <tt>dealjobid</tt> of this class. This object can
28 * be accessed by all output functions to provide an id for the current job.
29 *
30 * @ingroup utilities
31 */
32 class JobIdentifier
33 {
34 public:
35 /**
36 * Constructor. Set program identifier to value of <tt>program_id</tt>
37 * concatenated with the present time.
38 */
39 JobIdentifier();
40
41 /**
42 * This function returns an identifier for the running program. Currently,
43 * the library provides a function returning "JobID".
44 *
45 * The user may define a replacement of this function in their source code and
46 * avoid linking the library version. Unfortunately, this mechanism does not
47 * work with shared libraries.
48 */
49 static const char *
50 program_id();
51
52 /**
53 * Obtain the base name of the filename passed as argument. That is,
54 * if the file is <tt>mypath/file.cc</tt> return just
55 * <tt>file</tt>. For example, this function can be called from a
56 * user program with argument <tt>__FILE__</tt> to create an
57 * identifier for the program being run.
58 */
59 static std::string
60 base_name(const std::string &filename);
61
62 /**
63 * Return the value of <tt>id</tt>.
64 */
65 std::string
66 operator()() const;
67
68 /**
69 * %Function to identify the presently running program.
70 */
71 static const JobIdentifier &
72 get_dealjobid();
73
74 private:
75 /**
76 * String holding the identifier of the presently running program.
77 */
78 std::string id;
79 };
80
81 DEAL_II_NAMESPACE_CLOSE
82
83 #endif