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 
27 
28 #include "Oac.h"
29 #include "OacParameterList.h"
30 #include "OacPredictionFunction.h"
31 #include "OacStatisticalMeasure.h"
33 
34 namespace memoryx
35 {
36  ActiveOac::ActiveOac(const std::string& id) : Entity()
37  {
38  setName(id);
39  setId(id);
40 
41  setArgumentInstanceIds(std::vector<std::string>());
42  setOacRef(NULL);
43  setState(eIncomplete);
44  }
45 
46  NameList
47  ActiveOac::getArgumentInstanceIds(const ::Ice::Current&) const
48  {
49  return OacParameterListPtr::dynamicCast(
50  getAttributeValue("parameterIds")->getClass<OacParameterListBase>())
51  ->getNames();
52  }
53 
54  void
55  ActiveOac::setArgumentInstanceIds(const NameList& ids, const ::Ice::Current&)
56  {
57  OacParameterListPtr paramObj = new OacParameterList();
58  paramObj->setNames(ids);
59  putAttribute("parameterIds", paramObj);
60  }
61 
62  OacExecState
63  ActiveOac::getState(const ::Ice::Current&) const
64  {
65  return static_cast<OacExecState>(getAttributeValue("state")->getInt());
66  }
67 
68  void
69  ActiveOac::setState(OacExecState state, const ::Ice::Current&)
70  {
71  putAttribute("state", static_cast<int>(state));
72  }
73 
76  {
77  return this->clone();
78  }
79 
81  ActiveOac::clone(const Ice::Current& c) const
82  {
83  ActiveOacPtr ret = new ActiveOac(*this);
84  // ret->deepCopy(*this);
85  return ret;
86  }
87 
88  EntityRefBasePtr
89  ActiveOac::getOacRef(const Ice::Current&) const
90  {
91  return getAttributeValue("oacId")->get<EntityRef>();
92  }
93 
94  void
95  ActiveOac::setOacRef(const EntityRefBasePtr& oacRef, const Ice::Current&)
96  {
97  putAttribute("oacRef", oacRef);
98  }
99 
100  std::string
101  ActiveOac::getOacName(const Ice::Current&) const
102  {
103  if (EntityRefBasePtr ref = getOacRef())
104  {
105  return ref->entityName;
106  }
107 
108  return "";
109  }
110 
111  void
113  {
114  putAttribute("startTime", new armarx::TimestampVariant(time));
115  }
116 
119  {
121  getAttributeValue("startTime")->get<armarx::TimestampVariant>();
122  return timeVar->toTime();
123  }
124 } // namespace memoryx
ActiveOac.h
memoryx::ActiveOac::getStartTime
IceUtil::Time getStartTime() const
Definition: ActiveOac.cpp:118
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:13
memoryx::ActiveOac::getState
OacExecState getState(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: ActiveOac.cpp:63
memoryx::Entity::putAttribute
void putAttribute(const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override
Store attribute in entity.
Definition: Entity.cpp:347
memoryx::ActiveOac::setOacRef
void setOacRef(const EntityRefBasePtr &oacRef, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ActiveOac.cpp:95
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:81
OacStatisticalMeasure.h
memoryx::ActiveOac::setStartTime
void setStartTime(const IceUtil::Time &time)
Definition: ActiveOac.cpp:112
armarx::TimestampVariant
Definition: TimestampVariant.h:54
AbstractObjectSerializer.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::EntityRef
The EntityRef class is used to store references to Entities as values in other Entity instances.
Definition: EntityRef.h:46
memoryx::Entity::getAttributeValue
virtual armarx::VariantPtr getAttributeValue(const ::std::string &attrName) const
Retrieve value of an attribute from entity.
Definition: Entity.cpp:327
memoryx::ActiveOac::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: ActiveOac.cpp:75
memoryx::ActiveOac::setArgumentInstanceIds
void setArgumentInstanceIds(const NameList &, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ActiveOac.cpp:55
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:101
memoryx::Entity::setId
void setId(const ::std::string &id, const ::Ice::Current &=Ice::emptyCurrent) override
Set id of this entity.
Definition: Entity.cpp:174
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:69
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:89
memoryx::OacParameterList
Definition: OacParameterList.h:40
memoryx::Entity
Definition: Entity.h:245
memoryx::Entity::setName
void setName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) override
Set name of this entity.
Definition: Entity.cpp:188