Safir SDK Core
Loading...
Searching...
No Matches
ProcessInfo.h
Go to the documentation of this file.
1/******************************************************************************
2*
3* Copyright Saab AB, 2007-2013 (http://safirsdkcore.com)
4*
5* Created by: Lars Hagström / stlrha
6*
7*******************************************************************************
8*
9* This file is part of Safir SDK Core.
10*
11* Safir SDK Core is free software: you can redistribute it and/or modify
12* it under the terms of version 3 of the GNU General Public License as
13* published by the Free Software Foundation.
14*
15* Safir SDK Core is distributed in the hope that it will be useful,
16* but WITHOUT ANY WARRANTY; without even the implied warranty of
17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18* GNU General Public License for more details.
19*
20* You should have received a copy of the GNU General Public License
21* along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22*
23******************************************************************************/
24
25#ifndef __PROCESSINFO_H__
26#define __PROCESSINFO_H__
27
28#include <string>
29#include <Safir/Utilities/Internal/VisibilityHelpers.h>
30
31#ifdef lluf_utils_EXPORTS
32# define LLUF_UTILS_API SAFIR_HELPER_DLL_EXPORT
33#else
34# define LLUF_UTILS_API SAFIR_HELPER_DLL_IMPORT
35# define SAFIR_LIBRARY_NAME "lluf_utils"
36# include <Safir/Utilities/Internal/AutoLink.h>
37#endif
38#define LLUF_UTILS_LOCAL SAFIR_HELPER_DLL_LOCAL
39
40//Get hold of pid_t
41
42#if defined(linux) || defined(__linux) || defined(__linux__)
43# include <sys/types.h>
44#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
45 typedef int pid_t;
46#else
47# error You need to get hold of pid_t for this platform
48#endif
49
50#ifdef _MSC_VER
51#pragma warning(push)
52#pragma warning(disable: 4275)
53#endif
54
55namespace Safir
56{
57namespace Utilities
58{
60 {
61 public:
63 ProcessInfo(const pid_t pid);
64
67
69 static pid_t GetPid();
70
78 const std::string GetProcessName() const;
79
84 static const std::string GetProcessDescription();
85 private:
86 //we probably do not want this to be copyable if it is to be extended in the future.
87 ProcessInfo(const ProcessInfo&) = delete;
88 ProcessInfo& operator=(const ProcessInfo&) = delete;
89
90 const pid_t m_pid;
91 };
92
93}
94}
95
96#ifdef _MSC_VER
97#pragma warning(pop)
98#endif
99
100#endif
#define LLUF_UTILS_API
Definition DynamicLibraryLoader.h:33
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
Definition ProcessInfo.h:60
static pid_t GetPid()
Returns the pid of the current process.
const std::string GetProcessName() const
This method will probably return argv[0] of the process.
static const std::string GetProcessDescription()
This method will probably return the command line used to start the current process.
ProcessInfo(const pid_t pid)
Create a ProcessInfo object for a specific process.