API  4.3
For MATLAB, Python, Java, and C++ users
OpenSim::Socket< T > Class Template Reference
+ Inheritance diagram for OpenSim::Socket< T >:

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 ComponentgetOwner () 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...
 

Constructor & Destructor Documentation

◆ ~Socket()

template<class T>
virtual OpenSim::Socket< T >::~Socket ( )
inlinevirtual

◆ Socket()

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

Create a Socket that can only connect to Object of type T with specified name and stage at which it should be connected.

Only Component can ever construct this class.

Parameters
namename of the socket used to describe its dependency.
connecteePathIndexIndex of the property in the containing Component that holds this Socket's connectee path(s).
connectAtStageStage at which Socket should be connected.
ownerThe component that contains this input.

Member Function Documentation

◆ clone()

template<class T>
Socket<T>* OpenSim::Socket< 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::AbstractSocket.

◆ connect()

template<class T>
void OpenSim::Socket< T >::connect ( const Object object)
inlineoverridevirtual

Connect this Socket to the provided connectee object.

Implements OpenSim::AbstractSocket.

References OpenSim::Socket< T >::getConnecteeTypeName(), and OpenSim::AbstractSocket::getName().

◆ disconnect()

template<class T>
void OpenSim::Socket< 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()

template<class C >
void OpenSim::Socket< C >::finalizeConnection ( const Component root)
overridevirtual

Connect this Socket given its connectee path property.

Reimplemented from OpenSim::AbstractSocket.

◆ findAndConnect()

template<class C >
void OpenSim::Socket< C >::findAndConnect ( const ComponentPath connectee)
overridevirtual

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::ComponentPath::toString().

◆ getConnectee()

template<class C >
const C & OpenSim::Socket< C >::getConnectee ( ) const

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

Referenced by OpenSim::Component::getConnectee().

◆ getConnecteeAsObject()

template<class T>
const T& OpenSim::Socket< T >::getConnecteeAsObject ( ) const
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.

◆ getConnecteeTypeName()

template<class T>
std::string OpenSim::Socket< T >::getConnecteeTypeName ( ) const
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().

◆ isConnected()

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

Is the Socket connected to object of type T?

Implements OpenSim::AbstractSocket.

Referenced by OpenSim::Component::getConnectee().

◆ safeDownCast()

template<class T>
static Socket<T>* OpenSim::Socket< T >::safeDownCast ( AbstractSocket< T > *  base)
inlinestatic

For use in python/java/MATLAB bindings.

◆ SimTK_DOWNCAST()

template<class T>
OpenSim::Socket< T >::SimTK_DOWNCAST ( Socket< T >  ,
AbstractSocket< T >   
)

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