API
4.3
For C++ developers
|
A specialized Socket that connects to an Output signal is an Input. More...
Public Member Functions | |
virtual | ~AbstractInput () |
AbstractInput * | clone () const override=0 |
Create a dynamically-allocated copy. More... | |
void | connect (const Object &object) override |
Connect this Socket to the provided connectee object. More... | |
virtual void | connect (const AbstractOutput &output, const std::string &alias="")=0 |
TODO. More... | |
virtual void | connect (const AbstractChannel &channel, const std::string &alias="")=0 |
Connect this Input to a single output channel. More... | |
virtual const std::string & | getAlias () const =0 |
Get the alias for a Channel. More... | |
virtual const std::string & | getAlias (unsigned index) const =0 |
Get the alias for the Channel indicated by the provided index. More... | |
virtual void | setAlias (const std::string &alias)=0 |
Set the alias for a Channel. More... | |
virtual void | setAlias (unsigned index, const std::string &alias)=0 |
Set the alias for the Channel indicated by the provided index. More... | |
virtual std::string | getLabel () const =0 |
Get the label for this Channel. More... | |
virtual std::string | getLabel (unsigned index) const =0 |
Get the label for the Channel indicated by the provided index. 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 bool | isConnected () const =0 |
Derived classes must satisfy this Interface. More... | |
virtual std::string | getConnecteeTypeName () const =0 |
Get the type of object this socket connects to. More... | |
virtual const Object & | getConnecteeAsObject () 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... | |
virtual void | finalizeConnection (const Component &root) |
Connect this Socket according to its connectee path property given a root Component to search its subcomponents for the connect_to Component. More... | |
virtual void | disconnect ()=0 |
Clear references to connectees. 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 Component & | getOwner () const |
Get owner component of this socket. More... | |
Static Public Member Functions | |
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 | |
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... | |
const Property< std::string > & | getConnecteePathProp () const |
Const access to the connectee path property from the Component in which this Socket resides. More... | |
Property< std::string > & | updConnecteePathProp () |
Writable access to the connectee path property from the Component in which this Socket resides. More... | |
A specialized Socket that connects to an Output signal is an Input.
An AbstractInput enables maintenance of a list of unconnected Inputs. An Input can either be a single-value Input or a list Input. A list Input can connect to multiple (Output) Channels.
For every Input that a component has, the XML representation of the component contains an element named input_<input_name>
. For example, a component that has an Input named desired_angle
might look like the following in XML:
You use this field to specify the outputs/channels that should be connected to this input (that is, the connectees). The syntax for the connectee path property is as follows:
Angle brackets indicate fields that one would fill in, and square brackets indicate optional fields. The <path/to/component>
can be relative or absolute, and describes the location of the Component that contains the desired Output relative to the location of the Component that contains this Input. The <path/to/component>
and <output_name>
must always be specified. The <channel_name>
should only be specified if the Output is a list output (i.e., it has multiple channels). The <alias>
is a name for the output/channel that is specific to this input, and it is optional. All fields should contain only letters, numbers, and underscores (the path to the component can contain slashes and periods); fields must not contain spaces. Here are some examples:
../marker_data|column:left_ankle
: The TableSourceVec3 component ../marker_data
has a list output column
, and we want to connect to its left_ankle
channel.../averager|output(knee_joint_center)
: The component ../averager
(presumably a component that averages its inputs) has an output named output
, and we are aliasing this output as knee_joint_center
./leg_model/soleus|activation
: This connectee path uses the absolute path to component soleus
, which has an output named activation
.List inputs can contain multiple entries in its connectee path, with the entries separated by a space. For example:
|
inlinevirtual |
|
inlineprotected |
Create an AbstractInput (Socket) that connects only to an AbstractOutput specified by name and stage at which it should be connected.
Only Component should ever construct this class.
|
overridepure virtual |
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::AbstractSocket.
Implemented in OpenSim::Input< T >.
|
inlinestatic |
Compose the connectee path from its constituents.
This is the opposite operation of parseConnecteePath(). Example:
if inputs are componentPath --> "/foo/bar" outputName --> "output" channelName --> "channel" alias --> "baz" then result --> /foo/bar|output:channel(baz)
|
inlineoverridevirtual |
Connect this Socket to the provided connectee object.
If this is a list socket, the connectee is appended to the list of connectees; otherwise, the provided connectee replaces the single connectee.
Implements OpenSim::AbstractSocket.
References OpenSim::Exception::Exception().
|
pure virtual |
TODO.
Connect this Input to a single-valued (single-channel) Output or, if this is a list Input and the Output is a list Output, connect to all the channels of the Output. You can optionally provide an alias that will be used by the Component owning this Input to refer to the Output. If this method connects to multiple channels, the alias will be used for all channels.
Implemented in OpenSim::Input< T >.
|
pure virtual |
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.
Implemented in OpenSim::Input< T >.
|
pure virtual |
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.
Implemented in OpenSim::Input< T >.
|
pure virtual |
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.
Implemented in OpenSim::Input< T >.
|
pure virtual |
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.
Implemented in OpenSim::Input< T >.
|
pure virtual |
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.
Implemented in OpenSim::Input< T >.
|
inlinestatic |
Break up a connectee path into its output path, channel name (empty for single-value outputs), and alias.
This function writes to the passed-in outputPath, channelName, and alias.
Examples:
/foo/bar|output outputPath is "/foo/bar/output" channelName is "" alias is "" /foo/bar|output:channel outputPath is "/foo/bar/output" channelName is "channel" alias is "" /foo/bar|output(baz) outputPath is "/foo/bar/output" channelName is "" alias is "baz" /foo/bar|output:channel(baz) outputPath is "/foo/bar|output" channelName is "channel" alias is "baz"
|
pure virtual |
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.
Implemented in OpenSim::Input< T >.
|
pure virtual |
Set the alias for the Channel indicated by the provided index.
You must finalize connections (Component::finalizeConnections()) first.
Implemented in OpenSim::Input< T >.