libDwm-0.9.45
DwmProcessInfo.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2006-2007, 2016, 2020, 2024
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
40//---------------------------------------------------------------------------
41
42#ifndef _DWMPROCESSINFO_HH_
43#define _DWMPROCESSINFO_HH_
44
45extern "C" {
46 #include <unistd.h>
47 #include <bzlib.h>
48 #include <zlib.h>
49}
50
51#include <cstdint>
52#include <iostream>
53#include <string>
54#include <nlohmann/json.hpp>
55
56namespace Dwm {
57
58 //--------------------------------------------------------------------------
60 //--------------------------------------------------------------------------
62 {
63 public:
64 std::string user {""};
65 std::string ruser {""};
66 uint64_t pid {0};
67 uint64_t ppid {0};
68 uint64_t gid {0};
69 uint64_t uid {0};
70 uint64_t ruid {0};
71 uint64_t svuid {0};
72 uint64_t rgid {0};
73 uint64_t svgid {0};
74 uint64_t rss {0};
75 uint64_t vsz {0};
76 float pcpu {0.0};
77 float pmem {0.0};
78 int64_t pri {0};
79 int64_t lstart {0};
80 std::string tty {""};
81 std::string args {""};
82
83 //------------------------------------------------------------------------
85 //------------------------------------------------------------------------
86 std::istream & Read(std::istream & is);
87
88 //------------------------------------------------------------------------
90 //------------------------------------------------------------------------
91 std::ostream & Write(std::ostream & os) const;
92
93 //------------------------------------------------------------------------
96 //------------------------------------------------------------------------
97 int Read(gzFile gzf);
98
99 //------------------------------------------------------------------------
102 //------------------------------------------------------------------------
103 int Write(gzFile gzf) const;
104
105 //------------------------------------------------------------------------
108 //------------------------------------------------------------------------
109 int BZRead(BZFILE *bzf);
110
111 //------------------------------------------------------------------------
114 //------------------------------------------------------------------------
115 int BZWrite(BZFILE *bzf) const;
116
117 //------------------------------------------------------------------------
120 //------------------------------------------------------------------------
121 uint64_t StreamedLength() const;
122
123 //------------------------------------------------------------------------
125 //------------------------------------------------------------------------
126 nlohmann::json ToJson() const;
127
128 //------------------------------------------------------------------------
130 //------------------------------------------------------------------------
131 bool operator == (const ProcessInfo &) const;
132 };
133
134} // namespace Dwm
135
136//----------------------------------------------------------------------------
138//----------------------------------------------------------------------------
139std::ostream & operator << (std::ostream & os, const Dwm::ProcessInfo & pi);
140
141#endif // _DWMPROCESSINFO_HH_
std::ostream & operator<<(std::ostream &os, const Dwm::ProcessInfo &pi)
ostream output operator
Encapsulate information for a single process from the process table.
Definition DwmProcessInfo.hh:62
std::ostream & Write(std::ostream &os) const
Writes the process info to an ostream. Returns the ostream.
bool operator==(const ProcessInfo &) const
operator ==
int BZWrite(BZFILE *bzf) const
Writes the process info to a BZFILE.
std::istream & Read(std::istream &is)
Reads the process info from an istream. Returns the istream.
int Read(gzFile gzf)
Reads the process info from a gzFile.
nlohmann::json ToJson() const
Returns a JSON representation of the ProcessInfo.
int BZRead(BZFILE *bzf)
Reads the process info from a BZFILE.
uint64_t StreamedLength() const
Returns the number of bytes that would be written if we called one of the non-compressing Write() mem...
int Write(gzFile gzf) const
Writes the process info to a gzFile.