GlobalObjects
Loading...
Searching...
No Matches
glo::Communicator Class Referenceabstract

Superclass of LocalThread, ClientThread and ServerThread, because they can act as senders and receivers (communicators) of requests and inherit a send and receive method for this. More...

#include <GloCommunicator.h>

Inheritance diagram for glo::Communicator:

Public Member Functions

 Communicator ()
 
virtual ~Communicator ()
 
virtual int assignDBManager (OrderMsg *pOrderMsg)
 
std::string getClientName () const
 
const std::string & getClientNameAsRef ()
 
unsigned int getCommunicatorID () const
 
virtual void setClientName (const std::string &rstrClientName)
 
virtual void setCommunicatorID (unsigned int uiID)
 
virtual int takeOverResult (OrderMsg *pOrderMsg)
 
bool operator== (const Communicator &rT) const
 
bool operator!= (const Communicator &rT) const
 
- Public Member Functions inherited from eut::RepeatingThread
 RepeatingThread ()
 
virtual ~RepeatingThread ()
 
virtual void cancel ()
 
virtual void finishBreak ()
 
int getBreakCounter ()
 
bool isInExclusiveAccess () const
 
void setExclusiveAccess ()
 
void signalInput ()
 
virtual int start ()
 
RepeatingThread::STATUS status () const
 
virtual void takeABreak ()
 
bool testCancel ()
 
void unsetExclusiveAccess ()
 
void waitForInput ()
 

Protected Member Functions

virtual void processServerMsg (OrderMsg *pOrderMsg) const
 
virtual int sendToDBManager (OrderMsg *pOrderMsg) const =0
 
virtual void work () override
 
- Protected Member Functions inherited from eut::RepeatingThread
ORDER getOrder ()
 
STATUS getStatus ()
 
void setStatus (STATUS eStatus)
 
void threadWork ()
 
void toOrder (ORDER eOrder)
 

Protected Attributes

unsigned int m_uiOrderCounter
 

Private Member Functions

 Communicator (const Communicator &)
 
Communicatoroperator= (const Communicator &)
 

Private Attributes

std::queue< OrderMsg * > m_MsgQueue
 
std::string m_sClientName
 
unsigned int m_uiID
 

Additional Inherited Members

- Public Types inherited from eut::RepeatingThread
enum  EuTHREADERROR { EuTHREAD_ERR_NO_THREAD = -10301 , EuTHREAD_ERR_THREAD_ALREADY_WORKING = -10302 , EuTHREAD_ERR_THREAD_BREAK_COUNT_LESS_THAN_ZERO = -10303 , EuTHREAD_ERR_UNKNOWN = -10400 }
 Error range = -10301 to -10400 More...
 
enum  ORDER { eUNDEFINED , eDO_WORK , eEXIT }
 
enum  STATUS {
  eAT_THE_START , eWORKING , ePAUSING , eENDING ,
  eCOMPLETED
}
 
- Public Attributes inherited from eut::RepeatingThread
std::string m_strDebugInfo
 

Detailed Description

Superclass of LocalThread, ClientThread and ServerThread, because they can act as senders and receivers (communicators) of requests and inherit a send and receive method for this.

To allow parallel access to the database, this class is designed as a thread (derived from EuEndlessPThread).

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ Communicator() [1/2]

glo::Communicator::Communicator ( )

Standard constructor.

◆ ~Communicator()

virtual glo::Communicator::~Communicator ( )
virtual

Destructor.

◆ Communicator() [2/2]

glo::Communicator::Communicator ( const Communicator & )
private

The copy constructor is not available.

Member Function Documentation

◆ assignDBManager()

virtual int glo::Communicator::assignDBManager ( OrderMsg * pOrderMsg)
virtual

Sends a job to the Manager and waits for response.

Parameters
[in]pOrderMsgThe order for the Manager.
Returns
A return value < 0 indicates an error.

Reimplemented in glo::ClientThread, glo::LocalThread, and glo::ServerThread.

◆ getClientName()

std::string glo::Communicator::getClientName ( ) const

Returns the name of the communicator.

Returns
The name of the communicator.

◆ getClientNameAsRef()

const std::string & glo::Communicator::getClientNameAsRef ( )

Returns the name of the communicator as reference.

Returns
The name of the communicator.

◆ getCommunicatorID()

unsigned int glo::Communicator::getCommunicatorID ( ) const

Returns the unique ID of the communicator.

Returns
The unique ID of the communicator.

◆ operator!=()

bool glo::Communicator::operator!= ( const Communicator & rT) const

Comparison operator.

Parameters
[in]rTThe object to be compared with this one.

◆ operator=()

Communicator & glo::Communicator::operator= ( const Communicator & )
private

The assignment operator is not available.

◆ operator==()

bool glo::Communicator::operator== ( const Communicator & rT) const

Comparison operator.

Parameters
[in]rTThe object to be compared with this one.

◆ processServerMsg()

virtual void glo::Communicator::processServerMsg ( OrderMsg * pOrderMsg) const
protectedvirtual

Processes only one notification order here (Orderstayp == OrderMsg::eNOTIFY_CLIENT).

Each order is removed from memory here, so it must be called by the overwritten methods in the subclasses.

Parameters
[in]pOrderMsgThe order.

Reimplemented in glo::ServerThread.

◆ sendToDBManager()

virtual int glo::Communicator::sendToDBManager ( OrderMsg * pOrderMsg) const
protectedpure virtual

Sends an order in subclasses (received via assignDBManager() ) to the Manager. In the subclasses directly or via TCP/IP.

Parameters
[in]pOrderMsgThe order for the Manager.
Returns
A return value < 0 indicates an error.

Implemented in glo::ClientThread, glo::LocalThread, and glo::ServerThread.

◆ setClientName()

virtual void glo::Communicator::setClientName ( const std::string & rstrClientName)
virtual

Sets the name of the communicator.

Parameters
[in]rstrClientNameThe name of the communicator.

◆ setCommunicatorID()

virtual void glo::Communicator::setCommunicatorID ( unsigned int uiID)
virtual
Parameters
[in]uiIDThe unique ID of the communicator.
Attention
The calling instance must ensure that the ID is unique.

◆ takeOverResult()

virtual int glo::Communicator::takeOverResult ( OrderMsg * pOrderMsg)
virtual

Adopts a message into its message queue for processing.

Parameters
[in]pOrderMsgThe message to be processed.
Returns
A return value < 0 indicates an error.
See also
signalInput()

Reimplemented in glo::ServerThread.

◆ work()

virtual void glo::Communicator::work ( )
overrideprotectedvirtual

This method is executed as a thread. The message queue is queried for requests and replies to its own requests (the system 'sleeps' until a message is placed in the queue).

See also
waitForInput()

Implements eut::RepeatingThread.

Member Data Documentation

◆ m_MsgQueue

std::queue<OrderMsg *> glo::Communicator::m_MsgQueue
private

The notification queue; notifications such as information from monitored objects are set.

◆ m_sClientName

std::string glo::Communicator::m_sClientName
private

Every communicator can have a name.

◆ m_uiID

unsigned int glo::Communicator::m_uiID
private

A unique ID of the (derived) communicator.

◆ m_uiOrderCounter

unsigned int glo::Communicator::m_uiOrderCounter
protected

Orders to the Manager get a unique order number. The answers from the Manager are referenced by this order number, so they can be assigned to an order.


The documentation for this class was generated from the following file: