libstorage-ng
Remote.h
1 /*
2  * Copyright (c) 2015 Novell, Inc.
3  * Copyright (c) 2019 SUSE LLC
4  *
5  * All Rights Reserved.
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of version 2 of the GNU General Public License as published
9  * by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, contact Novell, Inc.
18  *
19  * To contact Novell about this file by physical or electronic mail, you may
20  * find current contact information at www.novell.com.
21  */
22 
23 
24 #ifndef STORAGE_REMOTE_H
25 #define STORAGE_REMOTE_H
26 
27 
28 #include <string>
29 #include <vector>
30 
31 
32 // TODO the classnames are bad since the classes for also used in Mockup
33 // TODO swig does not support nested classes so here are currently ugly names
34 
35 namespace storage
36 {
37 
42  {
43  RemoteCommand() : stdout(), stderr(), exit_code(0) {}
44  RemoteCommand(const std::vector<std::string>& stdout)
45  : stdout(stdout), stderr(), exit_code(0) {}
46  RemoteCommand(const std::vector<std::string>& stdout,
47  const std::vector<std::string>& stderr, int exit_code)
48  : stdout(stdout), stderr(stderr), exit_code(exit_code) {}
49 
50  std::vector<std::string> stdout;
51  std::vector<std::string> stderr;
52  int exit_code;
53 
57  bool operator==(const RemoteCommand& rhs) const;
58  };
59 
60 
64  struct RemoteFile
65  {
66  RemoteFile() : content() {}
67  RemoteFile(const std::vector<std::string>& content) : content(content) {}
68 
69  std::vector<std::string> content;
70 
74  bool operator==(const RemoteFile& rhs) const;
75  };
76 
77 
79  {
80  public:
81 
82  virtual ~RemoteCallbacks() {}
83 
84  virtual RemoteCommand get_command(const std::string& name) const = 0;
85  virtual RemoteFile get_file(const std::string& name) const = 0;
86 
87  };
88 
89  const RemoteCallbacks* get_remote_callbacks();
90  void set_remote_callbacks(const RemoteCallbacks* remote_callbacks);
91 
92 }
93 
94 
95 #endif
bool operator==(const RemoteFile &rhs) const
Compare content of two Remotefiles.
Contents of an unnamed file (vector of lines)
Definition: Remote.h:64
A result of an unnamed command: stdout + stderr + exit_code.
Definition: Remote.h:41
Definition: Remote.h:78
The storage namespace.
Definition: Actiongraph.h:39
bool operator==(const RemoteCommand &rhs) const
Compare stdout, stderr and exit_code of two RemoteCommands.