Go to the documentation of this file.
1 #pragma once
8 namespace drake {
9 namespace systems {
11 template <typename T>
12 class System;
14 /// This extends InputPortBase with some scalar type-dependent methods.
15 ///
16 /// @tparam T The mathematical type of the context, which must be a valid Eigen
17 /// scalar.
18 template <typename T>
19 class InputPortDescriptor final : public InputPortBase {
20  public:
25  /// (Internal use only)
26  /// Constructs a type-specific input port. See InputPortBase::InputPortBase()
27  /// for the meaning of these parameters. The additional `system` parameter
28  /// here must be the same object as the `system_base` parameter.
29  // The System and SystemBase are provided separately since we don't have
30  // access to System's declaration here so can't cast but the caller can.
32  PortDataType data_type, int size,
33  const optional<RandomDistribution>& random_type,
34  const System<T>* system, SystemBase* system_base)
35  : InputPortBase(index, ticket, data_type, size, random_type, system_base),
36  system_(*system) {
37  DRAKE_DEMAND(system != nullptr);
38  DRAKE_DEMAND(static_cast<const void*>(system) == system_base);
39  }
41  /// Returns a reference to the System that owns this input port. Note that
42  /// for a Diagram input port this will be the Diagram, not the LeafSystem
43  /// whose input port was exported.
44  // TODO(sherm1) Switch to an actual reference.
45  const System<T>* get_system() const { return &system_; }
47  private:
48  const System<T>& system_;
49 };
51 } // namespace systems
52 } // namespace drake
int size() const
Returns the fixed size expected for a vector-valued input port.
Definition: input_port_base.h:47
Definition: automotive_demo.cc:90
This extends InputPortBase with some scalar type-dependent methods.
Definition: input_port_descriptor.h:19
stx::optional< T > optional
Definition: drake_optional.h:22
DependencyTicket ticket() const
Returns the DependencyTicket for this input port within the owning System.
Definition: input_port_base.h:33
#define DRAKE_DEMAND(condition)
Evaluates condition and iff the value is false will trigger an assertion failure with a message showi...
Definition: drake_assert.h:45
Provides drake::optional as an alias for the appropriate implementation of std::optional or std::expe...
Base class for all System functionality that is dependent on the templatized scalar type T for input...
Definition: input_port_descriptor.h:12
Provides non-templatized functionality shared by the templatized System classes.
Definition: system_base.h:27
InputPortDescriptor(InputPortIndex index, DependencyTicket ticket, PortDataType data_type, int size, const optional< RandomDistribution > &random_type, const System< T > *system, SystemBase *system_base)
(Internal use only) Constructs a type-specific input port.
Definition: input_port_descriptor.h:31
const System< T > * get_system() const
Returns a reference to the System that owns this input port.
Definition: input_port_descriptor.h:45
~InputPortDescriptor() final
Definition: input_port_descriptor.h:23
All system ports are either vectors of Eigen scalars, or black-box AbstractValues which may contain a...
Definition: framework_common.h:64
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:33
A type-safe non-negative index class.
Definition: type_safe_index.h:155
An InputPort is a System resource that describes the kind of input a System accepts, on a given port.
Definition: input_port_base.h:20