new home directory
[feisty_meow.git] / nucleus / library / processes / process_entry.cpp
1 /*****************************************************************************\
2 *                                                                             *
3 *  Name   : process_entry                                                     *
4 *  Author : Chris Koeritz                                                     *
5 *                                                                             *
6 *******************************************************************************
7 * Copyright (c) 2000-$now By Author.  This program is free software; you can  *
8 * redistribute it and/or modify it under the terms of the GNU General Public  *
9 * License as published by the Free Software Foundation; either version 2 of   *
10 * the License or (at your option) any later version.  This is online at:      *
11 *     http://www.fsf.org/copyleft/gpl.html                                    *
12 * Please send any updates to: fred@gruntose.com                               *
13 \*****************************************************************************/
14
15 #include "process_entry.h"
16
17 #include <basis/array.h>
18 #include <basis/astring.h>
19 #include <filesystem/filename.h>
20
21 using namespace basis;
22 using namespace filesystem;
23
24 namespace processes {
25
26 process_entry::process_entry()
27 : _process_id(0),
28   _references(0),
29   _threads(0),
30   _parent_process_id(0),
31   _module16(0),
32   _process_path(new astring)
33 {}
34
35 process_entry::process_entry(const process_entry &to_copy)
36 : _process_id(0),
37   _references(0),
38   _threads(0),
39   _parent_process_id(0),
40   _module16(0),
41   _process_path(new astring)
42 {
43   operator =(to_copy);
44 }
45
46 process_entry::~process_entry()
47 {
48   WHACK(_process_path);
49 }
50
51 void process_entry::text_form(basis::base_string &fill) const
52 {
53   fill = text_form();
54 }
55
56 process_entry &process_entry::operator =(const process_entry &to_copy)
57 {
58   if (&to_copy == this) return *this;
59   _process_id = to_copy._process_id;
60   _references = to_copy._references;
61   _threads = to_copy._threads;
62   _parent_process_id = to_copy._parent_process_id;
63   *_process_path = *to_copy._process_path;
64   _module16 = to_copy._module16;
65   return *this;
66 }
67
68 const astring &process_entry::path() const { return *_process_path; }
69
70 void process_entry::path(const astring &new_path)
71 { *_process_path = new_path; }
72
73 astring process_entry::text_form() const
74 {
75 #ifdef __UNIX__
76   filename pat(path());
77 #else
78   filename pat(path().lower());
79 #endif
80   return a_sprintf("%s: pid=%u refs=%u thrd=%u par=%u mod16=%u path=%s",
81       pat.basename().raw().s(), _process_id, _references, _threads,
82       _parent_process_id, _module16, pat.dirname().raw().s());
83 }
84
85 } //namespace.
86