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