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 
53 class SystemInfo final {
54  Q_DECLARE_TR_FUNCTIONS(SystemInfo)
55 
56 public:
57  // Constructors/Destructor
58  SystemInfo() = delete;
59 
65  static const QString& getUsername() noexcept;
66 
75  static const QString& getFullUsername() noexcept;
76 
82  static const QString& getHostname() noexcept;
83 
93  static bool isProcessRunning(qint64 pid);
94 
105  static QString getProcessNameByPid(qint64 pid);
106 
107 private:
108  // Cached Data
109  static QString sUsername;
110  static QString sFullUsername;
111  static QString sHostname;
112 };
113 
114 /*******************************************************************************
115  * End of File
116  ******************************************************************************/
117 
118 } // namespace librepcb
119 
120 #endif // LIBREPCB_SYSTEMINFO_H
static QString sHostname
Definition: systeminfo.h:111
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:109
static QString sFullUsername
Definition: systeminfo.h:110
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:53