BodySchemaMemorySegment.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 
28 
30 
31 #include <MemoryX/interface/core/EntityBase.h>
32 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
33 #include <MemoryX/interface/memorytypes/MemorySegments.h>
35 
36 #include <vector>
37 
38 namespace memoryx
39 {
41  virtual public PersistentEntitySegment,
42  virtual public BodySchemaMemorySegmentBase
43  {
44  public:
45  BodySchemaMemorySegment(CollectionInterfacePrx entityCollection, Ice::CommunicatorPtr ic, bool useMongoIds = true) :
46  PersistentEntitySegment(entityCollection, ic, useMongoIds), OacMemorySegmentBase()
47  {
48  }
49 
50  OacBasePtr getOacById(const ::std::string& id, const ::Ice::Current& = Ice::emptyCurrent) const
51  {
52  return completeOac(OacBasePtr::dynamicCast(getEntityById(id)));
53  }
54 
55  OacBasePtr getOacByName(const ::std::string& name, const ::Ice::Current& = Ice::emptyCurrent) const
56  {
57  return completeOac(OacBasePtr::dynamicCast(getEntityByName(name)));
58  }
59 
60  OacBaseList getAll(const ::Ice::Current& = Ice::emptyCurrent) const
61  {
62  OacBaseList result;
63 
64  EntityIdList entityIdList = getAllEntityIds();
65 
66  for (EntityIdList::const_iterator it = entityIdList.begin(); it != entityIdList.end(); ++it)
67  {
68  OacBasePtr oac = getOacById(*it);
69 
70  if (oac)
71  {
72  result.push_back(oac);
73  }
74  }
75 
76  return result;
77  }
78 
79  protected:
80 
81  /*!
82  * \brief replaceObjectDummies checks the objects class in the SEC part of an OAC
83  * and completes it with the real object class entities from the
84  * PersistentObjectClassSegment.
85  * \param oac OAC in which the object should be replaced
86  * \return Returns same instance as the parameter oac for convenience.
87  */
88  OacBasePtr replaceObjectDummies(OacBasePtr oac) const;
89 
90  /*!
91  * \brief completeOac checks the data of an OAC and completes it with
92  * data from other segments (e.g: object with only the name are fetched
93  * from the PersistentObjectClassSegment.
94  * \param oac OAC that should be completed.
95  * \return Returns same instance as the parameter oac for convenience.
96  */
97  OacBasePtr completeOac(OacBasePtr oac) const;
98  PersistentObjectClassSegmentBasePrx objClassSegment ;
99 
100  };
101 
103 
104  OacBasePtr OacMemorySegment::completeOac(OacBasePtr oac) const
105  {
106  return replaceObjectDummies(oac);
107  }
108 
109  OacBasePtr OacMemorySegment::replaceObjectDummies(OacBasePtr oac) const
110  {
111  if (!oac)
112  {
113  return NULL;
114  }
115 
116  OacPtr oacCast = OacPtr::dynamicCast(oac);
117 
118  if (!oacCast)
119  {
120  throw IceUtil::NullHandleException("Could not cast OacBase into Oac Ptr", 0);
121  }
122 
123  if (!objClassSegment)
124  {
125  throw armarx::LocalException("PersistentObjectClassSegmentBaseProxy is NULL");
126  }
127 
128  SECObjectRelationsBasePtr pre = oacCast->getPredictionFunction()->getSECPreconditions();
129  SECObjectRelationsBasePtr post = oacCast->getPredictionFunction()->getSECEffects();
130 
131  if (pre)
132  {
134  }
135 
136  if (post)
137  {
139  }
140 
141  return oacCast;
142  }
143 
144 }
145 
cyberglove_with_calib_22dof.ic
ic
Definition: cyberglove_with_calib_22dof.py:22
memoryx::BodySchemaMemorySegment::objClassSegment
PersistentObjectClassSegmentBasePrx objClassSegment
Definition: BodySchemaMemorySegment.h:98
Oac.h
SemanticEventChainSegment.h
memoryx::OacMemorySegment::replaceObjectDummies
OacBasePtr replaceObjectDummies(OacBasePtr oac) const
replaceObjectDummies checks the objects class in the SEC part of an OAC and completes it with the rea...
Definition: BodySchemaMemorySegment.h:109
PersistentEntitySegment.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
IceInternal::Handle< ::Ice::Communicator >
memoryx::SemanticEventChainSegment::ReplaceObjectDummies
static void ReplaceObjectDummies(SECObjectRelationsBasePtr objRelations, PersistentObjectClassSegmentBasePrx objClassSegment)
Definition: SemanticEventChainSegment.cpp:37
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
memoryx::BodySchemaMemorySegment
Definition: BodySchemaMemorySegment.h:40
memoryx::BodySchemaMemorySegment::getOacById
OacBasePtr getOacById(const ::std::string &id, const ::Ice::Current &=Ice::emptyCurrent) const
Definition: BodySchemaMemorySegment.h:50
memoryx::OacMemorySegment::completeOac
OacBasePtr completeOac(OacBasePtr oac) const
completeOac checks the data of an OAC and completes it with data from other segments (e....
Definition: BodySchemaMemorySegment.h:104
memoryx::BodySchemaMemorySegment::getAll
OacBaseList getAll(const ::Ice::Current &=Ice::emptyCurrent) const
Definition: BodySchemaMemorySegment.h:60
memoryx::OacMemorySegment::objClassSegment
PersistentObjectClassSegmentBasePrx objClassSegment
Definition: OacMemorySegment.h:99
memoryx::PersistentEntitySegment
The PersistentEntitySegment class is the base class for all memory segments containing memoryx::Entit...
Definition: PersistentEntitySegment.h:107
memoryx::BodySchemaMemorySegment::getOacByName
OacBasePtr getOacByName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) const
Definition: BodySchemaMemorySegment.h:55
memoryx::BodySchemaMemorySegment::BodySchemaMemorySegment
BodySchemaMemorySegment(CollectionInterfacePrx entityCollection, Ice::CommunicatorPtr ic, bool useMongoIds=true)
Definition: BodySchemaMemorySegment.h:45
ImportExportComponent.h