ActiveOacMemorySegment.h
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 Kai Welke ( welke at kit dot edu)
18* @date 2012
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#pragma once
24
26
27#include <MemoryX/interface/core/EntityBase.h>
28#include <MemoryX/interface/memorytypes/MemoryEntities.h>
29#include <MemoryX/interface/memorytypes/MemorySegments.h>
32
33namespace memoryx
34{
36 virtual public WorkingMemoryEntitySegment<ActiveOac>,
37 virtual public ActiveOacMemorySegmentBase
38 {
39 public:
40 ActiveOacMemorySegment(ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx,
41 OacMemorySegmentBasePrx oacSegmentPrx) :
43 ActiveOacMemorySegmentBase(),
46 {
47 }
48
49 std::string
50 addEntity(const EntityBasePtr& entity, const ::Ice::Current& c = Ice::emptyCurrent) override
51 {
52 activeOac = new ActiveOacFull;
53 clear();
54
55 WorkingMemoryListenerInterfacePrx tmpListenerProxy = listenerProxy;
56 listenerProxy = NULL;
58 listenerProxy = tmpListenerProxy;
59
60 ActiveOacPtr actualEntity = ActiveOacPtr::dynamicCast(getEntityById(id));
61 activeOac->oac = oacSegmentPrx->getOacById(actualEntity->getOacRef()->entityId);
62
63 ObjectInstanceList args;
64 std::vector<std::string> ids = actualEntity->getArgumentInstanceIds();
65
66 for (std::vector<std::string>::const_iterator it = ids.begin(); it != ids.end(); ++it)
67 {
68 ObjectInstancePtr object = ObjectInstancePtr::dynamicCast(
69 objectInstanceSegmentPrx->getObjectInstanceById(*it));
70 args.push_back(object);
71 }
72
73 activeOac->parameters = args;
74 activeOac->entity = actualEntity;
75
76 if (listenerProxy)
77 {
78 listenerProxy->reportEntityCreated(segmentName, actualEntity);
79 }
80
81 return id;
82 }
83
84 ActiveOacFullPtr
85 getActiveOac(const ::Ice::Current& = Ice::emptyCurrent) override
86 {
87 return activeOac;
88 }
89
90 void
91 changeState(OacExecState state, const ::Ice::Current& = Ice::emptyCurrent) override
92 {
93 activeOac->entity->setState(state);
94 updateEntity(activeOac->entity->getId(), activeOac->entity);
95 }
96
97 protected:
98 ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx;
99 OacMemorySegmentBasePrx oacSegmentPrx;
100 ActiveOacFullPtr activeOac;
101 };
102
104} // namespace memoryx
#define ARMARXCOMPONENT_IMPORT_EXPORT
constexpr T c
std::string addEntity(const EntityBasePtr &entity, const ::Ice::Current &c=Ice::emptyCurrent) override
ActiveOacFullPtr getActiveOac(const ::Ice::Current &=Ice::emptyCurrent) override
void changeState(OacExecState state, const ::Ice::Current &=Ice::emptyCurrent) override
ActiveOacMemorySegment(ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx, OacMemorySegmentBasePrx oacSegmentPrx)
ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx
void clear(const ::Ice::Current &c=Ice::emptyCurrent) override
std::string addEntity(const EntityBasePtr &entity, const ::Ice::Current &c=Ice::emptyCurrent) override
addEntity addes an entity to this segment. The registered fusion methods are applied in order to fuse...
void updateEntity(const std::string &entityId, const EntityBasePtr &update, const ::Ice::Current &c=Ice::emptyCurrent) override
EntityBasePtr getEntityById(const ::std::string &id) const
VirtualRobot headers.
IceInternal::Handle< ActiveOacMemorySegment > ActiveOacMemorySegmentPtr
IceInternal::Handle< ObjectInstance > ObjectInstancePtr
IceInternal::Handle< ActiveOac > ActiveOacPtr
Definition ActiveOac.h:38