Ignition Physics

API Reference

2.0.0
GetEntities.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef IGNITION_PHYSICS_GETENTITIES_HH_
19 #define IGNITION_PHYSICS_GETENTITIES_HH_
20 
21 #include <string>
22 
24 
25 namespace ignition
26 {
27  namespace physics
28  {
29  class IGNITION_PHYSICS_VISIBLE GetEngineInfo : public virtual Feature
30  {
31  public: template <typename PolicyT, typename FeaturesT>
32  class Engine : public virtual Feature::Engine<PolicyT, FeaturesT>
33  {
36  public: const std::string &GetName() const;
37 
40  public: std::size_t GetIndex() const;
41  };
42 
43  public: template <typename PolicyT>
44  class Implementation : public virtual Feature::Implementation<PolicyT>
45  {
46  public: virtual const std::string &GetEngineName(
47  const Identity &_engineID) const = 0;
48 
49  public: virtual std::size_t GetEngineIndex(
50  const Identity &_engineID) const = 0;
51  };
52  };
53 
54  class IGNITION_PHYSICS_VISIBLE GetWorldFromEngine : public virtual Feature
55  {
56  public: template <typename PolicyT, typename FeaturesT>
57  class Engine : public virtual Feature::Engine<PolicyT, FeaturesT>
58  {
59  // typedefs for the type of World that this engine can return.
60  public: using WorldPtrType = WorldPtr<PolicyT, FeaturesT>;
61  public: using ConstWorldPtrType = ConstWorldPtr<PolicyT, FeaturesT>;
62 
64  public: std::size_t GetWorldCount() const;
65 
71  public: WorldPtrType GetWorld(std::size_t _index);
72 
74  public: ConstWorldPtrType GetWorld(std::size_t _index) const;
75 
81  public: WorldPtrType GetWorld(const std::string &_name);
82 
84  public: ConstWorldPtrType GetWorld(const std::string &_name) const;
85  };
86 
87  public: template <typename PolicyT, typename FeaturesT>
88  class World : public virtual Feature::World<PolicyT, FeaturesT>
89  {
90  // typedefs for the type of Engine that this World can return
91  public: using EnginePtrType = EnginePtr<PolicyT, FeaturesT>;
92  public: using ConstEnginePtrType = ConstEnginePtr<PolicyT, FeaturesT>;
93 
95  public: const std::string &GetName() const;
96 
98  public: std::size_t GetIndex() const;
99 
102  public: EnginePtrType GetEngine();
103 
105  public: ConstEnginePtrType GetEngine() const;
106  };
107 
108  public: template <typename PolicyT>
109  class Implementation : public virtual Feature::Implementation<PolicyT>
110  {
111  public: virtual std::size_t GetWorldCount(
112  const Identity &_engineID) const = 0;
113 
114  public: virtual Identity GetWorld(
115  const Identity &_engineID, std::size_t _worldIndex) const = 0;
116 
117  public: virtual Identity GetWorld(
118  const Identity &_engineID, const std::string &_worldName) const = 0;
119 
120  public: virtual const std::string &GetWorldName(
121  const Identity &_worldID) const = 0;
122 
123  public: virtual std::size_t GetWorldIndex(
124  const Identity &_worldID) const = 0;
125 
126  public: virtual Identity GetEngineOfWorld(
127  const Identity &_worldID) const = 0;
128  };
129  };
130 
131  class IGNITION_PHYSICS_VISIBLE GetModelFromWorld : public virtual Feature
132  {
133  public: template <typename PolicyT, typename FeaturesT>
134  class World : public virtual Feature::World<PolicyT, FeaturesT>
135  {
136  // typedefs for the type of Model that this World can return
137  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
138  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
139 
141  public: std::size_t GetModelCount() const;
142 
148  public: ModelPtrType GetModel(std::size_t _index);
149 
151  public: ConstModelPtrType GetModel(std::size_t _index) const;
152 
158  public: ModelPtrType GetModel(const std::string &_name);
159 
161  public: ConstModelPtrType GetModel(const std::string &_name) const;
162  };
163 
164  public: template <typename PolicyT, typename FeaturesT>
165  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
166  {
167  // typedefs for the type of World that this Model can return
168  public: using WorldPtrType = WorldPtr<PolicyT, FeaturesT>;
169  public: using ConstWorldPtrType = ConstWorldPtr<PolicyT, FeaturesT>;
170 
172  public: const std::string &GetName() const;
173 
175  public: std::size_t GetIndex() const;
176 
179  public: WorldPtrType GetWorld();
180 
182  public: ConstWorldPtrType GetWorld() const;
183  };
184 
185  public: template <typename PolicyT>
186  class Implementation : public virtual Feature::Implementation<PolicyT>
187  {
188  public: virtual std::size_t GetModelCount(
189  const Identity &_worldID) const = 0;
190 
191  public: virtual Identity GetModel(
192  const Identity &_worldID, std::size_t _modelIndex) const = 0;
193 
194  public: virtual Identity GetModel(
195  const Identity &_worldID, const std::string &_modelName) const = 0;
196 
197  public: virtual const std::string &GetModelName(
198  const Identity &_modelID) const = 0;
199 
200  public: virtual std::size_t GetModelIndex(
201  const Identity &_modelID) const = 0;
202 
203  public: virtual Identity GetWorldOfModel(
204  const Identity &_modelID) const = 0;
205  };
206  };
207 
208  class IGNITION_PHYSICS_VISIBLE GetLinkFromModel : public virtual Feature
209  {
210  public: template <typename PolicyT, typename FeaturesT>
211  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
212  {
213  // typedefs for the type of Link that this Model can return
214  public: using LinkPtrType = LinkPtr<PolicyT, FeaturesT>;
215  public: using ConstLinkPtrType = ConstLinkPtr<PolicyT, FeaturesT>;
216 
218  public: std::size_t GetLinkCount() const;
219 
225  public: LinkPtrType GetLink(std::size_t _index);
226 
228  public: ConstLinkPtrType GetLink(std::size_t _index) const;
229 
235  public: LinkPtrType GetLink(const std::string &_name);
236 
238  public: ConstLinkPtrType GetLink(const std::string &_name) const;
239  };
240 
241  public: template <typename PolicyT, typename FeaturesT>
242  class Link : public virtual Feature::Link<PolicyT, FeaturesT>
243  {
244  // typedefs for the type of Model that this Link can return
245  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
246  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
247 
249  public: const std::string &GetName() const;
250 
252  public: std::size_t GetIndex() const;
253 
256  public: ModelPtrType GetModel();
257 
259  public: ConstModelPtrType GetModel() const;
260  };
261 
262  public: template <typename PolicyT>
263  class Implementation : public virtual Feature::Implementation<PolicyT>
264  {
265  public: virtual std::size_t GetLinkCount(
266  const Identity &_modelID) const = 0;
267 
268  public: virtual Identity GetLink(
269  const Identity &_modelID, std::size_t _linkIndex) const = 0;
270 
271  public: virtual Identity GetLink(
272  const Identity &_modelID, const std::string &_linkName) const = 0;
273 
274  public: virtual const std::string &GetLinkName(
275  const Identity &_linkID) const = 0;
276 
277  public: virtual std::size_t GetLinkIndex(
278  const Identity &_linkID) const = 0;
279 
280  public: virtual Identity GetModelOfLink(
281  const Identity &_linkID) const = 0;
282  };
283  };
284 
285  class IGNITION_PHYSICS_VISIBLE GetJointFromModel : public virtual Feature
286  {
287  public: template <typename PolicyT, typename FeaturesT>
288  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
289  {
290  // typedefs for the type of Joint that this Model can return
291  public: using JointPtrType = JointPtr<PolicyT, FeaturesT>;
292  public: using ConstJointPtrType = ConstJointPtr<PolicyT, FeaturesT>;
293 
295  public: std::size_t GetJointCount() const;
296 
302  public: JointPtrType GetJoint(std::size_t _index);
303 
305  public: ConstJointPtrType GetJoint(std::size_t _index) const;
306 
312  public: JointPtrType GetJoint(const std::string &_name);
313 
315  public: ConstJointPtrType GetJoint(const std::string &_name) const;
316  };
317 
318  public: template <typename PolicyT, typename FeaturesT>
319  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
320  {
321  // typedefs for the type of Model that this Link can return
322  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
323  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
324 
326  public: const std::string &GetName() const;
327 
329  public: std::size_t GetIndex() const;
330 
333  public: ModelPtrType GetModel();
334 
336  public: ConstModelPtrType GetModel() const;
337  };
338 
339  public: template <typename PolicyT>
340  class Implementation : public virtual Feature::Implementation<PolicyT>
341  {
342  public: virtual std::size_t GetJointCount(
343  const Identity &_modelID) const = 0;
344 
345  public: virtual Identity GetJoint(
346  const Identity &_modelID, std::size_t _jointIndex) const = 0;
347 
348  public: virtual Identity GetJoint(
349  const Identity &_modelID, const std::string &_jointName) const = 0;
350 
351  public: virtual const std::string &GetJointName(
352  const Identity &_jointID) const = 0;
353 
354  public: virtual std::size_t GetJointIndex(
355  const Identity &_jointID) const = 0;
356 
357  public: virtual Identity GetModelOfJoint(
358  const Identity &_jointID) const = 0;
359  };
360  };
361 
362  class IGNITION_PHYSICS_VISIBLE GetShapeFromLink : public virtual Feature
363  {
364  public: template <typename PolicyT, typename FeaturesT>
365  class Link : public virtual Feature::Link<PolicyT, FeaturesT>
366  {
367  // typedefs for the type of Shape that this Link can return
368  public: using ShapePtrType = ShapePtr<PolicyT, FeaturesT>;
369  public: using ConstShapePtrType = ConstShapePtr<PolicyT, FeaturesT>;
370 
372  public: std::size_t GetShapeCount() const;
373 
379  public: ShapePtrType GetShape(std::size_t _index);
380 
382  public: ConstShapePtrType GetShape(std::size_t _index) const;
383 
389  public: ShapePtrType GetShape(const std::string &_name);
390 
392  public: ConstShapePtrType GetShape(const std::string &_name) const;
393  };
394 
395  public: template <typename PolicyT, typename FeaturesT>
396  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
397  {
398  // typedefs for the type of Link that this Shape can return
399  public: using LinkPtrType = LinkPtr<PolicyT, FeaturesT>;
400  public: using ConstLinkPtrType = ConstLinkPtr<PolicyT, FeaturesT>;
401 
403  public: const std::string &GetName() const;
404 
406  public: std::size_t GetIndex() const;
407 
410  public: LinkPtrType GetLink();
411 
413  public: ConstLinkPtrType GetLink() const;
414  };
415 
416  public: template <typename PolicyT>
417  class Implementation : public virtual Feature::Implementation<PolicyT>
418  {
419  public: virtual std::size_t GetShapeCount(
420  const Identity &_linkID) const = 0;
421 
422  public: virtual Identity GetShape(
423  const Identity &_linkID, std::size_t _shapeIndex) const = 0;
424 
425  public: virtual Identity GetShape(
426  const Identity &_linkID, const std::string &_shapeName) const = 0;
427 
428  public: virtual const std::string &GetShapeName(
429  const Identity &_shapeID) const = 0;
430 
431  public: virtual std::size_t GetShapeIndex(
432  const Identity &_shapeID) const = 0;
433 
434  public: virtual Identity GetLinkOfShape(
435  const Identity &_shapeID) const = 0;
436  };
437  };
438 
440  GetEngineInfo,
441  GetWorldFromEngine,
442  GetModelFromWorld,
443  GetLinkFromModel,
444  GetJointFromModel,
445  GetShapeFromLink
446  > { };
447  }
448 }
449 
450 #include <ignition/physics/detail/GetEntities.hh>
451 
452 #endif
Placeholder class in case a Feature does not define its own Shape API.
Definition: Feature.hh:85
ConstModelPtr< PolicyT, FeaturesT > ConstModelPtrType
Definition: GetEntities.hh:138
JointPtr< PolicyT, FeaturesT > JointPtrType
Definition: GetEntities.hh:291
Definition: GetEntities.hh:165
ConstJointPtr< PolicyT, FeaturesT > ConstJointPtrType
Definition: GetEntities.hh:292
Definition: GetEntities.hh:29
This class defines the concept of a Feature. It should be inherited by classes that define some plugi...
Definition: Feature.hh:35
Definition: GetEntities.hh:32
Definition: GetEntities.hh:134
STL class.
ConstLinkPtr< PolicyT, FeaturesT > ConstLinkPtrType
Definition: GetEntities.hh:215
ModelPtr< PolicyT, FeaturesT > ModelPtrType
Definition: GetEntities.hh:322
WorldPtr< PolicyT, FeaturesT > WorldPtrType
Definition: GetEntities.hh:60
Definition: GetEntities.hh:211
ModelPtr< PolicyT, FeaturesT > ModelPtrType
Definition: GetEntities.hh:137
Placeholder class in case a Feature does not define its own Joint API.
Definition: Feature.hh:76
Placeholder class for the Engine API. Every Engine feature MUST inherit this class.
Definition: Feature.hh:40
Definition: GetEntities.hh:288
Definition: GetEntities.hh:319
Placeholder class in case a Feature does not define its own World API.
Definition: Feature.hh:49
Placeholder class in case a Feature does not define its own Model API.
Definition: Feature.hh:58
Definition: GetEntities.hh:54
WorldPtr< PolicyT, FeaturesT > WorldPtrType
Definition: GetEntities.hh:168
ConstModelPtr< PolicyT, FeaturesT > ConstModelPtrType
Definition: GetEntities.hh:323
LinkPtr< PolicyT, FeaturesT > LinkPtrType
Definition: GetEntities.hh:214
ConstEnginePtr< PolicyT, FeaturesT > ConstEnginePtrType
Definition: GetEntities.hh:92
Definition: GetEntities.hh:131
Definition: GetEntities.hh:208
Definition: GetEntities.hh:439
Definition: GetEntities.hh:285
ConstWorldPtr< PolicyT, FeaturesT > ConstWorldPtrType
Definition: GetEntities.hh:61
Use a FeatureList to aggregate a list of Features.
Definition: FeatureList.hh:51
EnginePtr< PolicyT, FeaturesT > EnginePtrType
Definition: GetEntities.hh:91
ConstWorldPtr< PolicyT, FeaturesT > ConstWorldPtrType
Definition: GetEntities.hh:169