Drake
LeafOutputPort< T > Class Template Reference

Adds methods for allocation, calculation, and caching of an output port's value. More...

#include <drake/systems/framework/leaf_output_port.h>

Inheritance diagram for LeafOutputPort< T >:
[legend]
Collaboration diagram for LeafOutputPort< T >:
[legend]

Public Types

using AllocCallback = std::function< std::unique_ptr< AbstractValue >(const Context< T > &)>
 Signature of a function suitable for allocating an object that can hold a value of a particular output port. More...
 
using CalcCallback = std::function< void(const Context< T > &, AbstractValue *)>
 Signature of a function suitable for calculating a value of a particular output port, given a place to put the value. More...
 
using CalcVectorCallback = std::function< void(const Context< T > &, BasicVector< T > *)>
 Signature of a function suitable for calculating a value of a particular vector-valued output port, given a place to put the value. More...
 
using EvalCallback = std::function< const AbstractValue &(const Context< T > &)>
 Signature of a function suitable for obtaining the cached value of a particular output port. More...
 

Public Member Functions

 ~LeafOutputPort () override=default
 
 LeafOutputPort (const System< T > &system, AllocCallback alloc_function, CalcCallback calc_function)
 Constructs an abstract-valued output port. More...
 
 LeafOutputPort (const System< T > &system, int fixed_size, AllocCallback vector_alloc_function, CalcVectorCallback vector_calc_function)
 Constructs a fixed-size vector-valued output port. More...
 
void set_evaluation_function (EvalCallback eval_function)
 (Advanced) Sets or replaces the evaluation function for this output port, using a function that returns an AbstractValue. More...
 
Does not allow copy, move, or assignment
 LeafOutputPort (const LeafOutputPort &)=delete
 
LeafOutputPortoperator= (const LeafOutputPort &)=delete
 
 LeafOutputPort (LeafOutputPort &&)=delete
 
LeafOutputPortoperator= (LeafOutputPort &&)=delete
 
- Public Member Functions inherited from OutputPort< T >
virtual ~OutputPort ()=default
 
std::unique_ptr< AbstractValueAllocate (const Context< T > &context) const
 Allocates a concrete object suitable for holding the value to be exposed by this output port, and returns that as an AbstractValue. More...
 
void Calc (const Context< T > &context, AbstractValue *value) const
 Unconditionally computes the value of this output port with respect to the given context, into an already-allocated AbstractValue object whose concrete type must be exactly the same as the type returned by this port's allocator. More...
 
const AbstractValueEval (const Context< T > &context) const
 Returns a reference to the value of this output port contained in the given Context. More...
 
const System< T > & get_system () const
 Returns a reference to the System that owns this output port. More...
 
OutputPortIndex get_index () const
 Returns the index of this output port within the owning System. More...
 
PortDataType get_data_type () const
 Gets the port data type specified at port construction. More...
 
int size () const
 Returns the fixed size expected for a vector-valued output port. More...
 
 OutputPort (const OutputPort &)=delete
 
OutputPortoperator= (const OutputPort &)=delete
 
 OutputPort (OutputPort &&)=delete
 
OutputPortoperator= (OutputPort &&)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from OutputPort< T >
 OutputPort (const System< T > &system, PortDataType data_type, int size)
 Provides derived classes the ability to set the base class members at construction. More...
 
std::string GetPortIdString () const
 This is useful for error messages and produces "output port \<#\> of GetSystemIdString()" with whatever System identification string is produced by that method. More...
 

Detailed Description

template<typename T>
class drake::systems::LeafOutputPort< T >

Adds methods for allocation, calculation, and caching of an output port's value.

When created, an allocation and a calculation function must be provided. The output type of the calculation callback must match the type returned by the allocation function.

Template Parameters
TThe vector element type, which must be a valid Eigen scalar.

Instantiated templates for the following kinds of T's are provided:

They are already available to link against in the containing library. No other values for T are currently supported.

Member Typedef Documentation

using AllocCallback = std::function<std::unique_ptr<AbstractValue>( const Context<T>&)>

Signature of a function suitable for allocating an object that can hold a value of a particular output port.

The result is returned as an AbstractValue even if this is a vector-valued port.

using CalcCallback = std::function<void(const Context<T>&, AbstractValue*)>

Signature of a function suitable for calculating a value of a particular output port, given a place to put the value.

using CalcVectorCallback = std::function<void(const Context<T>&, BasicVector<T>*)>

Signature of a function suitable for calculating a value of a particular vector-valued output port, given a place to put the value.

using EvalCallback = std::function<const AbstractValue&(const Context<T>&)>

Signature of a function suitable for obtaining the cached value of a particular output port.

Constructor & Destructor Documentation

LeafOutputPort ( const LeafOutputPort< T > &  )
delete
LeafOutputPort ( LeafOutputPort< T > &&  )
delete
~LeafOutputPort ( )
overridedefault
LeafOutputPort ( const System< T > &  system,
AllocCallback  alloc_function,
CalcCallback  calc_function 
)
inline

Constructs an abstract-valued output port.

The supplied allocator must return a suitable AbstractValue in which to hold the result. The supplied calculator function must write to an AbstractValue of the same underlying concrete type as is returned by the allocator. The allocator function is not invoked here during construction of the port so it may depend on data that becomes available only after completion of the containing System or Diagram.

LeafOutputPort ( const System< T > &  system,
int  fixed_size,
AllocCallback  vector_alloc_function,
CalcVectorCallback  vector_calc_function 
)
inline

Constructs a fixed-size vector-valued output port.

The supplied allocator must return a Value<BasicVector> of the correct size in which to hold the result. The supplied calculator function must write to a BasicVector of the same underlying concrete type as is returned by the allocator. Requires the fixed size to be given explicitly here. The allocator function is not invoked here during construction of the port so it may depend on data that becomes available only after completion of the containing System or Diagram.

Member Function Documentation

LeafOutputPort& operator= ( const LeafOutputPort< T > &  )
delete
LeafOutputPort& operator= ( LeafOutputPort< T > &&  )
delete
void set_evaluation_function ( EvalCallback  eval_function)
inline

(Advanced) Sets or replaces the evaluation function for this output port, using a function that returns an AbstractValue.

By default, an evaluation function is automatically provided that calls the calculation function.


The documentation for this class was generated from the following files: