Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
job_identifier.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #include <deal.II/base/job_identifier.h>
17 
18 #include <ctime>
19 
20 #ifdef DEAL_II_HAVE_UNISTD_H
21 # include <unistd.h>
22 #endif
23 
24 DEAL_II_NAMESPACE_OPEN
25 
26 
27 const JobIdentifier &
29 {
30  static JobIdentifier dealjobid;
31  return dealjobid;
32 }
33 
34 
35 
37 {
38  time_t t = std::time(nullptr);
39  id = std::string("JobId ");
40 
41 #if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_GETHOSTNAME)
42  char name[100];
43  gethostname(name, 99);
44  id += std::string(name) + std::string(" ");
45 #else
46  id += std::string("unknown ");
47 #endif
48 
49  id += std::string(std::ctime(&t));
50 }
51 
52 
53 const std::string
55 {
56  return id;
57 }
58 
59 
60 std::string
61 JobIdentifier::base_name(const std::string &filename)
62 {
63  std::string name(filename);
64  std::string::size_type pos;
65  pos = name.rfind('/');
66  if (pos != std::string::npos)
67  name.erase(0, pos + 1);
68  pos = name.rfind('.');
69  if (pos != std::string::npos)
70  name.erase(pos, name.size());
71  return name;
72 }
73 
74 
75 
76 DEAL_II_NAMESPACE_CLOSE
const std::string operator()() const
static const JobIdentifier & get_dealjobid()
static std::string base_name(const std::string &filename)
std::string id