aboutsummaryrefslogtreecommitdiff
path: root/brillo/process_information.h
blob: 3f0a2c9d4cf11a9a97c23d3e0ab6bf1592617a39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBBRILLO_BRILLO_PROCESS_INFORMATION_H_
#define LIBBRILLO_BRILLO_PROCESS_INFORMATION_H_

#include <set>
#include <string>
#include <vector>

#include <brillo/brillo_export.h>

namespace brillo {

// Information for a single running process. Stores its command line, set of
// open files, process id and working directory.
class BRILLO_EXPORT ProcessInformation {
 public:
  ProcessInformation();
  virtual ~ProcessInformation();

  std::string GetCommandLine();

  // Set the command line array.  This method DOES swap out the contents of
  // |value|.  The caller should expect an empty vector on return.
  void set_cmd_line(std::vector<std::string>* value) {
    cmd_line_.clear();
    cmd_line_.swap(*value);
  }

  const std::vector<std::string>& get_cmd_line() { return cmd_line_; }

  // Set the command line array.  This method DOES swap out the contents of
  // |value|.  The caller should expect an empty set on return.
  void set_open_files(std::set<std::string>* value) {
    open_files_.clear();
    open_files_.swap(*value);
  }

  const std::set<std::string>& get_open_files() { return open_files_; }

  // Set the command line array.  This method DOES swap out the contents of
  // |value|.  The caller should expect an empty string on return.
  void set_cwd(std::string* value) {
    cwd_.clear();
    cwd_.swap(*value);
  }

  const std::string& get_cwd() { return cwd_; }

  void set_process_id(int value) { process_id_ = value; }

  int get_process_id() { return process_id_; }

 private:
  std::vector<std::string> cmd_line_;
  std::set<std::string> open_files_;
  std::string cwd_;
  int process_id_;
};

}  // namespace brillo

#endif  // LIBBRILLO_BRILLO_PROCESS_INFORMATION_H_