API
4.0
For C++ developers
|
Public Member Functions | |
virtual | ~Socket () |
Socket< T > * | clone () const override |
Create a dynamically-allocated copy. More... | |
bool | isConnected () const override |
Is the Socket connected to object of type T? More... | |
const T & | getConnecteeAsObject () const override |
Generic access to the connectee. More... | |
const T & | getConnectee () const |
Temporary access to the connectee for testing purposes. More... | |
void | connect (const Object &object) override |
Connect this Socket to the provided connectee object. More... | |
void | findAndConnect (const ComponentPath &connectee) override |
Find a component using a partial path or component name of the correct type anywhere in the model (using Component::findComponent()) and connect to that component. More... | |
void | finalizeConnection (const Component &root) override |
Connect this Socket given its connectee path property. More... | |
void | disconnect () override |
Clear references to connectees. More... | |
std::string | getConnecteeTypeName () const override |
Derived classes must satisfy this Interface. More... | |
SimTK_DOWNCAST (Socket, AbstractSocket) | |
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... | |
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 Component & | getOwner () const |
Get owner component of this socket. More... | |
Static Public Member Functions | |
static Socket< T > * | safeDownCast (AbstractSocket *base) |
For use in python/java/MATLAB bindings. More... | |
Protected Member Functions | |
Socket (const std::string &name, const PropertyIndex &connecteePathIndex, const SimTK::Stage &connectAtStage, Component &owner) | |
Create a Socket that can only connect to Object of type T with specified 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... | |
Protected Attributes | |
friend | Component |
So that Component can construct a Socket. More... | |
Related Functions | |
(Note that these are not member functions.) | |
Creating Sockets to other objects for your Component | |
Use these macros at the top of your component class declaration, near where you declare Property properties. | |
#define | OpenSim_DECLARE_SOCKET(cname, T, comment) |
Create a socket for this component's dependence on another component. More... | |
|
inlinevirtual |
|
inlineprotected |
|
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::AbstractSocket.
|
inlineoverridevirtual |
Connect this Socket to the provided connectee object.
Implements OpenSim::AbstractSocket.
References OpenSim::Socket< T >::getConnecteeTypeName(), and OpenSim::AbstractSocket::getName().
Referenced by OpenSim::Socket< T >::findAndConnect().
|
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.
References SimTK::ReferencePtr< T >::reset().
|
overridevirtual |
Connect this Socket given its connectee path property.
Reimplemented from OpenSim::AbstractSocket.
|
inlineoverridevirtual |
Find a component using a partial path or component name of the correct type anywhere in the model (using Component::findComponent()) and connect to that component.
Throws an exception If you provide only a component name and the model has multiple components with that nume.
Reimplemented from OpenSim::AbstractSocket.
References OpenSim::Socket< T >::connect(), OpenSim::Component::getAbsolutePathString(), OpenSim::Socket< T >::getConnecteeTypeName(), OpenSim::AbstractSocket::getOwner(), OpenSim::Component::getRoot(), and OpenSim::Path::toString().
|
inline |
Temporary access to the connectee for testing purposes.
Real usage will be through the Socket (and Input) interfaces. For example, Input should short circuit to its Output's getValue() once it is connected. Return a const reference to the object connected to this Socket
References OpenSim::Component::getAbsolutePathString(), OpenSim::Component::getConcreteClassName(), OpenSim::AbstractSocket::getName(), OpenSim::AbstractSocket::getOwner(), SimTK::ReferencePtr< T >::getRef(), and OpenSim::Socket< T >::isConnected().
Referenced by OpenSim::Component::getConnectee().
|
inlineoverridevirtual |
Generic access to the connectee.
Not all sockets support this method (e.g., the connectee for an Input is not an Object).
Reimplemented from OpenSim::AbstractSocket.
References SimTK::ReferencePtr< T >::getRef().
|
inlineoverridevirtual |
Derived classes must satisfy this Interface.
get the type of object this socket connects to
Implements OpenSim::AbstractSocket.
Referenced by OpenSim::Socket< T >::connect(), and OpenSim::Socket< T >::findAndConnect().
|
inlineoverridevirtual |
Is the Socket connected to object of type T?
Implements OpenSim::AbstractSocket.
References SimTK::ReferencePtr< T >::empty().
Referenced by OpenSim::Socket< T >::getConnectee(), and OpenSim::Component::getConnectee().
|
inlinestatic |
For use in python/java/MATLAB bindings.
OpenSim::Socket< T >::SimTK_DOWNCAST | ( | Socket< T > | , |
AbstractSocket< T > | |||
) |
|
related |
Create a socket for this component's dependence on another component.
You must specify the type of the component that can be connected to this socket. The comment should describe how the connected component (connectee) is used by this component.
Here's an example for using this macro:
T
, as shown in the example above. We currently do not support declaring sockets if T
is only forward-declared.
|
protected |