ProfilerEntity.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 "ProfilerEntity.h"
26
27namespace memoryx
28{
29
34
36 IceUtil::Shared(source),
37 ::armarx::Serializable(source),
38 EntityBase(), // dont copy
39 ProfilerEntityBase(source),
40 Entity(source)
41 {
42 }
43
47
48 void
49 ProfilerEntity::output(std::ostream& stream) const
50 {
51 Entity::output(stream);
52 }
53
54 Ice::ObjectPtr
56 {
57 return this->clone();
58 }
59
61 ProfilerEntity::clone(const Ice::Current& context) const
62 {
63 std::shared_lock entityLock(entityMutex);
64 std::scoped_lock attributesLock(attributesMutex);
65 std::scoped_lock wrappersLock(wrappersMutex);
66 return new ProfilerEntity(*this);
67 }
68
69 void
70 ProfilerEntity::setTags(const Ice::StringSeq& tags, const Ice::Current& context)
71 {
72 for (const std::string& tag : tags)
73 {
74 getAttribute("tags")->addValue(new armarx::Variant(tag));
75 }
76 }
77
78 void
79 ProfilerEntity::addTag(const std::string& tag, const Ice::Current& context)
80 {
81 getAttribute("tags")->addValue(new armarx::Variant(tag));
82 }
83
84 Ice::StringSeq
85 ProfilerEntity::getTags(const Ice::Current& context) const
86 {
87 memoryx::EntityAttributeBasePtr tags = getAttribute("tags");
88 Ice::StringSeq tagStrings;
89 tagStrings.reserve(tags->size());
90
91 for (int i = 0; i < tags->size(); i++)
92 {
93 tagStrings.push_back(tags->getValueAt(i)->getString());
94 }
95
96 return tagStrings;
97 }
98} // namespace memoryx
The Variant class is described here: Variants.
Definition Variant.h:224
Attribute of MemoryX entities.
EntityAttributeBasePtr getAttribute(const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve attribute from entity.
Definition Entity.cpp:311
Entity(const Entity &source)
Definition Entity.cpp:34
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
void addTag(const std::string &tag, const Ice::Current &context=Ice::emptyCurrent) override
Ice::StringSeq getTags(const Ice::Current &context=Ice::emptyCurrent) const override
void setTags(const Ice::StringSeq &tags, const Ice::Current &context=Ice::emptyCurrent) override
ProfilerEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Ice::ObjectPtr ice_clone() const override
This file offers overloads of toIce() and fromIce() functions for STL container types.
VirtualRobot headers.
IceInternal::Handle< ProfilerEntity > ProfilerEntityPtr