Nemiver  0.3
nmv-proc-mgr.h
Go to the documentation of this file.
1 // Author: Dodji Seketeli
2 /*
3  *This file is part of the Nemiver project
4  *
5  *Nemiver is free software; you can redistribute
6  *it and/or modify it under the terms of
7  *the GNU General Public License as published by the
8  *Free Software Foundation; either version 2,
9  *or (at your option) any later version.
10  *
11  *Nemiver is distributed in the hope that it will
12  *be useful, but WITHOUT ANY WARRANTY;
13  *without even the implied warranty of
14  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *See the GNU General Public License for more details.
16  *
17  *You should have received a copy of the
18  *GNU General Public License along with Nemiver;
19  *see the file COPYING.
20  *If not, write to the Free Software Foundation,
21  *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  *See COPYRIGHT file copyright information.
24  */
25 
26 #ifndef __NMV_PROC_MGR_H__
27 #define __NMV_PROC_MGR_H__
28 
29 #include <sys/types.h>
30 #include <pwd.h>
31 #include <list>
32 #include "nmv-object.h"
33 #include "nmv-ustring.h"
34 #include "nmv-safe-ptr-utils.h"
35 
36 using std::list;
42 
43 NEMIVER_BEGIN_NAMESPACE (nemiver)
44 NEMIVER_BEGIN_NAMESPACE (common)
45 
46 class IProcMgr;
48 
49 class NEMIVER_API IProcMgr : public Object {
50  //non copyable
51  IProcMgr (const IProcMgr &);
52  IProcMgr& operator= (const IProcMgr &);
53 
54 protected:
55  IProcMgr () {}
56 
57 public:
58 
59  class Process {
60  unsigned int m_pid;
61  unsigned int m_ppid;
62  unsigned int m_uid;
63  unsigned int m_euid;
64  UString m_user_name;
65  list<UString> m_args;
66 
67  public:
68 
69  Process () :
70  m_pid (0),
71  m_ppid (0),
72  m_uid (0),
73  m_euid (0)
74  {}
75 
76  Process (unsigned int a_pid, const list<UString> a_args) :
77  m_pid (a_pid),
78  m_ppid (0),
79  m_uid (0),
80  m_euid (0),
81  m_args (a_args)
82  {}
83 
84  Process (unsigned int a_pid) :
85  m_pid (a_pid),
86  m_ppid (0),
87  m_uid (0),
88  m_euid (0)
89  {}
90 
91  unsigned int pid () const {return m_pid;}
92  void pid (unsigned int a_pid) {m_pid = a_pid;}
93 
94  unsigned int ppid () const {return m_ppid;}
95  void ppid (unsigned int a_ppid) {m_ppid = a_ppid;}
96 
97  unsigned int uid () const {return m_uid;}
98  void uid (unsigned int a_uid) {m_uid = a_uid;}
99 
100  unsigned int euid () const {return m_euid;}
101  void euid (unsigned int a_euid) {m_euid = a_euid;}
102 
103  const UString& user_name () const {return m_user_name;}
104  void user_name (const UString &a_name) {m_user_name = a_name;}
105 
106  const list<UString>& args () const {return m_args;}
107  list<UString>& args () {return m_args;}
108  void args (const list<UString> &a_in) {m_args = a_in;}
109 
110  bool operator== (const Process &an_other)
111  {
112  if (pid () == an_other.pid ()
113  && ppid () == an_other.ppid ()
114  && uid () == an_other.uid ()
115  && euid () == an_other.euid ()) {
116  return true;
117  }
118  return false;
119  }
120  };//end class Process
121 
122  virtual ~IProcMgr () {}
123  static IProcMgrSafePtr create ();
124  virtual const list<Process>& get_all_process_list () const = 0;
125  virtual bool get_process_from_pid (pid_t a_pid,
126  Process &a_process) const = 0;
127  virtual bool get_process_from_name
128  (const UString &a_pname,
129  Process &a_process,
130  bool a_fuzzy_search=false) const = 0;
131 };//end IProcMgr
132 
133 NEMIVER_END_NAMESPACE (common)
134 NEMIVER_END_NAMESPACE (nemiver)
135 
136 #endif //__NMV_PROC_MGR_H__
137 
nmv-safe-ptr-utils.h
nemiver::common::IProcMgr::Process::ppid
void ppid(unsigned int a_ppid)
Definition: nmv-proc-mgr.h:95
nemiver::common::IProcMgr::Process::args
list< UString > & args()
Definition: nmv-proc-mgr.h:107
nemiver::common::Object
Definition: nmv-object.h:43
nemiver::common::IProcMgr::~IProcMgr
virtual ~IProcMgr()
Definition: nmv-proc-mgr.h:122
nemiver
Definition: nmv-address.h:31
nemiver::common::ObjectRef
Definition: nmv-safe-ptr-utils.h:45
nemiver::common::IProcMgr::Process::Process
Process(unsigned int a_pid)
Definition: nmv-proc-mgr.h:84
nemiver::common::IProcMgr::Process
Definition: nmv-proc-mgr.h:59
nmv-ustring.h
NEMIVER_API
#define NEMIVER_API
Definition: nmv-api-macros.h:53
nemiver::common::IProcMgr::Process::Process
Process(unsigned int a_pid, const list< UString > a_args)
Definition: nmv-proc-mgr.h:76
nemiver::common::IProcMgr::Process::user_name
const UString & user_name() const
Definition: nmv-proc-mgr.h:103
nemiver::common::IProcMgr::Process::args
const list< UString > & args() const
Definition: nmv-proc-mgr.h:106
nemiver::common::IProcMgr::Process::pid
unsigned int pid() const
Definition: nmv-proc-mgr.h:91
nemiver::common::IProcMgr::Process::euid
void euid(unsigned int a_euid)
Definition: nmv-proc-mgr.h:101
nemiver::common::UString
Definition: nmv-ustring.h:45
nemiver::common::IProcMgr::Process::uid
void uid(unsigned int a_uid)
Definition: nmv-proc-mgr.h:98
nemiver::common::IProcMgr::Process::args
void args(const list< UString > &a_in)
Definition: nmv-proc-mgr.h:108
nemiver::common::IProcMgr::Process::euid
unsigned int euid() const
Definition: nmv-proc-mgr.h:100
nemiver::common::IProcMgr
Definition: nmv-proc-mgr.h:49
nemiver::common::IProcMgr::Process::Process
Process()
Definition: nmv-proc-mgr.h:69
nemiver::common::IProcMgr::Process::user_name
void user_name(const UString &a_name)
Definition: nmv-proc-mgr.h:104
nemiver::common::IProcMgr::Process::uid
unsigned int uid() const
Definition: nmv-proc-mgr.h:97
nemiver::common::IProcMgr::IProcMgr
IProcMgr()
Definition: nmv-proc-mgr.h:55
nemiver::common::ObjectUnref
Definition: nmv-safe-ptr-utils.h:55
nmv-object.h
nemiver::common::SafePtr
Definition: nmv-safe-ptr.h:71
nemiver::common::IProcMgr::Process::ppid
unsigned int ppid() const
Definition: nmv-proc-mgr.h:94
nemiver::common::IProcMgr::Process::pid
void pid(unsigned int a_pid)
Definition: nmv-proc-mgr.h:92
common
Definition: nmv-proc-list-dialog.h:32