API
4.5.1
For C++ developers
|
An Input<Y> must be connected by an Output<Y> More...
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 Channel & | getChannel () const |
Get the Channel associated with this Input. More... | |
const Channel & | getChannel (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 ChannelList & | getChannels () 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 () |
bool | canConnectTo (OpenSim::Object const &) const override |
Returns true if the socket can connect to the object (i.e. More... | |
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 Object & | getConnecteeAsObject (int index=-1) 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 &path, int index=-1) |
Set the connectee path. More... | |
const std::string & | getConnecteePath (int index=-1) const |
Get the connectee path. More... | |
void | appendConnecteePath (const std::string &path) |
Append a connectee path to this socket. More... | |
void | assignConnecteePath (const std::string &path) |
Assign the connectee path to this socket. More... | |
void | clearConnecteePath () |
Clear all connectee paths in the connectee path property. More... | |
bool | isConnecteePathEmpty () const |
Check to see if the connectee path property is "empty". More... | |
const Component & | getOwner () const |
Get owner component of this socket. More... | |
Public Types | |
typedef Output< T >::Channel | Channel |
typedef std::vector< SimTK::ReferencePtr< const Channel > > | ChannelList |
typedef std::vector< std::string > | AliasList |
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... | |
Protected Member Functions | |
Input (const std::string &name, const PropertyIndex &connecteePathIndex, const SimTK::Stage &connectAtStage, Component &owner) | |
Create an Input<T> (Socket) that can only connect to an Output<T> name and stage at which it should be connected. More... | |
Protected Member Functions inherited from OpenSim::AbstractInput | |
AbstractInput (const std::string &name, const PropertyIndex &connecteePathIndex, const SimTK::Stage &connectAtStage, Component &owner) | |
Create an AbstractInput (Socket) that connects only to an AbstractOutput specified by name and stage at which it should be connected. More... | |
Protected Member Functions inherited from OpenSim::AbstractSocket | |
AbstractSocket (const std::string &name, const PropertyIndex &connecteePathIndex, const SimTK::Stage &connectAtStage, Component &owner) | |
Create a Socket with specified name and stage at which it should be connected. More... | |
void | setOwner (Component &o) |
Set an internal pointer to the Component that contains this Socket. More... | |
bool | hasOwner () const |
This will be false immediately after copy construction or assignment. More... | |
void | checkConnecteePathProperty () |
Check if entries of the connectee path property's value is valid (if it contains spaces, etc.); if so, print out a warning. More... | |
Protected Attributes | |
friend | Component |
So that Component can construct an Input. More... | |
Related Functions | |
(Note that these are not member functions.) | |
Creating Inputs for your Component | |
Use these macros at the top of your component class declaration, near where you declare Property properties. | |
#define | OpenSim_DECLARE_INPUT(iname, T, istage, comment) |
Create a socket for this component's dependence on an output signal from another component. More... | |
#define | OpenSim_DECLARE_LIST_INPUT(iname, T, istage, comment) |
Create a list input, which can connect to more than one Channel. More... | |
An Input<Y> must be connected by an Output<Y>
typedef std::vector<std::string> OpenSim::Input< T >::AliasList |
typedef Output<T>::Channel OpenSim::Input< T >::Channel |
typedef std::vector<SimTK::ReferencePtr<const Channel> > OpenSim::Input< T >::ChannelList |
|
inlineprotected |
Create an Input<T> (Socket) that can only connect to an Output<T> name and stage at which it should be connected.
|
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.
|
overridevirtual |
Connect this Input to the provided (Abstract)Output.
Implements OpenSim::AbstractInput.
References OpenSim::AbstractOutput::getPathName(), and OpenSim::AbstractOutput::getTypeName().
|
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.
|
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.
|
overridevirtual |
Connect this Input given a root Component to search for the Output according to the connectee path of this Input.
Reimplemented from OpenSim::AbstractSocket.
References OpenSim::AbstractOutput::getChannel(), OpenSim::Output< T >::getChannel(), OpenSim::Component::getComponent(), OpenSim::ComponentPath::getNumPathLevels(), OpenSim::Component::getOutput(), OpenSim::ComponentPath::getSubcomponentNameAtLevel(), OpenSim::ComponentPath::isAbsolute(), and OpenSim::ComponentPath::toString().
|
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().
|
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().
|
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().
|
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().
|
inline |
Get const access to the channels connected to this input.
You can use this to iterate through the channels.
|
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.
|
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().
|
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().
|
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().
|
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().
|
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.
|
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().
|
inlinestatic |
For use in python/java/MATLAB bindings.
|
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().
|
inlineoverridevirtual |
Set the alias for the Channel indicated by the provided index.
You must finalize connections (Component::finalizeConnections()) first.
Implements OpenSim::AbstractInput.
References OpenSim::AbstractInput::composeConnecteePath(), OpenSim::AbstractSocket::getConnecteePath(), OpenSim::AbstractSocket::getName(), OpenSim::AbstractSocket::getNumConnectees(), OpenSim::Input< T >::isConnected(), OpenSim::AbstractInput::parseConnecteePath(), and OpenSim::AbstractSocket::setConnecteePath().
OpenSim::Input< T >::SimTK_DOWNCAST | ( | Input< T > | , |
AbstractInput< T > | |||
) |
|
related |
Create a socket for this component's dependence on an output signal from another component.
It is a placeholder for an Output that can be connected to it. An output must have the same type T as an input to be connected to it. You must also specify the stage at which you require this input quantity. The comment should describe how the input quantity is used.
An Input declared with this macro can connect to only one Output.
Here's an example for using this macro:
|
related |
Create a list input, which can connect to more than one Channel.
This makes sense for components like reporters that can handle a flexible number of input values.
|
protected |