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"
33
34namespace 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 {
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
74 Ice::ObjectPtr
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
112 ActiveOac::setStartTime(const IceUtil::Time& time)
113 {
114 putAttribute("startTime", new armarx::TimestampVariant(time));
115 }
116
117 IceUtil::Time
119 {
121 getAttributeValue("startTime")->get<armarx::TimestampVariant>();
122 return timeVar->toTime();
123 }
124} // namespace memoryx
constexpr T c
Implements a Variant type for timestamps.
void setState(OacExecState state, const ::Ice::Current &=Ice::emptyCurrent) override
Definition ActiveOac.cpp:69
OacExecState getState(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition ActiveOac.cpp:63
void setOacRef(const EntityRefBasePtr &oacRef, const Ice::Current &c=Ice::emptyCurrent) override
Definition ActiveOac.cpp:95
NameList getArgumentInstanceIds(const Ice::Current &c=Ice::emptyCurrent) const override
Definition ActiveOac.cpp:47
IceUtil::Time getStartTime() const
ActiveOacPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition ActiveOac.cpp:81
void setStartTime(const IceUtil::Time &time)
std::string getOacName(const Ice::Current &c=Ice::emptyCurrent) const override
EntityRefBasePtr getOacRef(const Ice::Current &c=Ice::emptyCurrent) const override
Definition ActiveOac.cpp:89
Ice::ObjectPtr ice_clone() const override
Definition ActiveOac.cpp:75
void setArgumentInstanceIds(const NameList &, const Ice::Current &c=Ice::emptyCurrent) override
Definition ActiveOac.cpp:55
ActiveOac(const std::string &id="")
Definition ActiveOac.cpp:36
The EntityRef class is used to store references to Entities as values in other Entity instances.
Definition EntityRef.h:47
void setId(const ::std::string &id, const ::Ice::Current &=Ice::emptyCurrent) override
Set id of this entity.
Definition Entity.cpp:174
void setName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) override
Set name of this entity.
Definition Entity.cpp:188
Entity(const Entity &source)
Definition Entity.cpp:34
virtual armarx::VariantPtr getAttributeValue(const ::std::string &attrName) const
Retrieve value of an attribute from entity.
Definition Entity.cpp:327
void putAttribute(const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override
Store attribute in entity.
Definition Entity.cpp:347
IceInternal::Handle< TimestampVariant > TimestampVariantPtr
VirtualRobot headers.
IceInternal::Handle< ActiveOac > ActiveOacPtr
Definition ActiveOac.h:38
IceInternal::Handle< OacParameterList > OacParameterListPtr