ImagingTools Core SDK
List of all members
imtcom::CServerConnectionInterfaceParamComp

ACF component implementation of IServerConnectionInterface with default port configuration. More...

#include <CServerConnectionInterfaceParamComp.h>

Inheritance diagram for imtcom::CServerConnectionInterfaceParamComp:
imtcom::CServerConnectionInterfaceParam imtcom::IServerConnectionInterface

Additional Inherited Members

- Public Types inherited from imtcom::IServerConnectionInterface
enum  ProtocolType {
  PT_UNKNOWN , PT_HTTP , PT_WEBSOCKET , PT_FILE ,
  PT_GRPC
}
 Communication protocols supported by server connections. More...
 
enum  ConnectionFlags { CF_DEFAULT = 0x1 , CF_SECURE = 0x2 }
 Flags controlling connection security and behavior. More...
 
typedef QList< ProtocolTypeProtocolTypes
 List of protocol types for querying supported protocols.
 
- Public Member Functions inherited from imtcom::CServerConnectionInterfaceParam
 CServerConnectionInterfaceParam ()
 Default constructor.
 
void RegisterProtocol (ProtocolType protocol)
 Register a protocol as supported.
 

Detailed Description

ACF component implementation of IServerConnectionInterface with default port configuration.

CServerConnectionInterfaceParamComp extends CServerConnectionInterfaceParam with ACF component infrastructure and provides sensible default port numbers for common protocols. This is the recommended class to use in ImtCore applications requiring server connection configuration.

Key Features

Default Port Configuration:

ACF Component Integration:

SSL Configuration Integration:

Component Lifecycle:

Component Attributes

Attribute Type Description Default
DefaultHost QString Default server host name "localhost"
DefaultWebSocketPort int Default WebSocket port 9000
DefaultHttpPort int Default HTTP port 9001
DefaultgRPCPort int Default gRPC port 50101

Component References

Reference Interface Description
ExternalEnableSSL iprm::IEnableableParam External SSL configuration control

When ExternalEnableSSL is set and enabled, GetConnectionFlags() returns CF_SECURE. Otherwise, it returns the manually set connection flags.

Usage Example

Basic Usage

// Create component (uses default ports)
auto connection = icomp::CreateComponent<CServerConnectionInterfaceParamComp>();
// Default configuration is ready to use:
// - Host: "localhost"
// - HTTP port: 9001
// - WebSocket port: 9000
// - gRPC port: 50101
// Generate URLs with defaults
QUrl httpUrl;
connection->GetUrl(IServerConnectionInterface::PT_HTTP, httpUrl);
// httpUrl = "http://localhost:9001"
// Or override defaults as needed
connection->SetHost("api.example.com");
connection->SetPort(IServerConnectionInterface::PT_HTTP, 443);
connection->SetConnectionFlags(IServerConnectionInterface::CF_SECURE);
connection->GetUrl(IServerConnectionInterface::PT_HTTP, httpUrl);
// httpUrl = "https://api.example.com:443"
@ PT_HTTP
HTTP/HTTPS protocol for RESTful APIs (default port: 9001)
@ CF_SECURE
Secure connection with SSL/TLS encryption (HTTPS, WSS)

Custom Port Configuration

// Create component
auto connection = icomp::CreateComponent<CServerConnectionInterfaceParamComp>();
// Override default ports via attributes before component creation
// (in component configuration file or factory setup)
// connection->SetAttributeValue("DefaultHttpPort", 8080);
// connection->SetAttributeValue("DefaultWebSocketPort", 8081);
// Or set directly after creation
connection->SetPort(IServerConnectionInterface::PT_HTTP, 8080);
connection->SetPort(IServerConnectionInterface::PT_WEBSOCKET, 8081);
connection->SetPort(IServerConnectionInterface::PT_GRPC, 50051);
@ PT_WEBSOCKET
WebSocket/WSS protocol for real-time bidirectional communication (default port: 9000)
@ PT_GRPC
gRPC protocol for high-performance RPC (default port: 50101)

SSL Configuration Integration

// Create connection component
auto connection = icomp::CreateComponent<CServerConnectionInterfaceParamComp>();
// Create SSL enableable parameter
auto sslParam = icomp::CreateComponent<iprm::CEnableableParamComp>();
// Link SSL parameter to connection
connection->SetReference("ExternalEnableSSL", sslParam);
// Enable SSL
sslParam->SetEnabled(true);
// GetConnectionFlags() now returns CF_SECURE automatically
int flags = connection->GetConnectionFlags();
// flags == IServerConnectionInterface::CF_SECURE
// URLs are automatically generated with secure schemes
QUrl url;
connection->GetUrl(IServerConnectionInterface::PT_HTTP, url);
// url = "https://localhost:9001" (note: https, not http)

Factory-Based Creation

// Component factory XML configuration example:
// <Component type="CServerConnectionInterfaceParamComp" name="ServerConnection">
// <Attribute name="DefaultHost" value="api.example.com"/>
// <Attribute name="DefaultHttpPort" value="8080"/>
// <Attribute name="DefaultWebSocketPort" value="8081"/>
// <Reference name="ExternalEnableSSL" target="SslConfig"/>
// </Component>
// Load from configuration
auto connection = componentFactory->CreateComponent("ServerConnection");
// Configuration automatically applied
QUrl url;
connection->GetUrl(IServerConnectionInterface::PT_HTTP, url);
// url = "http://api.example.com:8080" (or https if SSL enabled)

Port Number Rationale

The default port numbers are chosen to:

Default Ports:

Comparison with Base Class

Feature CServerConnectionInterfaceParam CServerConnectionInterfaceParamComp
ACF Component ❌ No ✅ Yes
Default Ports ❌ Manual configuration required ✅ HTTP: 9001, WS: 9000, gRPC: 50101
Default Host ❌ Empty string ✅ "localhost"
Attribute Support ❌ No ✅ Yes
SSL Integration ❌ Manual flags only ✅ IEnableableParam integration
Factory Creation ❌ No ✅ Yes
Recommended Use Non-ACF contexts ✅ All ImtCore applications

Best Practices

  1. Use as Default: Always prefer this class over CServerConnectionInterfaceParam in ACF-based applications for consistent defaults.
  2. Override Selectively: Only override ports when defaults conflict with your deployment environment.
  3. SSL Integration: Use ExternalEnableSSL reference for SSL control rather than manually setting CF_SECURE flag.
  4. Factory Configuration: Configure via component factory XML for deployment-specific settings.
  5. Default Host: Change default host from "localhost" to actual server name in production deployments.
See also
CServerConnectionInterfaceParam, IServerConnectionInterface
iprm::IEnableableParam, icomp::CComponentBase

Definition at line 204 of file CServerConnectionInterfaceParamComp.h.