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 
28 namespace memoryx
29 {
30 
32  Entity()
33  {
34  putAttribute(new EntityAttribute("tags"));
35  }
36 
37 
39  IceUtil::Shared(source),
40  ::armarx::Serializable(source),
41  EntityBase(),// dont copy
42  ProfilerEntityBase(source),
43  Entity(source)
44  {
45  }
46 
47 
49  {
50  }
51 
52 
53  void ProfilerEntity::output(std::ostream& stream) const
54  {
55  Entity::output(stream);
56  }
57 
58 
60  {
61  return this->clone();
62  }
63 
64 
65  ProfilerEntityPtr ProfilerEntity::clone(const Ice::Current& context) const
66  {
67  std::shared_lock entityLock(entityMutex);
68  std::scoped_lock attributesLock(attributesMutex);
69  std::scoped_lock wrappersLock(wrappersMutex);
70  return new ProfilerEntity(*this);
71  }
72 
73 
74  void ProfilerEntity::setTags(const Ice::StringSeq& tags, const Ice::Current& context)
75  {
76  for (const std::string& tag : tags)
77  {
78  getAttribute("tags")->addValue(new armarx::Variant(tag));
79  }
80  }
81 
82 
83  void ProfilerEntity::addTag(const std::string& tag, const Ice::Current& context)
84  {
85  getAttribute("tags")->addValue(new armarx::Variant(tag));
86  }
87 
88 
89  Ice::StringSeq ProfilerEntity::getTags(const Ice::Current& context) const
90  {
91  memoryx::EntityAttributeBasePtr tags = getAttribute("tags");
92  Ice::StringSeq tagStrings;
93  tagStrings.reserve(tags->size());
94 
95  for (int i = 0; i < tags->size(); i++)
96  {
97  tagStrings.push_back(tags->getValueAt(i)->getString());
98  }
99 
100  return tagStrings;
101  }
102 }
103 
104 
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
memoryx::Entity::putAttribute
void putAttribute(const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override
Store attribute in entity.
Definition: Entity.cpp:327
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
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:409
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::ProfilerEntity::getTags
Ice::StringSeq getTags(const Ice::Current &context=Ice::emptyCurrent) const override
Definition: ProfilerEntity.cpp:89
memoryx::ProfilerEntity::addTag
void addTag(const std::string &tag, const Ice::Current &context=Ice::emptyCurrent) override
Definition: ProfilerEntity.cpp:83
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::ProfilerEntity::ProfilerEntity
ProfilerEntity()
Definition: ProfilerEntity.cpp:31
memoryx::Entity::entityMutex
std::shared_mutex entityMutex
Definition: Entity.h:505
memoryx::EntityAttribute
Attribute of MemoryX entities.
Definition: EntityAttribute.h:48
memoryx::ProfilerEntity::setTags
void setTags(const Ice::StringSeq &tags, const Ice::Current &context=Ice::emptyCurrent) override
Definition: ProfilerEntity.cpp:74
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:59
memoryx::Entity
Definition: Entity.h:246
memoryx::ProfilerEntity::~ProfilerEntity
~ProfilerEntity() override
Definition: ProfilerEntity.cpp:48
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
ProfilerEntity.h
memoryx::ProfilerEntity::clone
ProfilerEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: ProfilerEntity.cpp:65