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
36namespace 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
#define ARMARXCOMPONENT_IMPORT_EXPORT
BodySchemaMemorySegment(CollectionInterfacePrx entityCollection, Ice::CommunicatorPtr ic, bool useMongoIds=true)
OacBaseList getAll(const ::Ice::Current &=Ice::emptyCurrent) const
OacBasePtr getOacById(const ::std::string &id, const ::Ice::Current &=Ice::emptyCurrent) const
OacBasePtr replaceObjectDummies(OacBasePtr oac) const
replaceObjectDummies checks the objects class in the SEC part of an OAC and completes it with the rea...
PersistentObjectClassSegmentBasePrx objClassSegment
OacBasePtr completeOac(OacBasePtr oac) const
completeOac checks the data of an OAC and completes it with data from other segments (e....
OacBasePtr getOacByName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) const
OacBasePtr replaceObjectDummies(OacBasePtr oac) const
replaceObjectDummies checks the objects class in the SEC part of an OAC and completes it with the rea...
PersistentObjectClassSegmentBasePrx objClassSegment
OacBasePtr completeOac(OacBasePtr oac) const
completeOac checks the data of an OAC and completes it with data from other segments (e....
PersistentEntitySegment(CollectionInterfacePrx entityCollection, Ice::CommunicatorPtr ic, bool useMongoIds=true)
EntityBasePtr getEntityById(const ::std::string &entityId, const ::Ice::Current &=Ice::emptyCurrent) const override
EntityIdList getAllEntityIds(const ::Ice::Current &=Ice::emptyCurrent) const override
EntityBasePtr getEntityByName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) const override
static void ReplaceObjectDummies(SECObjectRelationsBasePtr objRelations, PersistentObjectClassSegmentBasePrx objClassSegment)
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
Definition IceManager.h:49
VirtualRobot headers.
IceInternal::Handle< Oac > OacPtr
Definition Oac.h:39
IceInternal::Handle< OacMemorySegment > OacMemorySegmentPtr