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
27namespace memoryx
28{
29
31 {
32 initializeAttributes();
33 }
34
35 ProfilerMemoryUsage::ProfilerMemoryUsage(const armarx::ProfilerProcessMemoryUsage& memoryUsage)
36 {
37 initializeAttributes();
38 setProfilerMemoryUsage(memoryUsage);
39 }
40
42 IceUtil::Shared(source),
43 ::armarx::Serializable(source),
44 EntityBase(),
45 ProfilerEntityBase(source),
46 ProfilerMemoryUsageBase(source),
47 Entity(source),
48 ProfilerEntity(source)
49 {
50 }
51
55
56 void
57 ProfilerMemoryUsage::initializeAttributes()
58 {
59 putAttribute(new EntityAttribute("pid"));
60 putAttribute(new EntityAttribute("processName"));
61 putAttribute(new EntityAttribute("timestamp"));
62 putAttribute(new EntityAttribute("memoryUsage"));
63 }
64
65 Ice::ObjectPtr
67 {
68 return this->clone();
69 }
70
72 ProfilerMemoryUsage::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
83 const armarx::ProfilerProcessMemoryUsage& memoryUsage)
84 {
85 setPid(memoryUsage.processId);
86 setProcessName(memoryUsage.processName);
87 setTimestamp(memoryUsage.timestamp);
88 setMemoryUsage(memoryUsage.memoryUsage);
89 }
90
91 Ice::Int
92 ProfilerMemoryUsage::getPid(const Ice::Current& c) const
93 {
94 return getAttribute("pid")->getValue()->getInt();
95 }
96
97 void
98 ProfilerMemoryUsage::setPid(Ice::Int pid, const Ice::Current&)
99 {
100 getAttribute("pid")->setValue(new armarx::Variant(pid));
101 }
102
103 std::string
104 ProfilerMemoryUsage::getProcessName(const Ice::Current&) const
105 {
106 return getAttribute("processName")->getValue()->getString();
107 }
108
109 void
110 ProfilerMemoryUsage::setProcessName(const std::string& processName, const Ice::Current&)
111 {
112 getAttribute("processName")->setValue(new armarx::Variant(processName));
113 }
114
115 Ice::Int
116 ProfilerMemoryUsage::getTimestamp(const Ice::Current&) const
117 {
118 return getAttribute("timestamp")->getValue()->getInt();
119 }
120
121 void
122 ProfilerMemoryUsage::setTimestamp(Ice::Int timestamp, const Ice::Current&)
123 {
124 getAttribute("timestamp")->setValue(new armarx::Variant(timestamp));
125 }
126
127 Ice::Int
128 ProfilerMemoryUsage::getMemoryUsage(const Ice::Current& c) const
129 {
130 return getAttribute("memoryUsage")->getValue()->getInt();
131 }
132
133 void
134 ProfilerMemoryUsage::setMemoryUsage(Ice::Int memoryUsage, const Ice::Current& c)
135 {
136 getAttribute("memoryUsage")->setValue(new armarx::Variant(memoryUsage));
137 }
138} // 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
std::mutex attributesMutex
Definition Entity.h:524
std::recursive_mutex wrappersMutex
Definition Entity.h:526
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
void setMemoryUsage(Ice::Int memoryUsage, const Ice::Current &c=Ice::emptyCurrent) override
std::string getProcessName(const Ice::Current &c=Ice::emptyCurrent) const override
Ice::Int getMemoryUsage(const Ice::Current &c=Ice::emptyCurrent) const override
void setTimestamp(Ice::Int timestamp, const Ice::Current &c=Ice::emptyCurrent) override
Ice::Int getPid(const Ice::Current &c=Ice::emptyCurrent) const override
ProfilerEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
void setProfilerMemoryUsage(const armarx::ProfilerProcessMemoryUsage &memoryUsage)
Ice::ObjectPtr ice_clone() const override
void setPid(Ice::Int pid, const Ice::Current &c=Ice::emptyCurrent) override
void setProcessName(const std::string &processName, const Ice::Current &c=Ice::emptyCurrent) override
Ice::Int getTimestamp(const Ice::Current &c=Ice::emptyCurrent) const override
This file offers overloads of toIce() and fromIce() functions for STL container types.
VirtualRobot headers.
IceInternal::Handle< ProfilerMemoryUsage > ProfilerMemoryUsagePtr
IceInternal::Handle< ProfilerEntity > ProfilerEntityPtr