ProfilerProcess.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 Lesser 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 Adil Orhan (ubdnw at student dot kit dot edu)
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl.txt
22  * GNU General Public License
23  */
24 
25 #include "ProfilerProcess.h"
26 
27 namespace memoryx
28 {
29 
31  {
32  initializeAttributes();
33  }
34 
35  ProfilerProcess::ProfilerProcess(const armarx::ProfilerProcessCpuUsage& process)
36  {
37  initializeAttributes();
38  setProfilerProcess(process);
39  }
40 
42  IceUtil::Shared(source),
43  ::armarx::Serializable(source),
44  EntityBase(),
45  ProfilerEntityBase(source),
46  ProfilerProcessBase(source),
47  Entity(source),
49  {
50  }
51 
53  {
54  }
55 
56  void
57  ProfilerProcess::initializeAttributes()
58  {
59  putAttribute(new EntityAttribute("pid"));
60  putAttribute(new EntityAttribute("processName"));
61  putAttribute(new EntityAttribute("timestamp"));
62  putAttribute(new EntityAttribute("processCpuUsage"));
63  }
64 
67  {
68  return this->clone();
69  }
70 
72  ProfilerProcess::clone(const Ice::Current& c) const
73  {
74  std::shared_lock entityLock(entityMutex);
75  std::scoped_lock attributesLock(attributesMutex);
76  std::scoped_lock wrappersLock(wrappersMutex);
78  return ret;
79  }
80 
81  void
82  ProfilerProcess::setProfilerProcess(const armarx::ProfilerProcessCpuUsage& process)
83  {
84  setPid(process.processId);
85  setProcessName(process.processName);
86  setTimestamp(process.timestamp);
87  setProcessCpuUsage(process.cpuUsage);
88  }
89 
90  Ice::Int
91  ProfilerProcess::getPid(const Ice::Current& c) const
92  {
93  return getAttribute("pid")->getValue()->getInt();
94  }
95 
96  void
97  ProfilerProcess::setPid(Ice::Int pid, const Ice::Current&)
98  {
99  getAttribute("pid")->setValue(new armarx::Variant(pid));
100  }
101 
102  std::string
103  ProfilerProcess::getProcessName(const Ice::Current&) const
104  {
105  return getAttribute("processName")->getValue()->getString();
106  }
107 
108  void
109  ProfilerProcess::setProcessName(const std::string& processName, const Ice::Current&)
110  {
111  getAttribute("processName")->setValue(new armarx::Variant(processName));
112  }
113 
114  Ice::Int
115  ProfilerProcess::getTimestamp(const Ice::Current&) const
116  {
117  return getAttribute("timestamp")->getValue()->getInt();
118  }
119 
120  void
121  ProfilerProcess::setTimestamp(Ice::Int timestamp, const Ice::Current&)
122  {
123  getAttribute("timestamp")->setValue(new armarx::Variant(timestamp));
124  }
125 
127  ProfilerProcess::getProcessCpuUsage(const Ice::Current&) const
128  {
129  return getAttribute("processCpuUsage")->getValue()->getDouble();
130  }
131 
132  void
133  ProfilerProcess::setProcessCpuUsage(Ice::Double processCpuUsage, const Ice::Current&)
134  {
135  getAttribute("processCpuUsage")->setValue(new armarx::Variant(processCpuUsage));
136  }
137 } // namespace memoryx
memoryx::ProfilerProcess::ProfilerProcess
ProfilerProcess()
Definition: ProfilerProcess.cpp:30
memoryx::ProfilerProcess
Definition: ProfilerProcess.h:37
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:223
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::Entity::getAttribute
EntityAttributeBasePtr getAttribute(const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve attribute from entity.
Definition: Entity.cpp:311
memoryx::ProfilerProcess::setTimestamp
void setTimestamp(Ice::Int timestamp, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerProcess.cpp:121
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::ProfilerEntity
Definition: ProfilerEntity.h:36
IceUtil
Definition: Instance.h:21
memoryx::ProfilerProcess::setProcessCpuUsage
void setProcessCpuUsage(Ice::Double processCpuUsage, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerProcess.cpp:133
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::ProfilerProcess::getTimestamp
Ice::Int getTimestamp(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerProcess.cpp:115
armarx::VariantType::Double
const VariantTypeId Double
Definition: Variant.h:920
memoryx::ProfilerProcess::setPid
void setPid(Ice::Int pid, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerProcess.cpp:97
memoryx::ProfilerProcess::setProfilerProcess
void setProfilerProcess(const armarx::ProfilerProcessCpuUsage &process)
Definition: ProfilerProcess.cpp:82
memoryx::ProfilerProcess::getProcessName
std::string getProcessName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerProcess.cpp:103
memoryx::Entity::attributesMutex
std::mutex attributesMutex
Definition: Entity.h:524
memoryx::ProfilerProcess::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: ProfilerProcess.cpp:66
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:661
memoryx::Entity::entityMutex
std::shared_mutex entityMutex
Definition: Entity.h:525
memoryx::ProfilerProcess::getPid
Ice::Int getPid(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerProcess.cpp:91
memoryx::ProfilerProcess::~ProfilerProcess
~ProfilerProcess() override
Definition: ProfilerProcess.cpp:52
memoryx::EntityAttribute
Attribute of MemoryX entities.
Definition: EntityAttribute.h:49
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:917
memoryx::ProfilerProcess::setProcessName
void setProcessName(const std::string &processName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerProcess.cpp:109
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::ProfilerProcess::clone
ProfilerEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: ProfilerProcess.cpp:72
memoryx::Entity
Definition: Entity.h:245
memoryx::Entity::wrappersMutex
std::recursive_mutex wrappersMutex
Definition: Entity.h:526
memoryx::ProfilerProcess::getProcessCpuUsage
Ice::Double getProcessCpuUsage(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerProcess.cpp:127
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
ProfilerProcess.h