LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
systeminfo.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_SYSTEMINFO_H
21 #define LIBREPCB_SYSTEMINFO_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "exceptions.h"
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 namespace librepcb {
34 
35 /*******************************************************************************
36  * Class SystemInfo
37  ******************************************************************************/
38 
50 class SystemInfo final {
51  Q_DECLARE_TR_FUNCTIONS(SystemInfo)
52 
53 public:
54  // Constructors/Destructor
55  SystemInfo() = delete;
56 
62  static const QString& getUsername() noexcept;
63 
70  static const QString& getFullUsername() noexcept;
71 
77  static const QString& getHostname() noexcept;
78 
88  static bool isProcessRunning(qint64 pid);
89 
100  static QString getProcessNameByPid(qint64 pid);
101 
102 private:
103  // Cached Data
104  static QString sUsername;
105  static QString sFullUsername;
106  static QString sHostname;
107 };
108 
109 /*******************************************************************************
110  * End of File
111  ******************************************************************************/
112 
113 } // namespace librepcb
114 
115 #endif // LIBREPCB_SYSTEMINFO_H
static QString sHostname
Definition: systeminfo.h:106
static bool isProcessRunning(qint64 pid)
Check whether a process with a given PID is running or not.
Definition: systeminfo.cpp:158
static const QString & getUsername() noexcept
Get the name of the user which is logged in (like "homer")
Definition: systeminfo.cpp:76
static QString sUsername
Definition: systeminfo.h:104
static QString sFullUsername
Definition: systeminfo.h:105
static const QString & getFullUsername() noexcept
Get the full name of the user which is logged in (like "Homer Simpson")
Definition: systeminfo.cpp:95
static const QString & getHostname() noexcept
Get the hostname of the computer (like "homer-workstation")
Definition: systeminfo.cpp:146
static QString getProcessNameByPid(qint64 pid)
Get the process name of a given PID.
Definition: systeminfo.cpp:206
This class provides some methods to get information from the operating system.
Definition: systeminfo.h:50