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