ProfilerMemoryUsage.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::MemoryTypes
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 "ProfilerMemoryUsage.h"
26 
27 
28 namespace memoryx
29 {
30 
32  Entity()
33  {
34  initializeAttributes();
35  }
36 
37  ProfilerMemoryUsage::ProfilerMemoryUsage(const armarx::ProfilerProcessMemoryUsage& memoryUsage)
38  {
39  initializeAttributes();
40  setProfilerMemoryUsage(memoryUsage);
41  }
42 
44  IceUtil::Shared(source),
45  ::armarx::Serializable(source),
46  EntityBase(),
47  ProfilerEntityBase(source),
48  ProfilerMemoryUsageBase(source),
49  Entity(source),
51  {
52  }
53 
55  {
56  }
57 
58  void ProfilerMemoryUsage::initializeAttributes()
59  {
60  putAttribute(new EntityAttribute("pid"));
61  putAttribute(new EntityAttribute("processName"));
62  putAttribute(new EntityAttribute("timestamp"));
63  putAttribute(new EntityAttribute("memoryUsage"));
64  }
65 
67  {
68  return this->clone();
69  }
70 
71  ProfilerEntityPtr ProfilerMemoryUsage::clone(const Ice::Current& c) const
72  {
73  std::shared_lock entityLock(entityMutex);
74  std::scoped_lock attributesLock(attributesMutex);
75  std::scoped_lock wrappersLock(wrappersMutex);
77  return ret;
78  }
79 
80  void ProfilerMemoryUsage::setProfilerMemoryUsage(const armarx::ProfilerProcessMemoryUsage& memoryUsage)
81  {
82  setPid(memoryUsage.processId);
83  setProcessName(memoryUsage.processName);
84  setTimestamp(memoryUsage.timestamp);
85  setMemoryUsage(memoryUsage.memoryUsage);
86  }
87 
88  Ice::Int ProfilerMemoryUsage::getPid(const Ice::Current& c) const
89  {
90  return getAttribute("pid")->getValue()->getInt();
91  }
92 
93  void ProfilerMemoryUsage::setPid(Ice::Int pid, const Ice::Current&)
94  {
95  getAttribute("pid")->setValue(new armarx::Variant(pid));
96  }
97 
98  std::string ProfilerMemoryUsage::getProcessName(const Ice::Current&) const
99  {
100  return getAttribute("processName")->getValue()->getString();
101  }
102 
103  void ProfilerMemoryUsage::setProcessName(const std::string& processName, const Ice::Current&)
104  {
105  getAttribute("processName")->setValue(new armarx::Variant(processName));
106  }
107 
108  Ice::Int ProfilerMemoryUsage::getTimestamp(const Ice::Current&) const
109  {
110  return getAttribute("timestamp")->getValue()->getInt();
111  }
112 
113  void ProfilerMemoryUsage::setTimestamp(Ice::Int timestamp, const Ice::Current&)
114  {
115  getAttribute("timestamp")->setValue(new armarx::Variant(timestamp));
116  }
117 
118  Ice::Int ProfilerMemoryUsage::getMemoryUsage(const Ice::Current& c) const
119  {
120  return getAttribute("memoryUsage")->getValue()->getInt();
121  }
122 
123  void ProfilerMemoryUsage::setMemoryUsage(Ice::Int memoryUsage, const Ice::Current& c)
124  {
125  getAttribute("memoryUsage")->setValue(new armarx::Variant(memoryUsage));
126  }
127 }
memoryx::ProfilerMemoryUsage::ProfilerMemoryUsage
ProfilerMemoryUsage()
Definition: ProfilerMemoryUsage.cpp:31
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
memoryx::ProfilerMemoryUsage::getProcessName
std::string getProcessName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerMemoryUsage.cpp:98
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
memoryx::ProfilerMemoryUsage::clone
ProfilerEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: ProfilerMemoryUsage.cpp:71
memoryx::Entity::putAttribute
void putAttribute(const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override
Store attribute in entity.
Definition: Entity.cpp:327
memoryx::ProfilerMemoryUsage::setMemoryUsage
void setMemoryUsage(Ice::Int memoryUsage, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerMemoryUsage.cpp:123
memoryx::ProfilerMemoryUsage::getPid
Ice::Int getPid(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerMemoryUsage.cpp:88
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::ProfilerMemoryUsage::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: ProfilerMemoryUsage.cpp:66
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
memoryx::ProfilerEntity
Definition: ProfilerEntity.h:36
IceUtil
Definition: Instance.h:21
memoryx::ProfilerMemoryUsage::setProcessName
void setProcessName(const std::string &processName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerMemoryUsage.cpp:103
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::ProfilerMemoryUsage::setProfilerMemoryUsage
void setProfilerMemoryUsage(const armarx::ProfilerProcessMemoryUsage &memoryUsage)
Definition: ProfilerMemoryUsage.cpp:80
memoryx::ProfilerMemoryUsage::getTimestamp
Ice::Int getTimestamp(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerMemoryUsage.cpp:108
memoryx::ProfilerMemoryUsage::getMemoryUsage
Ice::Int getMemoryUsage(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ProfilerMemoryUsage.cpp:118
memoryx::Entity::attributesMutex
std::mutex attributesMutex
Definition: Entity.h:504
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
memoryx::ProfilerMemoryUsage::setPid
void setPid(Ice::Int pid, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerMemoryUsage.cpp:93
memoryx::Entity::entityMutex
std::shared_mutex entityMutex
Definition: Entity.h:505
memoryx::ProfilerMemoryUsage::setTimestamp
void setTimestamp(Ice::Int timestamp, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ProfilerMemoryUsage.cpp:113
memoryx::EntityAttribute
Attribute of MemoryX entities.
Definition: EntityAttribute.h:48
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::ProfilerMemoryUsage
Definition: ProfilerMemoryUsage.h:38
ProfilerMemoryUsage.h
memoryx::Entity
Definition: Entity.h:246
memoryx::ProfilerMemoryUsage::~ProfilerMemoryUsage
~ProfilerMemoryUsage() override
Definition: ProfilerMemoryUsage.cpp:54
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