Reference documentation for deal.II version 8.4.2
job_identifier.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2014 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #include <deal.II/base/job_identifier.h>
17 #include <ctime>
18 
19 #ifdef DEAL_II_HAVE_UNISTD_H
20 # include <unistd.h>
21 #endif
22 
23 #ifdef DEAM_II_MSVC
24 # include <WinSock2.h>
25 #endif
26 
27 DEAL_II_NAMESPACE_OPEN
28 
29 
30 JobIdentifier dealjobid;
31 
32 
34 {
35  time_t t = std::time(0);
36  id = std::string("JobId ");
37 
38 #if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_GETHOSTNAME)
39  char name[100];
40  gethostname(name,99);
41  id += std::string(name) + std::string(" ");
42 #else
43  id += std::string("unknown ");
44 #endif
45 
46  id += std::string(std::ctime(&t));
47 }
48 
49 
50 const std::string
52 {
53  return id;
54 }
55 
56 
57 std::string
58 JobIdentifier::base_name(const char *filename)
59 {
60  std::string name(filename);
61  std::string::size_type pos = name.find(".");
62  name.erase(pos, name.size());
63  pos = name.rfind("/");
64  if (pos < name.size())
65  name.erase(0,pos);
66  return name;
67 }
68 
69 
70 
71 DEAL_II_NAMESPACE_CLOSE
const std::string operator()() const
static std::string base_name(const char *filename)
std::string id