ProfilerEvent.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::Core
19  * @author Manfred Kroehnert (Manfred dot Kroehnert at kit dot edu)
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include "ProfilerEvent.h"
26 
27 
28 namespace memoryx
29 {
30 
32  Entity()
33  {
34  initializeAttributes();
35  }
36 
37 
38  ProfilerEvent::ProfilerEvent(const armarx::ProfilerEvent& event)
39  {
40  initializeAttributes();
41  setProfilerEvent(event);
42  }
43 
44 
46  IceUtil::Shared(source),
47  ::armarx::Serializable(source),
48  EntityBase(),// dont copy
49  ProfilerEntityBase(source),
50  ProfilerEventBase(source),
51  Entity(source),
53  {
54  }
55 
56 
58  {
59  }
60 
61 
62  void ProfilerEvent::initializeAttributes()
63  {
64  putAttribute(new EntityAttribute("pid"));
65  putAttribute(new EntityAttribute("executableName"));
66  putAttribute(new EntityAttribute("timestamp"));
67  putAttribute(new EntityAttribute("timestampUnit"));
68  putAttribute(new EntityAttribute("eventName"));
69  putAttribute(new EntityAttribute("parentName"));
70  putAttribute(new EntityAttribute("functionName"));
71  }
72 
73 
74  void ProfilerEvent::output(std::ostream& stream) const
75  {
76  Entity::output(stream);
77  }
78 
79 
81  {
82  return this->clone();
83  }
84 
85 
86  ProfilerEntityPtr ProfilerEvent::clone(const Ice::Current& context) const
87  {
88  std::shared_lock entityLock(entityMutex);
89  std::scoped_lock attributesLock(attributesMutex);
90  std::scoped_lock wrappersLock(wrappersMutex);
91  ProfilerEntityPtr ret = new ProfilerEvent(*this);
92  return ret;
93  }
94 
95  void ProfilerEvent::setProfilerEvent(const armarx::ProfilerEvent& event)
96  {
97  setPid(event.processId);
98  setExecutableName(event.executableName);
99  setTimestamp(event.timestamp);
100  setTimestampUnit(event.timestampUnit);
101  setEventName(event.eventName);
102  setParentName(event.parentName);
103  setFunctionName(event.functionName);
104  }
105 
106 
107  Ice::Int ProfilerEvent::getPid(const Ice::Current& c) const
108  {
109  return getAttribute("pid")->getValue()->getInt();
110  }
111 
112 
113  void ProfilerEvent::setPid(Ice::Int pid, const Ice::Current& c)
114  {
115  getAttribute("pid")->setValue(new armarx::Variant(pid));
116  }
117 
118 
119  std::string ProfilerEvent::getExecutableName(const Ice::Current& c) const
120  {
121  return getAttribute("executableName")->getValue()->getString();
122  }
123 
124 
125  void ProfilerEvent::setExecutableName(const std::string& executableName, const Ice::Current& c)
126  {
127  getAttribute("executableName")->setValue(new armarx::Variant(executableName));
128  }
129 
130 
131  Ice::Int ProfilerEvent::getTimestamp(const Ice::Current& c) const
132  {
133  return getAttribute("timestamp")->getValue()->getInt();
134  }
135 
136 
137  void ProfilerEvent::setTimestamp(Ice::Int timestamp, const Ice::Current& c)
138  {
139  getAttribute("timestamp")->setValue(new armarx::Variant(timestamp));
140  }
141 
142 
143  std::string ProfilerEvent::getTimestampUnit(const Ice::Current& c) const
144  {
145  return getAttribute("timestampUnit")->getValue()->getString();
146  }
147 
148 
149  void ProfilerEvent::setTimestampUnit(const std::string& unit, const Ice::Current& c)
150  {
151  getAttribute("timestampUnit")->setValue(new armarx::Variant(unit));
152  }
153 
154 
155  std::string ProfilerEvent::getEventName(const Ice::Current& c) const
156  {
157  return getAttribute("eventName")->getValue()->getString();
158  }
159 
160 
161  void ProfilerEvent::setEventName(const std::string& eventName, const Ice::Current& c)
162  {
163  getAttribute("eventName")->setValue(new armarx::Variant(eventName));
164  setName(eventName);
165  }
166 
167 
168  std::string ProfilerEvent::getParentName(const Ice::Current& c) const
169  {
170  return getAttribute("parentName")->getValue()->getString();
171  }
172 
173 
174  void ProfilerEvent::setParentName(const std::string& parentName, const Ice::Current& c)
175  {
176  getAttribute("parentName")->setValue(new armarx::Variant(parentName));
177  }
178 
179 
180  std::string ProfilerEvent::getFunctionName(const Ice::Current& c) const
181  {
182  return getAttribute("functionName")->getValue()->getString();
183  }
184 
185 
186  void ProfilerEvent::setFunctionName(const std::string& functionName, const Ice::Current& c)
187  {
188  getAttribute("functionName")->setValue(new armarx::Variant(functionName));
189  }
190 }
191 
192 
memoryx::ProfilerEvent::ProfilerEvent
ProfilerEvent()
Definition: ProfilerEvent.cpp:31
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
memoryx::ProfilerEvent::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: ProfilerEvent.cpp:80
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
memoryx::Entity::putAttribute
void putAttribute(const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override
Store attribute in entity.
Definition: Entity.cpp:327
memoryx::ProfilerEvent::setProfilerEvent
void setProfilerEvent(const armarx::ProfilerEvent &event)
Definition: ProfilerEvent.cpp:95
memoryx::ProfilerEvent::setExecutableName
void setExecutableName(const std::string &executableName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:125
memoryx::Entity::getAttribute
EntityAttributeBasePtr getAttribute(const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve attribute from entity.
Definition: Entity.cpp:293
memoryx::ProfilerEvent::setTimestamp
void setTimestamp(Ice::Int timestamp, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:137
memoryx::ProfilerEvent::getParentName
std::string getParentName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:168
memoryx::ProfilerEvent
Definition: ProfilerEvent.h:40
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
memoryx::ProfilerEvent::clone
ProfilerEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: ProfilerEvent.cpp:86
memoryx::ProfilerEntity
Definition: ProfilerEntity.h:36
IceUtil
Definition: Instance.h:21
memoryx::Entity::output
void output(std::ostream &stream) const
Definition: Entity.cpp:409
memoryx::ProfilerEvent::~ProfilerEvent
~ProfilerEvent() override
Definition: ProfilerEvent.cpp:57
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::ProfilerEvent::getTimestampUnit
std::string getTimestampUnit(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:143
memoryx::ProfilerEvent::getExecutableName
std::string getExecutableName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:119
memoryx::ProfilerEvent::setParentName
void setParentName(const std::string &parentName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:174
memoryx::Entity::attributesMutex
std::mutex attributesMutex
Definition: Entity.h:504
memoryx::ProfilerEvent::getPid
Ice::Int getPid(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:107
memoryx::ProfilerEvent::getTimestamp
Ice::Int getTimestamp(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:131
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
ProfilerEvent.h
memoryx::Entity::entityMutex
std::shared_mutex entityMutex
Definition: Entity.h:505
memoryx::ProfilerEvent::setTimestampUnit
void setTimestampUnit(const std::string &unit, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:149
memoryx::ProfilerEvent::getFunctionName
std::string getFunctionName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:180
memoryx::EntityAttribute
Attribute of MemoryX entities.
Definition: EntityAttribute.h:48
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
memoryx::ProfilerEvent::setPid
void setPid(Ice::Int pid, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:113
memoryx::ProfilerEvent::setEventName
void setEventName(const std::string &eventName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:161
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::Entity
Definition: Entity.h:246
memoryx::Entity::setName
void setName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) override
Set name of this entity.
Definition: Entity.cpp:179
memoryx::Entity::wrappersMutex
std::recursive_mutex wrappersMutex
Definition: Entity.h:506
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
memoryx::ProfilerEvent::setFunctionName
void setFunctionName(const std::string &functionName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:186
memoryx::ProfilerEvent::getEventName
std::string getEventName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:155