COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Public Member Functions | Private Member Functions | Private Attributes | List of all members
NetworkThread Class Reference

#include <NetworkThread.hpp>

Inherits QThread, and SignalHandler.

Public Member Functions

 NetworkThread (QObject *parent=nullptr)
 Constructor. More...
 
 ~NetworkThread ()
 
bool connect_to_host (const std::string &hostAddress, unsigned short port)
 
void disconnect_from_server (bool shutServer)
 Disconnects from the server, then closes. More...
 
bool is_connected () const
 
void send (common::SignalArgs &signal)
 Sends a signal frame to the server. The client UuiD is added to the frame. More...
 
void run ()
 Executes the thread event loop. More...
 
void set_error_handler (boost::weak_ptr< network::ErrorHandler > handler)
 
- Public Member Functions inherited from SignalHandler
 ~SignalHandler ()
 
const storage_tsignal_list () const
 
SignalPtr signal (const SignalID &sname)
 
SignalCPtr signal (const SignalID &sname) const
 
SignalRet call_signal (const SignalID &sname, SignalArgs &sinput)
 Calls the signal by providing its name and input. More...
 
SignalRet call_signal (const SignalID &sname, std::vector< std::string > &sinput)
 Calls the signal by providing its name and input. More...
 
bool signal_exists (const SignalID &sname) const
 Checks if a signal exists or not. More...
 
Signalregist_signal (const SignalID &sname)
 Regist signal. More...
 
void unregist_signal (const SignalID &sname)
 Unregist signal. More...
 

Private Member Functions

void init_read ()
 
void callback_connect (const boost::system::error_code &error)
 
void callback_read (const boost::system::error_code &error)
 
void callback_send (const boost::system::error_code &error)
 

Private Attributes

boost::shared_ptr< network::TCPConnectionm_connection
 
common::SignalArgs m_buffer
 
boost::asio::io_service * m_io_service
 
boost::asio::ip::tcp::endpoint * m_endpoint
 
boost::shared_ptr< network::ErrorHandlerm_error_handler
 
bool m_request_disc
 
QString m_hostname
 
quint16 m_port
 
QMutex m_mutex
 

Additional Inherited Members

- Public Types inherited from SignalHandler
typedef std::vector< SignalPtrstorage_t
 storage type for signals More...
 
- Public Attributes inherited from SignalHandler
storage_t m_signals
 storage of the signals More...
 

Detailed Description

Thread that manages the network.

Author
Quentin Gasper.

Definition at line 43 of file NetworkThread.hpp.

Constructor & Destructor Documentation

NetworkThread ( QObject *  parent = nullptr)

Constructor.

Definition at line 44 of file NetworkThread.cpp.

Definition at line 58 of file NetworkThread.cpp.

Member Function Documentation

void callback_connect ( const boost::system::error_code &  error)
private

Definition at line 200 of file NetworkThread.cpp.

void callback_read ( const boost::system::error_code &  error)
private

Definition at line 217 of file NetworkThread.cpp.

void callback_send ( const boost::system::error_code &  error)
private

Definition at line 262 of file NetworkThread.cpp.

bool connect_to_host ( const std::string &  hostAddress,
unsigned short  port 
)

Attempts to connect to a remote host.

Warning
This is a non-blocking method. It does not wait the connection to be established. It sends a request to the system and returns directly after.
Parameters
hostAddressAddress of the host to connect to.
portThe port number to use.

Definition at line 76 of file NetworkThread.cpp.

void disconnect_from_server ( bool  shutServer)

Disconnects from the server, then closes.

Parameters
shutServerIf true, a request to shut down the server is sent.

Definition at line 121 of file NetworkThread.cpp.

void init_read ( )
private

Definition at line 188 of file NetworkThread.cpp.

bool is_connected ( ) const

Definition at line 111 of file NetworkThread.cpp.

void run ( )

Executes the thread event loop.

Definition at line 159 of file NetworkThread.cpp.

void send ( common::SignalArgs signal)

Sends a signal frame to the server. The client UuiD is added to the frame.

Parameters
signalThe signal to send.

Definition at line 141 of file NetworkThread.cpp.

void set_error_handler ( boost::weak_ptr< network::ErrorHandler handler)

Member Data Documentation

common::SignalArgs m_buffer
private

Definition at line 96 of file NetworkThread.hpp.

boost::shared_ptr<network::TCPConnection> m_connection
private

Definition at line 94 of file NetworkThread.hpp.

boost::asio::ip::tcp::endpoint* m_endpoint
private

Definition at line 100 of file NetworkThread.hpp.

boost::shared_ptr<network::ErrorHandler> m_error_handler
private

Definition at line 102 of file NetworkThread.hpp.

QString m_hostname
private

Definition at line 106 of file NetworkThread.hpp.

boost::asio::io_service* m_io_service
private

Definition at line 98 of file NetworkThread.hpp.

QMutex m_mutex
private

Definition at line 110 of file NetworkThread.hpp.

quint16 m_port
private

Definition at line 108 of file NetworkThread.hpp.

bool m_request_disc
private

Definition at line 104 of file NetworkThread.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin