Drake
query_handle.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstddef>
4 
6 
7 namespace drake {
8 
9 namespace systems {
10 template <typename T> class Context;
11 }
12 
13 namespace geometry {
14 
15 template <typename T> class GeometrySystem;
16 
40 template <typename T>
41 class QueryHandle {
42  public:
44 
45  private:
46  // Allow GeometrySystem unique access to getting the context back out.
47  friend class GeometrySystem<T>;
48  friend class QueryHandleTester;
49 
50  // Only the GeometrySystem<T> can create this class.
51  QueryHandle(const systems::Context<T>* context, size_t guard)
52  : context_(context), guard_(guard) {}
53 
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 };
65 
66 } // namespace geometry
67 } // namespace drake
GeometrySystem serves as a system-level wrapper for GeometryWorld.
Definition: geometry_state.h:25
Definition: automotive_demo.cc:88
std::unique_ptr< systems::Context< double > > context_
Definition: bicycle_car_test.cc:63
Context is an abstract base class template that represents all the inputs to a System: time...
Definition: query_handle.h:10
#define DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname)
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:59
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...