Go to the documentation of this file.
1 #pragma once
3 #include <cstddef>
7 namespace drake {
9 namespace systems {
10 template <typename T> class Context;
11 }
13 namespace geometry {
15 template <typename T> class GeometrySystem;
17 /** The %QueryHandle serves as a mechanism to allow LeafSystem instances to
18  perform geometry queries on GeometrySystem. One of the GeometrySystem output
19  ports is abstract-valued on the %QueryHandle.
21  From the perspective of every class _except_ GeometrySystem, this class should
22  simply be considered a ticket of sorts; acquired _from_ a GeometrySystem
23  instance, it is provided in calls to query methods.
25  To perform geometry queries on GeometrySystem:
26  - a LeafSystem must have a %QueryHandle-valued input port and connect it to
27  the corresponding query output port on GeometrySystem,
28  - the querying LeafSystem can evaluate the input port, retrieving a `const
29  QueryHandle*` in return, and, finally,
30  - the acquired handle is passed into query methods invoked on a pointer to
31  the GeometrySystem.
33  @internal There are no public methods. By design, GeometrySystem is the only
34  entity that can read and write the single data member. Every other entity
35  simply gets the value and passes it around.
36  @endinternal
38  @tparam T The underlying scalar type. Must be a valid Eigen scalar.
39  @sa GeometrySystem */
40 template <typename T>
41 class QueryHandle {
42  public:
45  private:
46  // Allow GeometrySystem unique access to getting the context back out.
47  friend class GeometrySystem<T>;
48  friend class QueryHandleTester;
50  // Only the GeometrySystem<T> can create this class.
51  QueryHandle(const systems::Context<T>* context, size_t guard)
52  : context_(context), guard_(guard) {}
54  // The context associated with the current handle.
56  // Serves as a hash of the state in which this QueryHandle was constructed.
57  // Serves to catch usage of a QueryHandle beyond its lifespan. The member is
58  // a size_t because std::hash returns a size_t.
59  // NOTE: This is a short-term solution. Ultimately, QueryHandle would have
60  // appropriate copy semantics such that copying it out of the AbstractValue
61  // will create a version of the handle that is divorced from the underlying
62  // Context.
63  size_t guard_{};
64 };
66 } // namespace geometry
67 } // namespace drake
GeometrySystem serves as a system-level wrapper for GeometryWorld.
Definition: geometry_state.h:26
Definition: automotive_demo.cc:88
std::unique_ptr< systems::Context< double > > context_
Definition: bicycle_car_test.cc:64
Context is an abstract base class template that represents all the inputs to a System: time...
Definition: query_handle.h:10
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN defaults the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:57
The QueryHandle serves as a mechanism to allow LeafSystem instances to perform geometry queries on Ge...
Definition: query_handle.h:41
Provides careful macros to selectively enable or disable the special member functions for copy-constr...