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 namespace memoryx
28 {
29 
31  {
32  initializeAttributes();
33  }
34 
35  ProfilerEvent::ProfilerEvent(const armarx::ProfilerEvent& event)
36  {
37  initializeAttributes();
38  setProfilerEvent(event);
39  }
40 
42  IceUtil::Shared(source),
43  ::armarx::Serializable(source),
44  EntityBase(), // dont copy
45  ProfilerEntityBase(source),
46  ProfilerEventBase(source),
47  Entity(source),
49  {
50  }
51 
53  {
54  }
55 
56  void
57  ProfilerEvent::initializeAttributes()
58  {
59  putAttribute(new EntityAttribute("pid"));
60  putAttribute(new EntityAttribute("executableName"));
61  putAttribute(new EntityAttribute("timestamp"));
62  putAttribute(new EntityAttribute("timestampUnit"));
63  putAttribute(new EntityAttribute("eventName"));
64  putAttribute(new EntityAttribute("parentName"));
65  putAttribute(new EntityAttribute("functionName"));
66  }
67 
68  void
69  ProfilerEvent::output(std::ostream& stream) const
70  {
71  Entity::output(stream);
72  }
73 
76  {
77  return this->clone();
78  }
79 
81  ProfilerEvent::clone(const Ice::Current& context) const
82  {
83  std::shared_lock entityLock(entityMutex);
84  std::scoped_lock attributesLock(attributesMutex);
85  std::scoped_lock wrappersLock(wrappersMutex);
86  ProfilerEntityPtr ret = new ProfilerEvent(*this);
87  return ret;
88  }
89 
90  void
91  ProfilerEvent::setProfilerEvent(const armarx::ProfilerEvent& event)
92  {
93  setPid(event.processId);
94  setExecutableName(event.executableName);
95  setTimestamp(event.timestamp);
96  setTimestampUnit(event.timestampUnit);
97  setEventName(event.eventName);
98  setParentName(event.parentName);
99  setFunctionName(event.functionName);
100  }
101 
102  Ice::Int
103  ProfilerEvent::getPid(const Ice::Current& c) const
104  {
105  return getAttribute("pid")->getValue()->getInt();
106  }
107 
108  void
109  ProfilerEvent::setPid(Ice::Int pid, const Ice::Current& c)
110  {
111  getAttribute("pid")->setValue(new armarx::Variant(pid));
112  }
113 
114  std::string
115  ProfilerEvent::getExecutableName(const Ice::Current& c) const
116  {
117  return getAttribute("executableName")->getValue()->getString();
118  }
119 
120  void
121  ProfilerEvent::setExecutableName(const std::string& executableName, const Ice::Current& c)
122  {
123  getAttribute("executableName")->setValue(new armarx::Variant(executableName));
124  }
125 
126  Ice::Int
127  ProfilerEvent::getTimestamp(const Ice::Current& c) const
128  {
129  return getAttribute("timestamp")->getValue()->getInt();
130  }
131 
132  void
133  ProfilerEvent::setTimestamp(Ice::Int timestamp, const Ice::Current& c)
134  {
135  getAttribute("timestamp")->setValue(new armarx::Variant(timestamp));
136  }
137 
138  std::string
139  ProfilerEvent::getTimestampUnit(const Ice::Current& c) const
140  {
141  return getAttribute("timestampUnit")->getValue()->getString();
142  }
143 
144  void
145  ProfilerEvent::setTimestampUnit(const std::string& unit, const Ice::Current& c)
146  {
147  getAttribute("timestampUnit")->setValue(new armarx::Variant(unit));
148  }
149 
150  std::string
151  ProfilerEvent::getEventName(const Ice::Current& c) const
152  {
153  return getAttribute("eventName")->getValue()->getString();
154  }
155 
156  void
157  ProfilerEvent::setEventName(const std::string& eventName, const Ice::Current& c)
158  {
159  getAttribute("eventName")->setValue(new armarx::Variant(eventName));
160  setName(eventName);
161  }
162 
163  std::string
164  ProfilerEvent::getParentName(const Ice::Current& c) const
165  {
166  return getAttribute("parentName")->getValue()->getString();
167  }
168 
169  void
170  ProfilerEvent::setParentName(const std::string& parentName, const Ice::Current& c)
171  {
172  getAttribute("parentName")->setValue(new armarx::Variant(parentName));
173  }
174 
175  std::string
176  ProfilerEvent::getFunctionName(const Ice::Current& c) const
177  {
178  return getAttribute("functionName")->getValue()->getString();
179  }
180 
181  void
182  ProfilerEvent::setFunctionName(const std::string& functionName, const Ice::Current& c)
183  {
184  getAttribute("functionName")->setValue(new armarx::Variant(functionName));
185  }
186 } // namespace memoryx
memoryx::ProfilerEvent::ProfilerEvent
ProfilerEvent()
Definition: ProfilerEvent.cpp:30
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:223
memoryx::ProfilerEvent::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: ProfilerEvent.cpp:75
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:13
memoryx::Entity::putAttribute
void putAttribute(const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override
Store attribute in entity.
Definition: Entity.cpp:347
memoryx::ProfilerEvent::setProfilerEvent
void setProfilerEvent(const armarx::ProfilerEvent &event)
Definition: ProfilerEvent.cpp:91
memoryx::ProfilerEvent::setExecutableName
void setExecutableName(const std::string &executableName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:121
memoryx::Entity::getAttribute
EntityAttributeBasePtr getAttribute(const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve attribute from entity.
Definition: Entity.cpp:311
memoryx::ProfilerEvent::setTimestamp
void setTimestamp(Ice::Int timestamp, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:133
memoryx::ProfilerEvent::getParentName
std::string getParentName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:164
memoryx::ProfilerEvent
Definition: ProfilerEvent.h:38
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::ProfilerEvent::clone
ProfilerEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: ProfilerEvent.cpp:81
memoryx::ProfilerEntity
Definition: ProfilerEntity.h:36
IceUtil
Definition: Instance.h:21
memoryx::Entity::output
void output(std::ostream &stream) const
Definition: Entity.cpp:436
memoryx::ProfilerEvent::~ProfilerEvent
~ProfilerEvent() override
Definition: ProfilerEvent.cpp:52
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::ProfilerEvent::getTimestampUnit
std::string getTimestampUnit(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:139
memoryx::ProfilerEvent::getExecutableName
std::string getExecutableName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:115
memoryx::ProfilerEvent::setParentName
void setParentName(const std::string &parentName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:170
memoryx::Entity::attributesMutex
std::mutex attributesMutex
Definition: Entity.h:524
memoryx::ProfilerEvent::getPid
Ice::Int getPid(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:103
memoryx::ProfilerEvent::getTimestamp
Ice::Int getTimestamp(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:127
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:661
ProfilerEvent.h
memoryx::Entity::entityMutex
std::shared_mutex entityMutex
Definition: Entity.h:525
memoryx::ProfilerEvent::setTimestampUnit
void setTimestampUnit(const std::string &unit, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:145
memoryx::ProfilerEvent::getFunctionName
std::string getFunctionName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:176
memoryx::EntityAttribute
Attribute of MemoryX entities.
Definition: EntityAttribute.h:49
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:917
memoryx::ProfilerEvent::setPid
void setPid(Ice::Int pid, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:109
memoryx::ProfilerEvent::setEventName
void setEventName(const std::string &eventName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:157
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::Entity
Definition: Entity.h:245
memoryx::Entity::setName
void setName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) override
Set name of this entity.
Definition: Entity.cpp:188
memoryx::Entity::wrappersMutex
std::recursive_mutex wrappersMutex
Definition: Entity.h:526
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
memoryx::ProfilerEvent::setFunctionName
void setFunctionName(const std::string &functionName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerEvent.cpp:182
memoryx::ProfilerEvent::getEventName
std::string getEventName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerEvent.cpp:151