Gazebo Physics

API Reference

6.5.1
gz/physics/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 GZ_PHYSICS_GETENTITIES_HH_
19 #define GZ_PHYSICS_GETENTITIES_HH_
20 
21 #include <string>
22 
24 
25 namespace gz
26 {
27  namespace physics
28  {
31  class GZ_PHYSICS_VISIBLE GetEngineInfo : public virtual Feature
32  {
33  public: template <typename PolicyT, typename FeaturesT>
34  class Engine : public virtual Feature::Engine<PolicyT, FeaturesT>
35  {
38  public: const std::string &GetName() const;
39 
42  public: std::size_t GetIndex() const;
43  };
44 
45  public: template <typename PolicyT>
46  class Implementation : public virtual Feature::Implementation<PolicyT>
47  {
48  public: virtual const std::string &GetEngineName(
49  const Identity &_engineID) const = 0;
50 
51  public: virtual std::size_t GetEngineIndex(
52  const Identity &_engineID) const = 0;
53  };
54  };
55 
59  class GZ_PHYSICS_VISIBLE GetWorldFromEngine : public virtual Feature
60  {
61  public: template <typename PolicyT, typename FeaturesT>
62  class Engine : public virtual Feature::Engine<PolicyT, FeaturesT>
63  {
64  // typedefs for the type of World that this engine can return.
65  public: using WorldPtrType = WorldPtr<PolicyT, FeaturesT>;
66  public: using ConstWorldPtrType = ConstWorldPtr<PolicyT, FeaturesT>;
67 
69  public: std::size_t GetWorldCount() const;
70 
76  public: WorldPtrType GetWorld(std::size_t _index);
77 
79  public: ConstWorldPtrType GetWorld(std::size_t _index) const;
80 
86  public: WorldPtrType GetWorld(const std::string &_name);
87 
89  public: ConstWorldPtrType GetWorld(const std::string &_name) const;
90  };
91 
92  public: template <typename PolicyT, typename FeaturesT>
93  class World : public virtual Feature::World<PolicyT, FeaturesT>
94  {
95  // typedefs for the type of Engine that this World can return
96  public: using EnginePtrType = EnginePtr<PolicyT, FeaturesT>;
97  public: using ConstEnginePtrType = ConstEnginePtr<PolicyT, FeaturesT>;
98 
100  public: const std::string &GetName() const;
101 
103  public: std::size_t GetIndex() const;
104 
107  public: EnginePtrType GetEngine();
108 
110  public: ConstEnginePtrType GetEngine() const;
111  };
112 
113  public: template <typename PolicyT>
114  class Implementation : public virtual Feature::Implementation<PolicyT>
115  {
116  public: virtual std::size_t GetWorldCount(
117  const Identity &_engineID) const = 0;
118 
119  public: virtual Identity GetWorld(
120  const Identity &_engineID, std::size_t _worldIndex) const = 0;
121 
122  public: virtual Identity GetWorld(
123  const Identity &_engineID, const std::string &_worldName) const = 0;
124 
125  public: virtual const std::string &GetWorldName(
126  const Identity &_worldID) const = 0;
127 
128  public: virtual std::size_t GetWorldIndex(
129  const Identity &_worldID) const = 0;
130 
131  public: virtual Identity GetEngineOfWorld(
132  const Identity &_worldID) const = 0;
133  };
134  };
135 
139  class GZ_PHYSICS_VISIBLE GetModelFromWorld : public virtual Feature
140  {
141  public: template <typename PolicyT, typename FeaturesT>
142  class World : public virtual Feature::World<PolicyT, FeaturesT>
143  {
144  // typedefs for the type of Model that this World can return
145  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
146  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
147 
149  public: std::size_t GetModelCount() const;
150 
156  public: ModelPtrType GetModel(std::size_t _index);
157 
159  public: ConstModelPtrType GetModel(std::size_t _index) const;
160 
166  public: ModelPtrType GetModel(const std::string &_name);
167 
169  public: ConstModelPtrType GetModel(const std::string &_name) const;
170  };
171 
172  public: template <typename PolicyT, typename FeaturesT>
173  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
174  {
175  // typedefs for the type of World that this Model can return
176  public: using WorldPtrType = WorldPtr<PolicyT, FeaturesT>;
177  public: using ConstWorldPtrType = ConstWorldPtr<PolicyT, FeaturesT>;
178 
180  public: const std::string &GetName() const;
181 
183  public: std::size_t GetIndex() const;
184 
187  public: WorldPtrType GetWorld();
188 
190  public: ConstWorldPtrType GetWorld() const;
191  };
192 
193  public: template <typename PolicyT>
194  class Implementation : public virtual Feature::Implementation<PolicyT>
195  {
196  public: virtual std::size_t GetModelCount(
197  const Identity &_worldID) const = 0;
198 
199  public: virtual Identity GetModel(
200  const Identity &_worldID, std::size_t _modelIndex) const = 0;
201 
202  public: virtual Identity GetModel(
203  const Identity &_worldID, const std::string &_modelName) const = 0;
204 
205  public: virtual const std::string &GetModelName(
206  const Identity &_modelID) const = 0;
207 
208  public: virtual std::size_t GetModelIndex(
209  const Identity &_modelID) const = 0;
210 
211  public: virtual Identity GetWorldOfModel(
212  const Identity &_modelID) const = 0;
213  };
214  };
215 
219  class GZ_PHYSICS_VISIBLE GetNestedModelFromModel
220  : public virtual FeatureWithRequirements<GetModelFromWorld>
221  {
222  public: template <typename PolicyT, typename FeaturesT>
223  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
224  {
225  // typedefs for the type of Model that this Model can return
226  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
227  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
228 
230  public: std::size_t GetNestedModelCount() const;
231 
237  public: ModelPtrType GetNestedModel(std::size_t _index);
238 
240  public: ConstModelPtrType GetNestedModel(std::size_t _index) const;
241 
247  public: ModelPtrType GetNestedModel(const std::string &_name);
248 
250  public: ConstModelPtrType GetNestedModel(
251  const std::string &_name) const;
252  };
253 
254  public: template <typename PolicyT>
255  class Implementation : public virtual Feature::Implementation<PolicyT>
256  {
257  public: virtual std::size_t GetNestedModelCount(
258  const Identity &_modelID) const = 0;
259 
260  public: virtual Identity GetNestedModel(
261  const Identity &_modelID, std::size_t _modelIndex) const = 0;
262 
263  public: virtual Identity GetNestedModel(
264  const Identity &_modelID, const std::string &_modelName) const = 0;
265  };
266  };
267 
271  class GZ_PHYSICS_VISIBLE GetLinkFromModel : public virtual Feature
272  {
273  public: template <typename PolicyT, typename FeaturesT>
274  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
275  {
276  // typedefs for the type of Link that this Model can return
277  public: using LinkPtrType = LinkPtr<PolicyT, FeaturesT>;
278  public: using ConstLinkPtrType = ConstLinkPtr<PolicyT, FeaturesT>;
279 
281  public: std::size_t GetLinkCount() const;
282 
288  public: LinkPtrType GetLink(std::size_t _index);
289 
291  public: ConstLinkPtrType GetLink(std::size_t _index) const;
292 
298  public: LinkPtrType GetLink(const std::string &_name);
299 
301  public: ConstLinkPtrType GetLink(const std::string &_name) const;
302  };
303 
304  public: template <typename PolicyT, typename FeaturesT>
305  class Link : public virtual Feature::Link<PolicyT, FeaturesT>
306  {
307  // typedefs for the type of Model that this Link can return
308  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
309  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
310 
312  public: const std::string &GetName() const;
313 
315  public: std::size_t GetIndex() const;
316 
319  public: ModelPtrType GetModel();
320 
322  public: ConstModelPtrType GetModel() const;
323  };
324 
325  public: template <typename PolicyT>
326  class Implementation : public virtual Feature::Implementation<PolicyT>
327  {
328  public: virtual std::size_t GetLinkCount(
329  const Identity &_modelID) const = 0;
330 
331  public: virtual Identity GetLink(
332  const Identity &_modelID, std::size_t _linkIndex) const = 0;
333 
334  public: virtual Identity GetLink(
335  const Identity &_modelID, const std::string &_linkName) const = 0;
336 
337  public: virtual const std::string &GetLinkName(
338  const Identity &_linkID) const = 0;
339 
340  public: virtual std::size_t GetLinkIndex(
341  const Identity &_linkID) const = 0;
342 
343  public: virtual Identity GetModelOfLink(
344  const Identity &_linkID) const = 0;
345  };
346  };
347 
351  class GZ_PHYSICS_VISIBLE GetJointFromModel : public virtual Feature
352  {
353  public: template <typename PolicyT, typename FeaturesT>
354  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
355  {
356  // typedefs for the type of Joint that this Model can return
357  public: using JointPtrType = JointPtr<PolicyT, FeaturesT>;
358  public: using ConstJointPtrType = ConstJointPtr<PolicyT, FeaturesT>;
359 
361  public: std::size_t GetJointCount() const;
362 
368  public: JointPtrType GetJoint(std::size_t _index);
369 
371  public: ConstJointPtrType GetJoint(std::size_t _index) const;
372 
378  public: JointPtrType GetJoint(const std::string &_name);
379 
381  public: ConstJointPtrType GetJoint(const std::string &_name) const;
382  };
383 
384  public: template <typename PolicyT, typename FeaturesT>
385  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
386  {
387  // typedefs for the type of Model that this Link can return
388  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
389  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
390 
392  public: const std::string &GetName() const;
393 
395  public: std::size_t GetIndex() const;
396 
399  public: ModelPtrType GetModel();
400 
402  public: ConstModelPtrType GetModel() const;
403  };
404 
405  public: template <typename PolicyT>
406  class Implementation : public virtual Feature::Implementation<PolicyT>
407  {
408  public: virtual std::size_t GetJointCount(
409  const Identity &_modelID) const = 0;
410 
411  public: virtual Identity GetJoint(
412  const Identity &_modelID, std::size_t _jointIndex) const = 0;
413 
414  public: virtual Identity GetJoint(
415  const Identity &_modelID, const std::string &_jointName) const = 0;
416 
417  public: virtual const std::string &GetJointName(
418  const Identity &_jointID) const = 0;
419 
420  public: virtual std::size_t GetJointIndex(
421  const Identity &_jointID) const = 0;
422 
423  public: virtual Identity GetModelOfJoint(
424  const Identity &_jointID) const = 0;
425  };
426  };
427 
431  class GZ_PHYSICS_VISIBLE GetShapeFromLink : public virtual Feature
432  {
433  public: template <typename PolicyT, typename FeaturesT>
434  class Link : public virtual Feature::Link<PolicyT, FeaturesT>
435  {
436  // typedefs for the type of Shape that this Link can return
437  public: using ShapePtrType = ShapePtr<PolicyT, FeaturesT>;
438  public: using ConstShapePtrType = ConstShapePtr<PolicyT, FeaturesT>;
439 
441  public: std::size_t GetShapeCount() const;
442 
448  public: ShapePtrType GetShape(std::size_t _index);
449 
451  public: ConstShapePtrType GetShape(std::size_t _index) const;
452 
458  public: ShapePtrType GetShape(const std::string &_name);
459 
461  public: ConstShapePtrType GetShape(const std::string &_name) const;
462  };
463 
464  public: template <typename PolicyT, typename FeaturesT>
465  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
466  {
467  // typedefs for the type of Link that this Shape can return
468  public: using LinkPtrType = LinkPtr<PolicyT, FeaturesT>;
469  public: using ConstLinkPtrType = ConstLinkPtr<PolicyT, FeaturesT>;
470 
472  public: const std::string &GetName() const;
473 
475  public: std::size_t GetIndex() const;
476 
479  public: LinkPtrType GetLink();
480 
482  public: ConstLinkPtrType GetLink() const;
483  };
484 
485  public: template <typename PolicyT>
486  class Implementation : public virtual Feature::Implementation<PolicyT>
487  {
488  public: virtual std::size_t GetShapeCount(
489  const Identity &_linkID) const = 0;
490 
491  public: virtual Identity GetShape(
492  const Identity &_linkID, std::size_t _shapeIndex) const = 0;
493 
494  public: virtual Identity GetShape(
495  const Identity &_linkID, const std::string &_shapeName) const = 0;
496 
497  public: virtual const std::string &GetShapeName(
498  const Identity &_shapeID) const = 0;
499 
500  public: virtual std::size_t GetShapeIndex(
501  const Identity &_shapeID) const = 0;
502 
503  public: virtual Identity GetLinkOfShape(
504  const Identity &_shapeID) const = 0;
505  };
506  };
507 
524  class GZ_PHYSICS_VISIBLE WorldModelFeature : public virtual Feature
525  {
526  public: template <typename PolicyT, typename FeaturesT>
527  class World: public virtual Feature::World<PolicyT, FeaturesT>
528  {
529  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
530  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
531 
533  public: ModelPtrType GetWorldModel();
534 
536  public: ConstModelPtrType GetWorldModel() const;
537  };
538 
539  public: template <typename PolicyT>
540  class Implementation : public virtual Feature::Implementation<PolicyT>
541  {
542  public:
543  virtual Identity GetWorldModel(const Identity &_worldID) const = 0;
544  };
545  };
546 
548  GetEngineInfo,
549  GetWorldFromEngine,
550  GetModelFromWorld,
551  GetNestedModelFromModel,
552  GetLinkFromModel,
553  GetJointFromModel,
554  GetShapeFromLink
555  > { };
556  }
557 }
558 
559 #include <gz/physics/detail/GetEntities.hh>
560 
561 #endif