RSB  0.17.0
Model.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the RSB project
4  *
5  * Copyright (C) 2014, 2015 Jan Moringen <jmoringe@techfak.uni-bielefeld.de>
6  *
7  * This file may be licensed under the terms of the
8  * GNU Lesser General Public License Version 3 (the ``LGPL''),
9  * or (at your option) any later version.
10  *
11  * Software distributed under the License is distributed
12  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
13  * express or implied. See the LGPL for the specific language
14  * governing rights and limitations.
15  *
16  * You should have received a copy of the LGPL along with this
17  * program. If not, go to http://www.gnu.org/licenses/lgpl.html
18  * or write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * The development of this software was supported by:
22  * CoR-Lab, Research Institute for Cognition and Robotics
23  * Bielefeld University
24  *
25  * ============================================================ */
26 
27 #pragma once
28 
29 #include <vector>
30 #include <string>
31 #include <set>
32 
33 #include <boost/date_time/posix_time/ptime.hpp>
34 
35 #include <rsc/misc/UUID.h>
36 #include <rsc/os/ProcessInfo.h>
37 #include <rsc/os/HostInfo.h>
38 
39 #include <rsb/Version.h>
40 #include <rsb/Scope.h>
41 
42 namespace rsb {
43 namespace introspection {
44 
45 // ParticipantInfo
46 
54 public:
55  ParticipantInfo(const std::string& kind,
56  const rsc::misc::UUID& id,
57  const rsc::misc::UUID& parentId,
58  const Scope& scope,
59  const std::string& type,
60  const std::set<std::string>& transportURLs);
61  virtual ~ParticipantInfo();
62 
63  const std::string& getKind() const;
64 
65  const rsc::misc::UUID& getId() const;
66 
67  const rsc::misc::UUID& getParentId() const;
68 
69  const Scope& getScope() const;
70 
71  const std::string& getType() const;
72 
73  const std::set<std::string>& getTransportURLs() const;
74 private:
75  std::string kind;
76  rsc::misc::UUID id;
77  rsc::misc::UUID parentId;
79  std::string type;
80  std::set<std::string> transportURLs;
81 };
82 
83 // ProcessInfo
84 
85 // Wrap non-essential RSC function which can throw exceptions.
86 std::string tryCurrentProgramName();
87 
88 std::vector<std::string> tryCurrentCommandlineArguments();
89 
90 boost::posix_time::ptime tryCurrentProcessStartTime();
91 
92 std::string tryCurrentExecutingUser();
93 
100 class ProcessInfo {
101 public:
102  ProcessInfo(unsigned int pid
103  = rsc::os::currentProcessId(),
104  const std::string& programName
106  const std::vector<std::string>& arguments
108  const boost::posix_time::ptime& startTime
110  const std::string& rsbVersion
111  = rsb::Version::string() + "-" + rsb::Version::buildId(),
112  const std::string& executingUser
114  virtual ~ProcessInfo();
115 
116  unsigned int getPid() const;
117 
118  const std::string& getProgramName() const;
119 
120  const std::vector<std::string>& getArguments() const;
121 
122  const boost::posix_time::ptime& getStartTime() const;
123 
124  const std::string& getRSBVersion() const;
125 
126  const std::string& getExecutingUser() const;
127 private:
128  unsigned int pid;
129  std::string programName;
130  std::vector<std::string> arguments;
131  boost::posix_time::ptime startTime;
132  std::string rsbVersion;
133  std::string executingUser;
134 };
135 
136 // HostInfo
137 
138 std::string tryCurrentHostId();
139 
140 std::string currentCompatibleHostId();
141 
142 std::string tryCurrentHostname();
143 
144 std::string tryCurrentMachineType();
145 
146 std::string tryCurrentMachineVersion();
147 
148 std::string tryCurrentSoftwareType();
149 
150 std::string tryCurrentSoftwareVersion();
151 
157 class HostInfo {
158 public:
159  HostInfo(const std::string& id = currentCompatibleHostId(),
160  const std::string& hostname = tryCurrentHostname(),
161  const std::string& machineType = tryCurrentMachineType(),
162  const std::string& machineVersion = tryCurrentMachineVersion(),
163  const std::string& softwareType = tryCurrentSoftwareType(),
164  const std::string& softwareVersion = tryCurrentSoftwareVersion());
165  virtual ~HostInfo();
166 
167  const std::string& getId() const;
168 
169  const std::string& getHostname() const;
170 
171  const std::string& getMachineType() const;
172 
173  const std::string& getMachineVersion() const;
174 
175  const std::string& getSoftwareType() const;
176 
177  const std::string& getSoftwareVersion() const;
178 private:
179  std::string id;
180  std::string hostname;
181  std::string machineType;
182  std::string machineVersion;
183  std::string softwareType;
184  std::string softwareVersion;
185 };
186 
187 }
188 }
boost::posix_time::ptime tryCurrentProcessStartTime()
Definition: Model.cpp:107
Instances of this class store information about participants in the current process.
Definition: Model.h:53
Instances of this class store information about the current process.
Definition: Model.h:100
std::string softwareVersion
Definition: Model.h:184
boost::posix_time::ptime startTime
Definition: Model.h:131
const std::string & getKind() const
Definition: Model.cpp:60
std::string tryCurrentMachineType()
Definition: Model.cpp:201
std::vector< std::string > arguments
Definition: Model.h:130
std::string tryCurrentExecutingUser()
Definition: Model.cpp:119
std::string currentCompatibleHostId()
Definition: Model.cpp:179
const std::string & getType() const
Definition: Model.cpp:76
std::string softwareType
Definition: Model.h:183
std::string tryCurrentSoftwareVersion()
Definition: Model.cpp:231
const std::set< std::string > & getTransportURLs() const
Definition: Model.cpp:80
const rsc::misc::UUID & getParentId() const
Definition: Model.cpp:68
std::set< std::string > transportURLs
Definition: Model.h:80
std::vector< std::string > tryCurrentCommandlineArguments()
Definition: Model.cpp:97
std::string machineType
Definition: Model.h:181
ParticipantInfo(const std::string &kind, const rsc::misc::UUID &id, const rsc::misc::UUID &parentId, const Scope &scope, const std::string &type, const std::set< std::string > &transportURLs)
Definition: Model.cpp:47
const Scope & getScope() const
Definition: Model.cpp:72
std::string tryCurrentMachineVersion()
Definition: Model.cpp:211
std::string tryCurrentHostId()
Definition: Model.cpp:169
Instances of this class store information about the local host.
Definition: Model.h:157
std::string machineVersion
Definition: Model.h:182
std::string tryCurrentSoftwareType()
Definition: Model.cpp:221
std::string tryCurrentProgramName()
Definition: Model.cpp:87
Scope is a descriptor for a hierarchical channel of the unified bus.
Definition: Scope.h:46
std::string tryCurrentHostname()
Definition: Model.cpp:191
const rsc::misc::UUID & getId() const
Definition: Model.cpp:64