ImagingTools Core SDK
Public Member Functions | List of all members
imtcom::IConnectionControllerabstract

Simple interface for connection lifecycle control. More...

#include <IConnectionController.h>

Inherits istd::IPolymorphic.

Inherited by imtclientgql::CWebSocketClientComp [virtual].

Public Member Functions

virtual bool Connect ()=0
 Establish a connection.
 
virtual bool Disconnect ()=0
 Close the connection.
 

Detailed Description

Simple interface for connection lifecycle control.

IConnectionController provides a minimal contract for components that need to establish and tear down network connections. This interface is intentionally lightweight and generic, suitable for various connection types (TCP, WebSocket, database connections, etc.).

Key Concepts

Connection States:

Lifecycle:

Usage Example

// Assume component implements IConnectionController
IConnectionController* controller = ...;
// Establish connection
if (controller->Connect()) {
qDebug() << "Connection established";
// Perform operations...
// Close connection when done
controller->Disconnect();
} else {
qCritical() << "Failed to connect";
}
Simple interface for connection lifecycle control.
virtual bool Disconnect()=0
Close the connection.
virtual bool Connect()=0
Establish a connection.

Typical Implementations

Components implementing this interface typically include:

Note
This interface does not provide connection status queries. For observable connection status, use IConnectionStatusProvider instead.
See also
IConnectionStatusProvider, IServerConnectionInterface

Definition at line 66 of file IConnectionController.h.

Member Function Documentation

◆ Connect()

virtual bool imtcom::IConnectionController::Connect ( )
pure virtual

Establish a connection.

Initiates the connection establishment process. Implementation-specific details may include DNS resolution, TCP handshake, authentication, protocol negotiation, etc.

Returns
true if connection was established successfully; false on failure.
See also
Disconnect()
Example:
if (!controller->Connect()) {
qCritical() << "Connection failed";
// Check logs for detailed error information
}
Note
If already connected, implementations typically return true without re-establishing the connection (idempotent behavior).

◆ Disconnect()

virtual bool imtcom::IConnectionController::Disconnect ( )
pure virtual

Close the connection.

Gracefully terminates the connection. Implementations should clean up resources, close sockets, and notify peers if applicable.

Returns
true if disconnection was successful; false on error.
See also
Connect()
Example:
controller->Disconnect();
qDebug() << "Connection closed";
Note
If already disconnected, implementations typically return true without error (idempotent behavior).