API  4.3
For MATLAB, Python, Java, and C++ users
OpenSim::Input< T > Class Template Reference

An Input<Y> must be connected by an Output<Y> More...

+ Inheritance diagram for OpenSim::Input< T >:

Public Member Functions

Input< T > * clone () const override
 Create a dynamically-allocated copy. More...
 
void connect (const AbstractOutput &output, const std::string &alias="") override
 Connect this Input to the provided (Abstract)Output. More...
 
void connect (const AbstractChannel &channel, const std::string &alias="") override
 Connect this Input to a single output channel. More...
 
void finalizeConnection (const Component &root) override
 Connect this Input given a root Component to search for the Output according to the connectee path of this Input. More...
 
void disconnect () override
 Clear references to connectees. More...
 
bool isConnected () const override
 Derived classes must satisfy this Interface. More...
 
const T & getValue (const SimTK::State &state) const
 Get the value of this Input when it is connected. More...
 
const T & getValue (const SimTK::State &state, unsigned index) const
 Get the value of this Input when it is connected. More...
 
const ChannelgetChannel () const
 Get the Channel associated with this Input. More...
 
const ChannelgetChannel (unsigned index) const
 Get the Channel associated with this Input. More...
 
const std::string & getAlias () const override
 Get the alias for a Channel. More...
 
const std::string & getAlias (unsigned index) const override
 Get the alias for the Channel indicated by the provided index. More...
 
void setAlias (const std::string &alias) override
 Set the alias for a Channel. More...
 
void setAlias (unsigned index, const std::string &alias) override
 Set the alias for the Channel indicated by the provided index. More...
 
std::string getLabel () const override
 Get the label for this Channel. More...
 
std::string getLabel (unsigned index) const override
 Get the label for the Channel indicated by the provided index. More...
 
SimTK::Vector_< T > getVector (const SimTK::State &state) const
 Access the values of all the channels connected to this Input as a SimTK::Vector_<T>. More...
 
const ChannelListgetChannels () const
 Get const access to the channels connected to this input. More...
 
std::string getConnecteeTypeName () const override
 Return the typename of the Output value, T, that satisfies this Input<T>. More...
 
 SimTK_DOWNCAST (Input, AbstractInput)
 
- Public Member Functions inherited from OpenSim::AbstractInput
virtual ~AbstractInput ()
 
void connect (const Object &object) override
 Connect this Socket to the provided connectee object. More...
 
- Public Member Functions inherited from OpenSim::AbstractSocket
virtual ~AbstractSocket ()
 
const std::string & getName () const
 
SimTK::Stage getConnectAtStage () const
 Get the system Stage when the connection should be made. More...
 
bool isListSocket () const
 Can this Socket have more than one connectee? More...
 
unsigned getNumConnectees () const
 The number of slots to fill in order to satisfy this socket. More...
 
virtual const ObjectgetConnecteeAsObject () const
 Generic access to the connectee. More...
 
virtual void findAndConnect (const ComponentPath &connectee)
 Find the connectee using a search with a partial path. More...
 
void findAndConnect (const std::string &connectee)
 Same as findAndConnect(const ComponentPath&), but using a string argument. More...
 
void setConnecteePath (const std::string &name)
 Set connectee path. More...
 
void setConnecteePath (const std::string &name, unsigned ix)
 Set connectee path of a connectee among a list of connectees. More...
 
const std::string & getConnecteePath () const
 Get connectee path. More...
 
const std::string & getConnecteePath (unsigned ix) const
 Get connectee path of a connectee among a list of connectees. More...
 
void appendConnecteePath (const std::string &name)
 
void clearConnecteePath ()
 Clear all connectee paths in the connectee path property. More...
 
const ComponentgetOwner () const
 Get owner component of this socket. More...
 

Static Public Member Functions

static Input< T > * safeDownCast (AbstractInput *base)
 For use in python/java/MATLAB bindings. More...
 
- Static Public Member Functions inherited from OpenSim::AbstractInput
static bool parseConnecteePath (const std::string &connecteePath, std::string &componentPath, std::string &outputName, std::string &channelName, std::string &alias)
 Break up a connectee path into its output path, channel name (empty for single-value outputs), and alias. More...
 
static std::string composeConnecteePath (const std::string &componentPath, const std::string &outputName, const std::string &channelName, const std::string &alias)
 Compose the connectee path from its constituents. More...
 

Detailed Description

template<class T>
class OpenSim::Input< T >

An Input<Y> must be connected by an Output<Y>

