Class CConnection#
Defined in File connection.h
Nested Relationships#
Nested Types#
Inheritance Relationships#
Base Types#
public std::enable_shared_from_this< CConnection >
public sdv::IInterfaceAccess
(Struct IInterfaceAccess)public sdv::IObjectDestroy
(Struct IObjectDestroy)public sdv::ipc::IDataSend
(Struct IDataSend)public sdv::ipc::IConnect
(Struct IConnect)public sdv::IInterfaceAccess
(Struct IInterfaceAccess)public sdv::ipc::IDataSend
(Struct IDataSend)public sdv::ipc::IConnect
(Struct IConnect)public sdv::IObjectDestroy
(Struct IObjectDestroy)
Class Documentation#
-
class CConnection : public std::enable_shared_from_this<CConnection>, public sdv::IInterfaceAccess, public sdv::IObjectDestroy, public sdv::ipc::IDataSend, public sdv::ipc::IConnect, public sdv::IInterfaceAccess, public sdv::ipc::IDataSend, public sdv::ipc::IConnect, public sdv::IObjectDestroy#
Class for local IPC connection Created and managed by IPCAccess::AccessLocalIPCConnection(best use unique_ptr to store, so memory address stays
valid)
Class for remote IPC connection Created and managed by IPCAccess::AccessRemoveIPCConnection(best use unique_ptr to store, so memory address stays
valid)
Public Functions
-
CConnection(CWatchDog &rWatchDog, uint32_t uiSize, const std::string &rssName, bool bServer)#
default constructor used by create endpoint - allocates new buffers m_Sender and m_Receiver
- Parameters:
rWatchDog – [in] Reference to the watch dog object monitoring the connected processes.
uiSize – [in] Optional size of the buffer. If zero, a default buffer size of 10k is configured.
rssName – [in] Optional name to be used for the connection. If empty, a random name is generated.
bServer – [in] When set, the connection is the server connection; otherwise it is the client connection (determines the initial communication).
-
CConnection(CWatchDog &rWatchDog, const std::string &rssConnectionString)#
Access existing connection.
- Parameters:
rWatchDog – [in] Reference to the watch dog object monitoring the connected processes.
rssConnectionString – [in] Reference to string with connection information.
-
virtual ~CConnection()#
Virtual destructor needed for “delete this;”.
-
std::string GetConnectionString()#
get the connection string for the sender and the receiver
- Returns:
Returns the connection string for the sender and the receiver together
-
virtual bool SendData(sdv::sequence<sdv::pointer<uint8_t>> &seqData) override#
Sends data consisting of multiple data chunks via the IPC connection. Overload of sdv::ipc::IDataSend::SendData.
- Parameters:
seqData – [inout] Sequence of data buffers to be sent. The sequence might be changed to optimize the communication without having to copy the data.
- Returns:
Return ‘true’ if all data could be sent; ‘false’ otherwise.
-
virtual bool AsyncConnect(sdv::IInterfaceAccess *pReceiver) override#
Establish a connection and start sending/receiving messages. Overload of sdv::ipc::IConnect::AsyncConnect.
- Parameters:
pReceiver – [in] The message has to be forwarded.
- Returns:
Returns ‘true’ when a connection could be established. Use IConnectStatus or IConnectEventCallback to check the connection state.
-
virtual bool WaitForConnection(uint32_t uiWaitMs) override#
Wait for a connection to take place. Overload of sdv::ipc::IConnect::WaitForConnection.
- Parameters:
uiWaitMs – [in] Wait for a connection to take place. A value of 0 doesn’t wait at all, a value of 0xffffffff waits for infinite time.
- Returns:
Returns ‘true’ when a connection took place.
-
virtual void CancelWait() override#
Cancel a wait for connection. Overload of sdv::ipc::IConnect::CancelWait.
-
virtual void Disconnect() override#
Disconnect from a connection. This will set the connect status to disconnected. Overload of sdv::ipc::IConnect::Disconnect.
-
virtual uint64_t RegisterStatusEventCallback(sdv::IInterfaceAccess *pEventCallback) override#
Register event callback interface. Overload of sdv::ipc::IConnect::RegisterStatusEventCallback.
Register a connection status event callback interface. The exposed interface must be of type IConnectEventCallback. The registration will exist until a call to the unregister function with the returned cookie or until the connection is terminated.
- Parameters:
pEventCallback – [in] Pointer to the object exposing the IConnectEventCallback interface.
- Returns:
The cookie assigned to the registration.
-
virtual void UnregisterStatusEventCallback(uint64_t uiCookie) override#
Unregister the status event callback with the returned cookie from the registration. Overload of sdv::ipc::IConnect::UnregisterStatusEventCallback.
- Parameters:
uiCookie – [in] The cookie returned by a previous call to the registration function.
-
virtual sdv::ipc::EConnectStatus GetStatus() const override#
Get status of the connection. Overload of sdv::ipc::IConnect::GetStatus.
- Returns:
Returns the ipc::EConnectStatus struct
-
virtual void DestroyObject() override#
Destroy the object. Overload of IObjectDestroy::DestroyObject.
- Attention
After a call of this function, all exposed interfaces render invalid and should not be used any more.
-
void SetStatus(sdv::ipc::EConnectStatus eStatus)#
Set the connection status and if needed call the event callback.
- Parameters:
eStatus – [in] The new status.
-
bool IsServer() const#
Returns whether this is a server connection or a client connection.
- Returns:
The server connection flag. If ‘true’ the connection is a server connection; otherwise a client connection.
-
CConnection()#
default constructor used by create endpoint - allocates new buffers m_Sender and m_Receiver
-
CConnection(SOCKET preconfiguredSocket, bool acceptConnectionRequired)#
access existing connection
- Parameters:
preconfiguredSocket – [in] Prepared socket for the connection.
acceptConnectionRequired – [in] If true connection has to be accepted before receive thread can be started.
-
virtual ~CConnection() = default
Virtual destructor needed for “delete this;”.
-
virtual bool SendData(sdv::sequence<sdv::pointer<uint8_t>> &seqData) override
Sends data consisting of multiple data chunks via the IPC connection. Overload of sdv::ipc::IDataSend::SendData.
- Parameters:
seqData – [inout] Sequence of data buffers to be sent. The sequence might be changed to optimize the communication without having to copy the data.
- Returns:
Return ‘true’ if all data could be sent; ‘false’ otherwise.
-
virtual bool AsyncConnect(sdv::IInterfaceAccess *pReceiver) override
Establish a connection and start sending/receiving messages. Overload of sdv::ipc::IConnect::AsyncConnect.
- Parameters:
pReceiver – [in] The message has to be forwarded.
- Returns:
Returns ‘true’ when a connection could be established. Use IConnectStatus or IConnectEventCallback to check the connection state.
-
virtual bool WaitForConnection(uint32_t uiWaitMs) override
Wait for a connection to take place. Overload of sdv::ipc::IConnect::WaitForConnection.
- Parameters:
uiWaitMs – [in] Wait for a connection to take place. A value of 0 doesn’t wait at all, a value of 0xffffffff waits for infinite time.
- Returns:
Returns ‘true’ when a connection took place.
-
virtual void CancelWait() override
Cancel a wait for connection. Overload of sdv::ipc::IConnect::CancelWait.
-
virtual void Disconnect() override
Disconnect from a connection. This will set the connect status to disconnected and release the interface used for the status events.
-
virtual uint64_t RegisterStatusEventCallback(sdv::IInterfaceAccess *pEventCallback) override
Register event callback interface. Overload of sdv::ipc::IConnect::RegisterStatusEventCallback.
Register a connection status event callback interface. The exposed interface must be of type IConnectEventCallback. The registration will exist until a call to the unregister function with the returned cookie or until the connection is terminated.
- Parameters:
pEventCallback – [in] Pointer to the object exposing the IConnectEventCallback interface.
- Returns:
The cookie assigned to the registration.
-
virtual void UnregisterStatusEventCallback(uint64_t uiCookie) override
Unregister the status event callback with the returned cookie from the registration. Overload of sdv::ipc::IConnect::UnregisterStatusEventCallback.
- Parameters:
uiCookie – [in] The cookie returned by a previous call to the registration function.
-
virtual sdv::ipc::EConnectStatus GetStatus() const override
Get status of the connection.
- Returns:
Returns the ipc::EConnectStatus struct
-
virtual void DestroyObject() override
Destroy the object. Overload of IObjectDestroy::DestroyObject.
- Attention
After a call of this function, all exposed interfaces render invalid and should not be used any more.
-
CConnection(CWatchDog &rWatchDog, uint32_t uiSize, const std::string &rssName, bool bServer)#