plptools
Loading...
Searching...
No Matches
psiprocess.cc
Go to the documentation of this file.
1/*
2 * This file is part of plptools.
3 *
4 * Copyright (C) 1999-2002 Fritz Elfert <felfert@to.com>
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 2 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 along
17 * along with this program; if not, see <https://www.gnu.org/licenses/>.
18 *
19 */
20#include "config.h"
21
22#include "psiprocess.h"
23
24#include <sstream>
25#include <iomanip>
26
27using namespace std;
28
30 : pid(0), name(""), args(""), s5mx(false) {
31}
32
34 pid = p.pid;
35 name = p.name;
36 args = p.args;
37 s5mx = p.s5mx;
38}
39
40PsiProcess::PsiProcess(int _pid, const char * const _name,
41 const char * const _args, bool _s5mx) {
42 pid = _pid;
43 name = _name;
44 args = _args;
45 s5mx = _s5mx;
46}
47
49getPID() {
50 return pid;
51}
52
53const char *PsiProcess::
54getName() {
55 return name.c_str();
56}
57
58const char *PsiProcess::
59getArgs() {
60 return args.c_str();
61}
62
63const char *PsiProcess::
64getProcId() {
65 ostringstream tmp;
66
67 if (s5mx)
68 tmp << name << ".$" << setw(2) << setfill('0') << pid << '\0';
69 else
70 tmp << name << ".$" << pid << '\0';
71 return tmp.str().c_str();
72}
73
75setArgs(string _args) {
76 args = _args;
77}
78
80operator=(const PsiProcess &p) {
81 pid = p.pid;
82 name = p.name;
83 args = p.args;
84 s5mx = p.s5mx;
85 return *this;
86}
87
89operator<<(ostream &o, const PsiProcess &p) {
90 ostream::fmtflags old = o.flags();
91
92 o << dec << setw(5) << setfill(' ') << p.pid << " " << setw(12)
93 << setfill(' ') << setiosflags(ios::left) << p.name.c_str()
94 << resetiosflags(ios::left) << " " << p.args;
95 o.flags(old);
96 return o;
97}
A class, describing a Process on the Psion.
Definition: psiprocess.h:35
const char * getName()
Retrieve the file name of a process.
Definition: psiprocess.cc:54
void setArgs(std::string _args)
Definition: psiprocess.cc:75
std::string name
Definition: psiprocess.h:113
PsiProcess()
Default constructor.
Definition: psiprocess.cc:29
const char * getProcId()
Retrieve the file name and PID of a process.
Definition: psiprocess.cc:64
PsiProcess & operator=(const PsiProcess &p)
Assignment operator Mainly used by STL container classes.
Definition: psiprocess.cc:80
int getPID()
Retrieves the PID of a process.
Definition: psiprocess.cc:49
std::string args
Definition: psiprocess.h:114
const char * getArgs()
Retrieve the file name of a process.
Definition: psiprocess.cc:59
Definition: doctest.h:522
ostream & operator<<(ostream &o, const PsiProcess &p)
Definition: psiprocess.cc:89