Constructor & Destructor Documentation

◆ Input()

template<class T>
OpenSim::Input< T >::Input ( const std::string &  name,
const PropertyIndex &  connecteePathIndex,
const SimTK::Stage &  connectAtStage,
Component owner 
)
inlineprotected

Create an Input<T> (Socket) that can only connect to an Output<T> name and stage at which it should be connected.

Only Component should ever construct an Input.

Parameters
namename of the Output dependency.
connecteePathIndexIndex of the property in the containing Component that holds this Input's connectee path(s).
connectAtStageStage at which Input should be connected.
ownerThe component that contains this input.

Member Typedef Documentation

◆ AliasList

template<class T>
typedef std::vector<std::string> OpenSim::Input< T >::AliasList

◆ Channel

template<class T>
typedef Output<T>::Channel OpenSim::Input< T >::Channel

◆ ChannelList

template<class T>
typedef std::vector<SimTK::ReferencePtr<const Channel> > OpenSim::Input< T >::ChannelList

Member Function Documentation

◆ clone()

template<class T>
Input<T>* OpenSim::Input< T >::clone ( ) const
inlineoverridevirtual

Create a dynamically-allocated copy.

You must manage the memory for the returned pointer. This function exists to facilitate the use of SimTK::ClonePtr<AbstractSocket>.

Implements OpenSim::AbstractInput.

◆ connect() [1/2]

template<class T >
void OpenSim::Input< T >::connect ( const AbstractOutput output,
const std::string &  alias = "" 
)
overridevirtual

Connect this Input to the provided (Abstract)Output.

Implements OpenSim::AbstractInput.

References OpenSim::AbstractOutput::getPathName(), and OpenSim::AbstractOutput::getTypeName().

◆ connect() [2/2]

template<class T >
void OpenSim::Input< T >::connect ( const AbstractChannel channel,
const std::string &  alias = "" 
)
overridevirtual

Connect this Input to a single output channel.

This method can be used with both single-valued and list Inputs. You can optionally provide an alias that will be used by the Component owning this Input to refer to the Channel.

Implements OpenSim::AbstractInput.

◆ disconnect()

template<class T>
void OpenSim::Input< T >::disconnect ( )
inlineoverridevirtual

Clear references to connectees.

The connectee path property is not affected. Calling finalizeConnection() will use the connectee path property to satisfy the socket.

Implements OpenSim::AbstractSocket.

◆ finalizeConnection()

◆ getAlias() [1/2]

template<class T>
const std::string& OpenSim::Input< T >::getAlias ( ) const
inlineoverridevirtual

Get the alias for a Channel.

An alias is a description for a Channel that is specific to how the Input will use the Channel. For example, the Component that owns this Input might expect the aliases to be the names of markers in the model. This method can be used only for non-list Inputs; for list Inputs, use the overload that takes an index. You must finalize connections (Component::finalizeConnections()) first.

Implements OpenSim::AbstractInput.

References OpenSim::AbstractSocket::isListSocket().

Referenced by OpenSim::Input< T >::getLabel().

◆ getAlias() [2/2]

template<class T>
const std::string& OpenSim::Input< T >::getAlias ( unsigned  index) const
inlineoverridevirtual

Get the alias for the Channel indicated by the provided index.

An alias is a description for a Channel that is specific to how the Input will use the Channel. For example, the Component that owns this Input might expect the aliases to be the names of markers in the model. You must finalize connections (Component::finalizeConnections()) first.

Implements OpenSim::AbstractInput.

References OpenSim::AbstractSocket::getName(), OpenSim::AbstractSocket::getNumConnectees(), and OpenSim::Input< T >::isConnected().

◆ getChannel() [1/2]

template<class T>
const Channel& OpenSim::Input< T >::getChannel ( ) const
inline

Get the Channel associated with this Input.

This method can only be used for non-list Input(s). For list Input(s), use the other overload.

References OpenSim::AbstractSocket::isListSocket().

Referenced by OpenSim::Input< T >::getLabel().

◆ getChannel() [2/2]

template<class T>
const Channel& OpenSim::Input< T >::getChannel ( unsigned  index) const
inline

Get the Channel associated with this Input.

Specify the index of the channel desired.

References OpenSim::AbstractSocket::getName(), OpenSim::AbstractSocket::getNumConnectees(), and OpenSim::Input< T >::isConnected().

◆ getChannels()

template<class T>
const ChannelList& OpenSim::Input< T >::getChannels ( ) const
inline

Get const access to the channels connected to this input.

You can use this to iterate through the channels.

