Class CConnection#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Types#

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#

Class for local IPC connection Created and managed by IPCAccess::AccessLocalIPCConnection(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 IConnect 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 state to disconnected. Overload of sdv::ipc::IConnect::Disconnect.

virtual uint64_t RegisterStateEventCallback(sdv::IInterfaceAccess *pEventCallback) override#

Register event callback interface. Overload of sdv::ipc::IConnect::RegisterStateEventCallback.

Register a connection state 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 UnregisterStateEventCallback(uint64_t uiCookie) override#

Unregister the state event callback with the returned cookie from the registration. Overload of sdv::ipc::IConnect::UnregisterStateEventCallback.

Parameters:

uiCookie[in] The cookie returned by a previous call to the registration function.

virtual sdv::ipc::EConnectState GetConnectState() const override#

Get the current state of the IPC connection. Overload of sdv::ipc::IConnect::GetConnectState.

Returns:

Returns connection state.

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 SetConnectState(sdv::ipc::EConnectState eConnectState)#

Set the connection state and if needed call the event callback.

Parameters:

eConnectState[in] The new state.

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.