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
27namespace 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),
48 ProfilerEntity(source)
49 {
50 }
51
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
74 Ice::ObjectPtr
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
std::string timestamp()
constexpr T c
The Variant class is described here: Variants.
Definition Variant.h:224
Attribute of MemoryX entities.
Entity is the superclass for all MemoryX memory chunks.
Definition Entity.h:246
EntityAttributeBasePtr getAttribute(const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve attribute from entity.
Definition Entity.cpp:311
void setName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) override
Set name of this entity.
Definition Entity.cpp:188
std::mutex attributesMutex
Definition Entity.h:524
std::recursive_mutex wrappersMutex
Definition Entity.h:526
void output(std::ostream &stream) const
Definition Entity.cpp:436
void putAttribute(const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override
Store attribute in entity.
Definition Entity.cpp:347
std::shared_mutex entityMutex
Definition Entity.h:525
std::string getTimestampUnit(const Ice::Current &c=Ice::emptyCurrent) const override
void setTimestampUnit(const std::string &unit, const Ice::Current &c=Ice::emptyCurrent) override
void setTimestamp(Ice::Int timestamp, const Ice::Current &c=Ice::emptyCurrent) override
std::string getFunctionName(const Ice::Current &c=Ice::emptyCurrent) const override
std::string getParentName(const Ice::Current &c=Ice::emptyCurrent) const override
Ice::Int getPid(const Ice::Current &c=Ice::emptyCurrent) const override
ProfilerEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
void setFunctionName(const std::string &functionName, const Ice::Current &c=Ice::emptyCurrent) override
Ice::ObjectPtr ice_clone() const override
void setParentName(const std::string &parentName, const Ice::Current &c=Ice::emptyCurrent) override
void setPid(Ice::Int pid, const Ice::Current &c=Ice::emptyCurrent) override
std::string getEventName(const Ice::Current &c=Ice::emptyCurrent) const override
void setExecutableName(const std::string &executableName, const Ice::Current &c=Ice::emptyCurrent) override
std::string getExecutableName(const Ice::Current &c=Ice::emptyCurrent) const override
void setProfilerEvent(const armarx::ProfilerEvent &event)
Ice::Int getTimestamp(const Ice::Current &c=Ice::emptyCurrent) const override
void setEventName(const std::string &eventName, const Ice::Current &c=Ice::emptyCurrent) override
This file offers overloads of toIce() and fromIce() functions for STL container types.
VirtualRobot headers.
IceInternal::Handle< ProfilerEntity > ProfilerEntityPtr