PredictionTaskEntity.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 "PredictionTaskEntity.h"
26 #include "../../../../core/entity/EntityRef.h"
27 
28 
29 namespace memoryx
30 {
31  const std::string PredictionTaskEntity::TASK_NAME_ATTRIBUTE("predictionTaskName");
32  const std::string PredictionTaskEntity::PREDICTION_LIST_ATTRIBUTE("predictionList");
33 
35  Entity()
36  {
38  }
39 
40  PredictionTaskEntity::PredictionTaskEntity(const std::string& predictionTaskName, const EntityRefBaseList& predictionEntityRefList) :
41  Entity()
42  {
44  setPredictionTaskName(predictionTaskName);
45  setPredictionEntityRefList(predictionEntityRefList);
46  }
47 
48 
50  IceUtil::Shared(source),
51  ::armarx::Serializable(source),
52  EntityBase(),// dont copy
53  PredictionTaskEntityBase(source),
54  Entity(source)
55  {
56  }
57 
58 
60  {
61  }
62 
64  {
65  putAttribute(new EntityAttribute(PredictionTaskEntity::TASK_NAME_ATTRIBUTE));
66  putAttribute(new EntityAttribute(PredictionTaskEntity::PREDICTION_LIST_ATTRIBUTE));
67  }
68 
69 
70  void PredictionTaskEntity::output(std::ostream& stream) const
71  {
72  Entity::output(stream);
73  }
74 
75 
77  {
78  return this->clone();
79  }
80 
81 
82  PredictionTaskEntityPtr PredictionTaskEntity::clone(const Ice::Current& context) const
83  {
84  std::shared_lock entityLock(entityMutex);
85  std::scoped_lock attributesLock(attributesMutex);
86  std::scoped_lock wrappersLock(wrappersMutex);
87  return new PredictionTaskEntity(*this);
88  }
89 
90  std::string PredictionTaskEntity::getPredictionTaskName(const Ice::Current&) const
91  {
92  return getAttribute(PredictionTaskEntity::TASK_NAME_ATTRIBUTE)->getValue()->getString();
93  }
94 
95  void PredictionTaskEntity::setPredictionTaskName(const std::string& predictionTaskName, const Ice::Current&)
96  {
97  getAttribute(PredictionTaskEntity::TASK_NAME_ATTRIBUTE)->setValue(new armarx::Variant(predictionTaskName));
98  }
99 
100 
101  EntityRefBaseList PredictionTaskEntity::getPredictionEntityRefList(const Ice::Current&) const
102  {
103  // EntityAttributeBasePtr attribute = getAttribute(PredictionTaskEntity::PREDICTION_LIST_ATTRIBUTE);
104  // EntityRefBaseList entityList;
105  // for (int i = 0; i < attribute->size(); i++)
106  // {
107  // armarx::VariantPtr attributeValue = armarx::VariantPtr::dynamicCast(attribute->getValueAt(i));
108  // entityList.push_back(attributeValue->get<EntityRef>());
109  // }
110  // return entityList;
111  return EntityRefBaseList {};
112  }
113 
114  void PredictionTaskEntity::setPredictionEntityRefList(const EntityRefBaseList& predictedEntityRefList, const Ice::Current&)
115  {
116  // EntityAttributeBasePtr attribute = getAttribute(PredictionTaskEntity::PREDICTION_LIST_ATTRIBUTE);
117  // attribute->clear();
118  // for (const EntityRefBasePtr & entityRef : predictedMemorySnapshotRefList)
119  // {
120  // attribute->addValue(new armarx::Variant(entityRef));
121  // }
122  }
123 }
memoryx::PredictionTaskEntity::initializeAttributes
void initializeAttributes()
Definition: PredictionTaskEntity.cpp:63
memoryx::PredictionTaskEntity::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: PredictionTaskEntity.cpp:76
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
IceUtil
Definition: Instance.h:21
memoryx::PredictionTaskEntity::getPredictionTaskName
std::string getPredictionTaskName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: PredictionTaskEntity.cpp:90
memoryx::Entity::output
void output(std::ostream &stream) const
Definition: Entity.cpp:409
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::PredictionTaskEntity::PredictionTaskEntity
PredictionTaskEntity()
Definition: PredictionTaskEntity.cpp:34
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::PredictionTaskEntity::getPredictionEntityRefList
EntityRefBaseList getPredictionEntityRefList(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: PredictionTaskEntity.cpp:101
memoryx::PredictionTaskEntity::~PredictionTaskEntity
~PredictionTaskEntity() override
Definition: PredictionTaskEntity.cpp:59
memoryx::Entity::entityMutex
std::shared_mutex entityMutex
Definition: Entity.h:505
memoryx::PredictionTaskEntity::setPredictionTaskName
void setPredictionTaskName(const std::string &predictionTaskName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: PredictionTaskEntity.cpp:95
memoryx::EntityAttribute
Attribute of MemoryX entities.
Definition: EntityAttribute.h:48
memoryx::PredictionTaskEntity::setPredictionEntityRefList
void setPredictionEntityRefList(const EntityRefBaseList &predictedEntityRefList, const Ice::Current &c=Ice::emptyCurrent) override
Definition: PredictionTaskEntity.cpp:114
memoryx::PredictionTaskEntity::clone
PredictionTaskEntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: PredictionTaskEntity.cpp:82
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::PredictionTaskEntity
Definition: PredictionTaskEntity.h:35
memoryx::Entity
Definition: Entity.h:246
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
PredictionTaskEntity.h