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 
29 
30 #include <MemoryX/interface/core/EntityBase.h>
31 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
32 #include <MemoryX/interface/memorytypes/MemorySegments.h>
33 
34 
35 namespace memoryx
36 {
38  virtual public WorkingMemoryEntitySegment<ActiveOac>,
39  virtual public ActiveOacMemorySegmentBase
40  {
41  public:
42  ActiveOacMemorySegment(ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx, OacMemorySegmentBasePrx oacSegmentPrx):
44  ActiveOacMemorySegmentBase(),
45  objectInstanceSegmentPrx(objectInstanceSegmentPrx),
46  oacSegmentPrx(oacSegmentPrx)
47  {
48  }
49 
50  std::string 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;
57  std::string id = WorkingMemoryEntitySegment<ActiveOac>::addEntity(entity, c);
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(objectInstanceSegmentPrx->getObjectInstanceById(*it));
69  args.push_back(object);
70  }
71 
72  activeOac->parameters = args;
73  activeOac->entity = actualEntity;
74 
75  if (listenerProxy)
76  {
77  listenerProxy->reportEntityCreated(segmentName, actualEntity);
78  }
79 
80  return id;
81  }
82 
83  ActiveOacFullPtr getActiveOac(const ::Ice::Current& = Ice::emptyCurrent) override
84  {
85  return activeOac;
86  }
87 
88  void changeState(OacExecState state, const ::Ice::Current& = Ice::emptyCurrent) override
89  {
90  activeOac->entity->setState(state);
91  updateEntity(activeOac->entity->getId(), activeOac->entity);
92  }
93 
94  protected:
95  ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx;
96  OacMemorySegmentBasePrx oacSegmentPrx;
97  ActiveOacFullPtr activeOac;
98  };
99 
101 }
102 
ActiveOac.h
memoryx::ActiveOacMemorySegment::changeState
void changeState(OacExecState state, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ActiveOacMemorySegment.h:88
memoryx::ActiveOacMemorySegment::addEntity
std::string addEntity(const EntityBasePtr &entity, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: ActiveOacMemorySegment.h:50
memoryx::ActiveOacMemorySegment::ActiveOacMemorySegment
ActiveOacMemorySegment(ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx, OacMemorySegmentBasePrx oacSegmentPrx)
Definition: ActiveOacMemorySegment.h:42
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::ActiveOacMemorySegment::oacSegmentPrx
OacMemorySegmentBasePrx oacSegmentPrx
Definition: ActiveOacMemorySegment.h:96
memoryx::WorkingMemoryEntitySegment
Definition: WorkingMemoryEntitySegment.h:44
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
memoryx::ActiveOacMemorySegment::getActiveOac
ActiveOacFullPtr getActiveOac(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ActiveOacMemorySegment.h:83
memoryx::WorkingMemoryEntitySegment::addEntity
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...
Definition: WorkingMemoryEntitySegment.h:164
WorkingMemoryEntitySegment.h
memoryx::ActiveOacMemorySegment::activeOac
ActiveOacFullPtr activeOac
Definition: ActiveOacMemorySegment.h:97
memoryx::ActiveOacMemorySegment
Definition: ActiveOacMemorySegment.h:37
memoryx::ActiveOacMemorySegment::objectInstanceSegmentPrx
ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx
Definition: ActiveOacMemorySegment.h:95
memoryx::ActiveOac
Definition: ActiveOac.h:39
ImportExportComponent.h