ActiveOac.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package MemoryX::WorkingMemory
17 * @author ALexey Kozlov ( kozlov at kit dot edu), Kai Welke (welke at kit got edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #include "ActiveOac.h"
24 #include "Oac.h"
25 #include "OacParameterList.h"
26 #include "OacPredictionFunction.h"
27 #include "OacStatisticalMeasure.h"
28 
31 
33 
34 namespace memoryx
35 {
36  ActiveOac::ActiveOac(const std::string& id)
37  : Entity()
38  {
39  setName(id);
40  setId(id);
41 
42  setArgumentInstanceIds(std::vector<std::string>());
43  setOacRef(NULL);
44  setState(eIncomplete);
45  }
46 
47  NameList ActiveOac::getArgumentInstanceIds(const ::Ice::Current&) const
48  {
49  return OacParameterListPtr::dynamicCast(
50  getAttributeValue("parameterIds")->getClass<OacParameterListBase>()
51  )->getNames();
52  }
53 
54  void ActiveOac::setArgumentInstanceIds(const NameList& ids, const ::Ice::Current&)
55  {
56  OacParameterListPtr paramObj = new OacParameterList();
57  paramObj->setNames(ids);
58  putAttribute("parameterIds", paramObj);
59  }
60 
61 
62  OacExecState ActiveOac::getState(const ::Ice::Current&) const
63  {
64  return static_cast<OacExecState>(getAttributeValue("state")->getInt());
65  }
66 
67  void ActiveOac::setState(OacExecState state, const ::Ice::Current&)
68  {
69  putAttribute("state", static_cast<int>(state));
70  }
71 
73  {
74  return this->clone();
75  }
76 
77  ActiveOacPtr ActiveOac::clone(const Ice::Current& c) const
78  {
79  ActiveOacPtr ret = new ActiveOac(*this);
80  // ret->deepCopy(*this);
81  return ret;
82  }
83 
84  EntityRefBasePtr ActiveOac::getOacRef(const Ice::Current&) const
85  {
86  return getAttributeValue("oacId")->get<EntityRef>();
87  }
88 
89  void ActiveOac::setOacRef(const EntityRefBasePtr& oacRef, const Ice::Current&)
90  {
91  putAttribute("oacRef", oacRef);
92  }
93 
94  std::string ActiveOac::getOacName(const Ice::Current&) const
95  {
96  if (EntityRefBasePtr ref = getOacRef())
97  {
98  return ref->entityName;
99  }
100 
101  return "";
102 
103  }
104 
106  {
107  putAttribute("startTime", new armarx::TimestampVariant(time));
108  }
109 
111  {
113  return timeVar->toTime();
114  }
115 }
ActiveOac.h
memoryx::ActiveOac::getStartTime
IceUtil::Time getStartTime() const
Definition: ActiveOac.cpp:110
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
memoryx::ActiveOac::getState
OacExecState getState(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ActiveOac.cpp:62
memoryx::Entity::putAttribute
void putAttribute(const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override
Store attribute in entity.
Definition: Entity.cpp:327
memoryx::ActiveOac::setOacRef
void setOacRef(const EntityRefBasePtr &oacRef, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ActiveOac.cpp:89
OacPredictionFunction.h
memoryx::ActiveOac::ActiveOac
ActiveOac(const std::string &id="")
Definition: ActiveOac.cpp:36
Oac.h
memoryx::ActiveOac::clone
ActiveOacPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: ActiveOac.cpp:77
OacStatisticalMeasure.h
memoryx::ActiveOac::setStartTime
void setStartTime(const IceUtil::Time &time)
Definition: ActiveOac.cpp:105
armarx::TimestampVariant
Definition: TimestampVariant.h:54
AbstractObjectSerializer.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
memoryx::EntityRef
The EntityRef class is used to store references to Entities as values in other Entity instances.
Definition: EntityRef.h:45
memoryx::Entity::getAttributeValue
virtual armarx::VariantPtr getAttributeValue(const ::std::string &attrName) const
Retrieve value of an attribute from entity.
Definition: Entity.cpp:308
memoryx::ActiveOac::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: ActiveOac.cpp:72
memoryx::ActiveOac::setArgumentInstanceIds
void setArgumentInstanceIds(const NameList &, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ActiveOac.cpp:54
IceInternal::Handle
Definition: forward_declarations.h:8
EntityRef.h
TimestampVariant.h
memoryx::ActiveOac::getOacName
std::string getOacName(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ActiveOac.cpp:94
memoryx::Entity::setId
void setId(const ::std::string &id, const ::Ice::Current &=Ice::emptyCurrent) override
Set id of this entity.
Definition: Entity.cpp:167
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
memoryx::ActiveOac::getArgumentInstanceIds
NameList getArgumentInstanceIds(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ActiveOac.cpp:47
OacParameterList.h
memoryx::ActiveOac::setState
void setState(OacExecState state, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ActiveOac.cpp:67
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::ActiveOac::getOacRef
EntityRefBasePtr getOacRef(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: ActiveOac.cpp:84
memoryx::OacParameterList
Definition: OacParameterList.h:39
memoryx::Entity
Definition: Entity.h:246
memoryx::Entity::setName
void setName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) override
Set name of this entity.
Definition: Entity.cpp:179