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 
33 namespace memoryx
34 {
36  virtual public WorkingMemoryEntitySegment<ActiveOac>,
37  virtual public ActiveOacMemorySegmentBase
38  {
39  public:
40  ActiveOacMemorySegment(ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx,
41  OacMemorySegmentBasePrx oacSegmentPrx) :
43  ActiveOacMemorySegmentBase(),
44  objectInstanceSegmentPrx(objectInstanceSegmentPrx),
45  oacSegmentPrx(oacSegmentPrx)
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;
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(
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
ActiveOac.h
memoryx::ActiveOacMemorySegment::changeState
void changeState(OacExecState state, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ActiveOacMemorySegment.h:91
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:40
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::ActiveOacMemorySegment::oacSegmentPrx
OacMemorySegmentBasePrx oacSegmentPrx
Definition: ActiveOacMemorySegment.h:99
memoryx::WorkingMemoryEntitySegment
Definition: WorkingMemoryEntitySegment.h:45
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:85
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:172
WorkingMemoryEntitySegment.h
memoryx::ActiveOacMemorySegment::activeOac
ActiveOacFullPtr activeOac
Definition: ActiveOacMemorySegment.h:100
memoryx::ActiveOacMemorySegment
Definition: ActiveOacMemorySegment.h:35
memoryx::ActiveOacMemorySegment::objectInstanceSegmentPrx
ObjectInstanceMemorySegmentBasePrx objectInstanceSegmentPrx
Definition: ActiveOacMemorySegment.h:98
memoryx::ActiveOac
Definition: ActiveOac.h:40
ImportExportComponent.h