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 
27 namespace memoryx
28 {
29 
31  {
32  putAttribute(new EntityAttribute("tags"));
33  }
34 
36  IceUtil::Shared(source),
37  ::armarx::Serializable(source),
38  EntityBase(), // dont copy
39  ProfilerEntityBase(source),
40  Entity(source)
41  {
42  }
43 
45  {
46  }
47 
48  void
49  ProfilerEntity::output(std::ostream& stream) const
50  {
51  Entity::output(stream);
52  }
53 
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
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:223
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
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::ProfilerEntity
Definition: ProfilerEntity.h:36
IceUtil
Definition: Instance.h:21
memoryx::Entity::output
void output(std::ostream &stream) const
Definition: Entity.cpp:436
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::ProfilerEntity::getTags
Ice::StringSeq getTags(const Ice::Current &context=Ice::emptyCurrent) const override
Definition: ProfilerEntity.cpp:85
memoryx::ProfilerEntity::addTag
void addTag(const std::string &tag, const Ice::Current &context=Ice::emptyCurrent) override
Definition: ProfilerEntity.cpp:79
memoryx::Entity::attributesMutex
std::mutex attributesMutex
Definition: Entity.h:524
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:661
memoryx::ProfilerEntity::ProfilerEntity
ProfilerEntity()
Definition: ProfilerEntity.cpp:30
memoryx::Entity::entityMutex
std::shared_mutex entityMutex
Definition: Entity.h:525
memoryx::EntityAttribute
Attribute of MemoryX entities.
Definition: EntityAttribute.h:49
memoryx::ProfilerEntity::setTags
void setTags(const Ice::StringSeq &tags, const Ice::Current &context=Ice::emptyCurrent) override
Definition: ProfilerEntity.cpp:70
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::ProfilerEntity::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: ProfilerEntity.cpp:55
memoryx::Entity
Definition: Entity.h:245
memoryx::ProfilerEntity::~ProfilerEntity
~ProfilerEntity() override
Definition: ProfilerEntity.cpp:44
memoryx::Entity::wrappersMutex
std::recursive_mutex wrappersMutex
Definition: Entity.h:526
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
ProfilerEntity.h
memoryx::ProfilerEntity::clone
ProfilerEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: ProfilerEntity.cpp:61