Workspace 6.21.5
Public Member Functions | List of all members
ConnectionWrapper Class Reference

Convenience wrapper around a Connection. More...

#include <Workspace/DataExecution/Connections/connection.h>

Public Member Functions

 ConnectionWrapper (Connection &connection)
 
 ~ConnectionWrapper ()
 
Connectionoperator* ()
 
const Connectionoperator* () const
 
Connectionoperator-> ()
 
const Connectionoperator-> () const
 
ConnectionsetConnection (Connection *connection)
 

Detailed Description

This class is useful for holding a connection that should survive only as long as the ConnectionWrapper exists. When the ConnectionWrapper is deleted, it destroys the connection it holds. The most useful application of this is when a connection needs to be created in a local scope and that connection should be deleted at the end of that scope. For example:

{
// ... do stuff
} // con goes out of scope and calls destroy() on the connection
static Connection & create(Output &source, InputScalar &destination, bool copy=false, bool enable=true)
Definition: connection.cpp:141
Convenience wrapper around a Connection.
Definition: connection.h:148

A ConnectionWrapper also acts somewhat like a smart pointer to the connection it holds in that it can be dereferenced.

Constructor & Destructor Documentation

◆ ConnectionWrapper()

ConnectionWrapper ( Connection connection)
inline
Parameters
connectionThe new connection this wrapper should manage.

◆ ~ConnectionWrapper()

~ConnectionWrapper ( )
inline

The destructor will destroy the connection it holds. If the connection has been set to a null pointer in setConnection, the destructor does nothing.

Member Function Documentation

◆ operator*() [1/2]

Connection & operator* ( )
inline

Allows this wrapper to act like a smart pointer to its connection.

◆ operator*() [2/2]

const Connection & operator* ( ) const
inline

Allows this wrapper to act like a smart pointer to its connection.

◆ operator->() [1/2]

Connection * operator-> ( )
inline

Allows this wrapper to act like a smart pointer to its connection.

◆ operator->() [2/2]

const Connection * operator-> ( ) const
inline

Allows this wrapper to act like a smart pointer to its connection.

◆ setConnection()

Connection * setConnection ( Connection connection)
inline
Parameters
connectionThe new connection this wrapper should manage. If it is a null pointer, the wrapper will not manage anything, and as long as it is not dereferenced, it is still safe. The wrapper can even be deleted and it is not considered an error.