EnvironmentalPrimitiveSegment.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 Peter Kaiser (peter dot kaiser at kit dot edu)
18* @date 2014
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
33namespace memoryx
34{
36 virtual public WorkingMemoryEntitySegment<EnvironmentalPrimitive>,
37 virtual public EnvironmentalPrimitiveSegmentBase
38 {
39 public:
41
42 EnvironmentalPrimitiveBaseList
43 getEnvironmentalPrimitives(const ::Ice::Current& c = Ice::emptyCurrent) const override;
44 PlanePrimitiveBaseList
45 getPlanes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
46 SpherePrimitiveBaseList
47 getSpheres(const ::Ice::Current& c = Ice::emptyCurrent) const override;
48 CylinderPrimitiveBaseList
49 getCylinders(const ::Ice::Current& c = Ice::emptyCurrent) const override;
50 BoxPrimitiveBaseList getBoxes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
51
52 EnvironmentalPrimitiveBasePtr
53 getEnvironmentalPrimitiveById(const std::string& id,
54 const ::Ice::Current& c = Ice::emptyCurrent) const override;
55 PlanePrimitiveBasePtr
56 getPlaneById(const std::string& id,
57 const ::Ice::Current& c = Ice::emptyCurrent) const override;
58 SpherePrimitiveBasePtr
59 getSphereById(const std::string& id,
60 const ::Ice::Current& c = Ice::emptyCurrent) const override;
61 CylinderPrimitiveBasePtr
62 getCylinderById(const std::string& id,
63 const ::Ice::Current& c = Ice::emptyCurrent) const override;
64 BoxPrimitiveBasePtr getBoxById(const std::string& id,
65 const ::Ice::Current& c = Ice::emptyCurrent) const override;
66
67 EnvironmentalPrimitiveBaseList getEnvironmentalPrimitivesByTimestamp(
68 const armarx::TimestampBasePtr& timestamp,
69 const ::Ice::Current& c = Ice::emptyCurrent) const override;
70 PlanePrimitiveBaseList
71 getPlanesByTimestamp(const armarx::TimestampBasePtr& timestamp,
72 const ::Ice::Current& c = Ice::emptyCurrent) const override;
73 SpherePrimitiveBaseList
74 getSpheresByTimestamp(const armarx::TimestampBasePtr& timestamp,
75 const ::Ice::Current& c = Ice::emptyCurrent) const override;
76 CylinderPrimitiveBaseList
77 getCylindersByTimestamp(const armarx::TimestampBasePtr& timestamp,
78 const ::Ice::Current& c = Ice::emptyCurrent) const override;
79 BoxPrimitiveBaseList
80 getBoxesByTimestamp(const armarx::TimestampBasePtr& timestamp,
81 const ::Ice::Current& c = Ice::emptyCurrent) const override;
82
83 EnvironmentalPrimitiveBaseList getMostRecentEnvironmentalPrimitives(
84 const ::Ice::Current& c = Ice::emptyCurrent) const override;
85 PlanePrimitiveBaseList
86 getMostRecentPlanes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
87 SpherePrimitiveBaseList
88 getMostRecentSpheres(const ::Ice::Current& c = Ice::emptyCurrent) const override;
89 CylinderPrimitiveBaseList
90 getMostRecentCylinders(const ::Ice::Current& c = Ice::emptyCurrent) const override;
91 BoxPrimitiveBaseList
92 getMostRecentBoxes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
93
94 void removePrimitivesByTimestamp(const armarx::TimestampBasePtr& timestamp,
95 const ::Ice::Current& c = Ice::emptyCurrent) override;
96 void removeOlderPrimitives(const armarx::TimestampBasePtr& olderThan,
97 const ::Ice::Current& c = Ice::emptyCurrent) override;
98
99 protected:
100 template <typename EntityPtrType>
101 Ice::Long
102 getMostRecentTimestamp(const std::vector<EntityPtrType>& primitives,
103 const ::Ice::Current& c = Ice::emptyCurrent) const
104 {
105 Ice::Long mostRecentTimestamp = 0;
106
107 for (auto& p : primitives)
108 {
109 Ice::Long t = p->getTime(c)->timestamp;
110 if (t > mostRecentTimestamp)
111 {
112 mostRecentTimestamp = t;
113 }
114 }
115
116 return mostRecentTimestamp;
117 }
118 };
119
121} // namespace memoryx
std::string timestamp()
#define ARMARXCOMPONENT_IMPORT_EXPORT
constexpr T c
Ice::Long getMostRecentTimestamp(const std::vector< EntityPtrType > &primitives, const ::Ice::Current &c=Ice::emptyCurrent) const
EnvironmentalPrimitiveBasePtr getEnvironmentalPrimitiveById(const std::string &id, const ::Ice::Current &c=Ice::emptyCurrent) const override
EnvironmentalPrimitiveBaseList getEnvironmentalPrimitives(const ::Ice::Current &c=Ice::emptyCurrent) const override
CylinderPrimitiveBaseList getMostRecentCylinders(const ::Ice::Current &c=Ice::emptyCurrent) const override
CylinderPrimitiveBasePtr getCylinderById(const std::string &id, const ::Ice::Current &c=Ice::emptyCurrent) const override
SpherePrimitiveBaseList getSpheresByTimestamp(const armarx::TimestampBasePtr &timestamp, const ::Ice::Current &c=Ice::emptyCurrent) const override
PlanePrimitiveBasePtr getPlaneById(const std::string &id, const ::Ice::Current &c=Ice::emptyCurrent) const override
PlanePrimitiveBaseList getPlanesByTimestamp(const armarx::TimestampBasePtr &timestamp, const ::Ice::Current &c=Ice::emptyCurrent) const override
void removeOlderPrimitives(const armarx::TimestampBasePtr &olderThan, const ::Ice::Current &c=Ice::emptyCurrent) override
SpherePrimitiveBaseList getSpheres(const ::Ice::Current &c=Ice::emptyCurrent) const override
EnvironmentalPrimitiveBaseList getMostRecentEnvironmentalPrimitives(const ::Ice::Current &c=Ice::emptyCurrent) const override
CylinderPrimitiveBaseList getCylindersByTimestamp(const armarx::TimestampBasePtr &timestamp, const ::Ice::Current &c=Ice::emptyCurrent) const override
BoxPrimitiveBasePtr getBoxById(const std::string &id, const ::Ice::Current &c=Ice::emptyCurrent) const override
void removePrimitivesByTimestamp(const armarx::TimestampBasePtr &timestamp, const ::Ice::Current &c=Ice::emptyCurrent) override
BoxPrimitiveBaseList getMostRecentBoxes(const ::Ice::Current &c=Ice::emptyCurrent) const override
BoxPrimitiveBaseList getBoxesByTimestamp(const armarx::TimestampBasePtr &timestamp, const ::Ice::Current &c=Ice::emptyCurrent) const override
CylinderPrimitiveBaseList getCylinders(const ::Ice::Current &c=Ice::emptyCurrent) const override
SpherePrimitiveBaseList getMostRecentSpheres(const ::Ice::Current &c=Ice::emptyCurrent) const override
SpherePrimitiveBasePtr getSphereById(const std::string &id, const ::Ice::Current &c=Ice::emptyCurrent) const override
EnvironmentalPrimitiveBaseList getEnvironmentalPrimitivesByTimestamp(const armarx::TimestampBasePtr &timestamp, const ::Ice::Current &c=Ice::emptyCurrent) const override
PlanePrimitiveBaseList getMostRecentPlanes(const ::Ice::Current &c=Ice::emptyCurrent) const override
BoxPrimitiveBaseList getBoxes(const ::Ice::Current &c=Ice::emptyCurrent) const override
PlanePrimitiveBaseList getPlanes(const ::Ice::Current &c=Ice::emptyCurrent) const override
VirtualRobot headers.
IceInternal::Handle< EnvironmentalPrimitiveSegment > EnvironmentalPrimitiveSegmentPtr