for (const auto& chan : getChannels()) {
std::cout << chan.getValue(state) << std::endl;
}

◆ getConnecteeTypeName()

template<class T>
std::string OpenSim::Input< T >::getConnecteeTypeName ( ) const
inlineoverridevirtual

Return the typename of the Output value, T, that satisfies this Input<T>.

No reason to return Output<T> since it is a given that only an Output can satisfy an Input.

Implements OpenSim::AbstractSocket.

◆ getLabel() [1/2]

template<class T>
std::string OpenSim::Input< T >::getLabel ( ) const
inlineoverridevirtual

Get the label for this Channel.

If an alias has been set, the label is the alias; otherwise, the label is the full path of the Output that has been connected to this Input. This method can be used only for non-list Inputs; for list Inputs, use the single-argument overload. You must finalize connections (Component::finalizeConnections()) first.

Implements OpenSim::AbstractInput.

References OpenSim::AbstractSocket::getName(), OpenSim::Input< T >::isConnected(), and OpenSim::AbstractSocket::isListSocket().

◆ getLabel() [2/2]

template<class T>
std::string OpenSim::Input< T >::getLabel ( unsigned  index) const
inlineoverridevirtual

Get the label for the Channel indicated by the provided index.

If an alias has been set, the label is the alias; otherwise, the label is the full path of the Channel that has been connected to this Input. You must finalize connections (Component::finalizeConnections()) first.

Implements OpenSim::AbstractInput.

References OpenSim::Input< T >::getAlias(), OpenSim::Input< T >::getChannel(), OpenSim::AbstractSocket::getName(), OpenSim::AbstractSocket::getNumConnectees(), OpenSim::Output< T >::Channel::getPathName(), and OpenSim::Input< T >::isConnected().

◆ getValue() [1/2]

template<class T>
const T& OpenSim::Input< T >::getValue ( const SimTK::State &  state) const
inline

Get the value of this Input when it is connected.

Redirects to connected Output<T>'s getValue() with minimal overhead. This method can be used only for non-list Input(s). For list Input(s), use the other overload.

References OpenSim::AbstractSocket::isListSocket().

◆ getValue() [2/2]

template<class T>
const T& OpenSim::Input< T >::getValue ( const SimTK::State &  state,
unsigned  index 
) const
inline

Get the value of this Input when it is connected.

Redirects to connected Output<T>'s getValue() with minimal overhead. Specify the index of the Channel whose value is desired.

References OpenSim::AbstractSocket::getName(), OpenSim::AbstractSocket::getNumConnectees(), and OpenSim::Input< T >::isConnected().

◆ getVector()

template<class T>
SimTK::Vector_<T> OpenSim::Input< T >::getVector ( const SimTK::State &  state) const
inline

Access the values of all the channels connected to this Input as a SimTK::Vector_<T>.

The elements are in the same order as the channels.

◆ isConnected()

template<class T>
bool OpenSim::Input< T >::isConnected ( ) const
inlineoverridevirtual

Derived classes must satisfy this Interface.

Is the Socket connected to its connectee(s)? For a list socket, this is only true if this socket is connected to all its connectees.

Implements OpenSim::AbstractSocket.

References OpenSim::AbstractSocket::getNumConnectees().

Referenced by OpenSim::Input< T >::getAlias(), OpenSim::Input< T >::getChannel(), OpenSim::Input< T >::getLabel(), OpenSim::Input< T >::getValue(), and OpenSim::Input< T >::setAlias().

◆ safeDownCast()

template<class T>
static Input<T>* OpenSim::Input< T >::safeDownCast ( AbstractInput< T > *  base)
inlinestatic

For use in python/java/MATLAB bindings.

◆ setAlias() [1/2]

template<class T>
void OpenSim::Input< T >::setAlias ( const std::string &  alias)
inlineoverridevirtual

Set the alias for a Channel.

If this is a list Input, the aliases of all Channels will be set to the provided string. If you wish to set the alias of only one Channel, use the two-argument overload. You must finalize connections (Component::finalizeConnections()) first.

Implements OpenSim::AbstractInput.

References OpenSim::AbstractSocket::getNumConnectees().

◆ setAlias() [2/2]

template<class T>
void OpenSim::Input< T >::setAlias ( unsigned  index,
const std::string &  alias 
)
inlineoverridevirtual

◆ SimTK_DOWNCAST()

template<class T>
OpenSim::Input< T >::SimTK_DOWNCAST ( Input< T >  ,
AbstractInput< T >   
)

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