RSB  0.12.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 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 
32 #include <boost/date_time/posix_time/ptime.hpp>
33 
34 #include <rsc/misc/UUID.h>
35 #include <rsc/os/ProcessInfo.h>
36 #include <rsc/os/HostInfo.h>
37 
38 #include <rsb/Version.h>
39 #include <rsb/Scope.h>
40 
41 namespace rsb {
42 namespace introspection {
43 
44 // ParticipantInfo
45 
53 public:
54  ParticipantInfo(const std::string& kind,
55  const rsc::misc::UUID& id,
56  const rsc::misc::UUID& parentId,
57  const Scope& scope,
58  const std::string& type);
59  virtual ~ParticipantInfo();
60 
61  const std::string& getKind() const;
62 
63  const rsc::misc::UUID& getId() const;
64 
65  const rsc::misc::UUID& getParentId() const;
66 
67  const Scope& getScope() const;
68 
69  const std::string& getType() const;
70 private:
71  std::string kind;
72  rsc::misc::UUID id;
73  rsc::misc::UUID parentId;
75  std::string type;
76 };
77 
78 // ProcessInfo
79 
80 // Wrap non-essential RSC function which can throw exceptions.
81 std::string tryCurrentProgramName();
82 
83 std::vector<std::string> tryCurrentCommandlineArguments();
84 
85 boost::posix_time::ptime tryCurrentProcessStartTime();
86 
87 std::string tryCurrentExecutingUser();
88 
95 class ProcessInfo {
96 public:
97  ProcessInfo(unsigned int pid
98  = rsc::os::currentProcessId(),
99  const std::string& programName
101  const std::vector<std::string>& arguments
103  const boost::posix_time::ptime& startTime
105  const std::string& rsbVersion
106  = rsb::Version::string() + "-" + rsb::Version::buildId(),
107  const std::string& executingUser
109  virtual ~ProcessInfo();
110 
111  unsigned int getPid() const;
112 
113  const std::string& getProgramName() const;
114 
115  const std::vector<std::string>& getArguments() const;
116 
117  const boost::posix_time::ptime& getStartTime() const;
118 
119  const std::string& getRSBVersion() const;
120 
121  const std::string& getExecutingUser() const;
122 private:
123  unsigned int pid;
124  std::string programName;
125  std::vector<std::string> arguments;
126  boost::posix_time::ptime startTime;
127  std::string rsbVersion;
128  std::string executingUser;
129 };
130 
131 // HostInfo
132 
133 std::string tryCurrentHostId();
134 
135 std::string currentCompatibleHostId();
136 
137 std::string tryCurrentHostname();
138 
139 std::string tryCurrentMachineType();
140 
141 std::string tryCurrentMachineVersion();
142 
143 std::string tryCurrentSoftwareType();
144 
145 std::string tryCurrentSoftwareVersion();
146 
152 class HostInfo {
153 public:
154  HostInfo(const std::string& id = currentCompatibleHostId(),
155  const std::string& hostname = tryCurrentHostname(),
156  const std::string& machineType = tryCurrentMachineType(),
157  const std::string& machineVersion = tryCurrentMachineVersion(),
158  const std::string& softwareType = tryCurrentSoftwareType(),
159  const std::string& softwareVersion = tryCurrentSoftwareVersion());
160  virtual ~HostInfo();
161 
162  const std::string& getId() const;
163 
164  const std::string& getHostname() const;
165 
166  const std::string& getMachineType() const;
167 
168  const std::string& getMachineVersion() const;
169 
170  const std::string& getSoftwareType() const;
171 
172  const std::string& getSoftwareVersion() const;
173 private:
174  std::string id;
175  std::string hostname;
176  std::string machineType;
177  std::string machineVersion;
178  std::string softwareType;
179  std::string softwareVersion;
180 };
181 
182 }
183 }
unsigned int getPid() const
Definition: Model.cpp:136
boost::posix_time::ptime tryCurrentProcessStartTime()
Definition: Model.cpp:100
Instances of this class store information about participants in the current process.
Definition: Model.h:52
const std::string & getMachineType() const
Definition: Model.cpp:256
HostInfo(const std::string &id=currentCompatibleHostId(), const std::string &hostname=tryCurrentHostname(), const std::string &machineType=tryCurrentMachineType(), const std::string &machineVersion=tryCurrentMachineVersion(), const std::string &softwareType=tryCurrentSoftwareType(), const std::string &softwareVersion=tryCurrentSoftwareVersion())
Definition: Model.cpp:234
Instances of this class store information about the current process.
Definition: Model.h:95
std::string softwareVersion
Definition: Model.h:179
boost::posix_time::ptime startTime
Definition: Model.h:126
const std::string & getKind() const
Definition: Model.cpp:58
std::string tryCurrentMachineType()
Definition: Model.cpp:194
std::vector< std::string > arguments
Definition: Model.h:125
std::string tryCurrentExecutingUser()
Definition: Model.cpp:112
std::string currentCompatibleHostId()
Definition: Model.cpp:172
const std::string & getHostname() const
Definition: Model.cpp:252
const std::string & getType() const
Definition: Model.cpp:74
std::string softwareType
Definition: Model.h:178
std::string tryCurrentSoftwareVersion()
Definition: Model.cpp:224
const std::string & getProgramName() const
Definition: Model.cpp:140
const rsc::misc::UUID & getParentId() const
Definition: Model.cpp:66
const std::string & getSoftwareType() const
Definition: Model.cpp:264
std::vector< std::string > tryCurrentCommandlineArguments()
Definition: Model.cpp:90
const std::vector< std::string > & getArguments() const
Definition: Model.cpp:144
const std::string & getRSBVersion() const
Definition: Model.cpp:152
const std::string & getExecutingUser() const
Definition: Model.cpp:156
std::string machineType
Definition: Model.h:176
const std::string & getMachineVersion() const
Definition: Model.cpp:260
const Scope & getScope() const
Definition: Model.cpp:70
std::string tryCurrentMachineVersion()
Definition: Model.cpp:204
std::string tryCurrentHostId()
Definition: Model.cpp:162
Instances of this class store information about the local host.
Definition: Model.h:152
const std::string & getSoftwareVersion() const
Definition: Model.cpp:268
const std::string & getId() const
Definition: Model.cpp:248
std::string machineVersion
Definition: Model.h:177
std::string tryCurrentSoftwareType()
Definition: Model.cpp:214
std::string tryCurrentProgramName()
Definition: Model.cpp:80
Scope is a descriptor for a hierarchical channel of the unified bus.
Definition: Scope.h:46
ParticipantInfo(const std::string &kind, const rsc::misc::UUID &id, const rsc::misc::UUID &parentId, const Scope &scope, const std::string &type)
Definition: Model.cpp:47
const boost::posix_time::ptime & getStartTime() const
Definition: Model.cpp:148
ProcessInfo(unsigned int pid=rsc::os::currentProcessId(), const std::string &programName=tryCurrentProgramName(), const std::vector< std::string > &arguments=tryCurrentCommandlineArguments(), const boost::posix_time::ptime &startTime=tryCurrentProcessStartTime(), const std::string &rsbVersion=rsb::Version::string()+"-"+rsb::Version::buildId(), const std::string &executingUser=tryCurrentExecutingUser())
Definition: Model.cpp:122
std::string tryCurrentHostname()
Definition: Model.cpp:184
const rsc::misc::UUID & getId() const
Definition: Model.cpp:62