QMsgClient Class Reference
[Networking]

Inheritance diagram for QMsgClient:

QBaseClient QApolloSocketClient

List of all members.


Detailed Description

client side methods for interaction with Message Logger server

Author:
sergio.didomizio@ge.infn.it

Public Member Functions

 QMsgClient ()
 default constructor: server address and port are determined from environment variables. A QError is thrown if they are not set.
 QMsgClient (const std::string &address, const std::string &port)
 default constructor
virtual ~QMsgClient ()
 destructor
bool RegisterProcess (const std::string &processName, const std::string &host, pid_t processPid)
 register a process to message server
bool UnregisterProcess (const std::string &processName)
 unregister a process previously registered to message server
bool SendStatus (const std::string &processName, QDaqCommonDefs::ProcessStatus_t status)
 inform message server about the status of a process
bool SendLog (const std::string &processName, const std::string &message, MsgLevel level=InfoMsg)
 send log message to message server
bool GetStatus (const std::string &processName, QDaqCommonDefs::ProcessStatus_t &status)
 get current status for a certain process
bool GetRegisteredProcesses (std::list< std::string > &processes)
 get a list of registered processes
bool IsRegistered (const std::string &processName, bool &isReg)
 check whether a certain process is registered
bool GetMessageIdByTime (time_t time, int &id)
 get id of first message logged after a given time
bool GetFirstMessageId (int &id)
 get id associated to the oldest message recorded by the logger
bool GetLastMessageId (int &id)
 get id associated to the most recent message recorded by the logger
bool GetFormattedMessage (int id, std::string &message)
 get message formatted as string
bool GetMessage (int id, QLogInfo &logInfo)
 retrieve QLogInfo object associated to a given log id

Constructor & Destructor Documentation

QMsgClient::QMsgClient ( const std::string &  address,
const std::string &  port 
)

default constructor

Parameters:
address network address of the MsgLogger server
port port for network connection


Member Function Documentation

bool QMsgClient::RegisterProcess ( const std::string &  processName,
const std::string &  host,
pid_t  processPid 
)

register a process to message server

Parameters:
processName process name with which the server will identify the client in future communications
host the host name from which the client is connecting
pid process id of the process that is being registered
Returns:
true on success, false if a process with the same name is already registered or an error occurred in the network communication.

References QBaseClient::ExecCommand(), QStringHandler::IntToString(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().

Referenced by QApolloMessenger::RegisterProcess().

bool QMsgClient::UnregisterProcess ( const std::string &  processName  ) 

unregister a process previously registered to message server

Parameters:
processName name of the process to be released
Returns:
true on success, false if the requested process was not registered or an error occurred in the network communication.

References QBaseClient::ExecCommand(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().

Referenced by QApolloMessenger::UnregisterProcess().

bool QMsgClient::SendStatus ( const std::string &  processName,
QDaqCommonDefs::ProcessStatus_t  status 
)

inform message server about the status of a process

Parameters:
processName name of the process
status process status to be sent return true on success, false if process was not previously registered or an error occurred in the network communication

References QBaseClient::ExecCommand(), QDaqCommonDefs::ProcessStatusEnumToString(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().

Referenced by QApolloMessenger::SendStatus().

bool QMsgClient::SendLog ( const std::string &  processName,
const std::string &  message,
MsgLevel  level = InfoMsg 
)

send log message to message server

Parameters:
processName name of the process that is sending the message
message log message
level log level (defaults to InfoMsg)
Returns:
true on success or false if sending process is not registerd to message server or an error occurred in the network communication

References QBaseClient::ExecCommand(), QStringHandler::IntToString(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().

Referenced by QApolloMessenger::Send().

bool QMsgClient::GetStatus ( const std::string &  processName,
QDaqCommonDefs::ProcessStatus_t status 
)

get current status for a certain process

Parameters:
processName name of the process for which informations are requested
status is filled with current status of the process
Returns:
true on success or false if requested process is not registered or an error occurs in the network communication

References QBaseClient::ExecCommand(), QBaseClient::GetString(), QDaqCommonDefs::ProcessStatusStringToEnum(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().

Referenced by QDaqServer::CheckStatus().

bool QMsgClient::GetRegisteredProcesses ( std::list< std::string > &  processes  ) 

get a list of registered processes

Parameters:
processes filled with the names of registered processes
Returns:
true on success, false in case of network communication error

References QBaseClient::ExecCommand(), QBaseClient::GetInt(), QBaseClient::GetParList(), QNwMessageBuilder::SetCommand(), and QNwMessageBuilder::SetModifier().

Referenced by IsRegistered().

bool QMsgClient::IsRegistered ( const std::string &  processName,
bool &  isReg 
)

check whether a certain process is registered

Parameters:
processName name of the process to eb cheched
isReg will be set to true if process is regstered
Returns:
true, unless an error occurs in network communication
This method searches for processName through the list obtained with GetRegisteredProcesses()

References GetRegisteredProcesses().

Referenced by QDaqServer::CheckStatus(), and QDaqServer::Unregistered().

bool QMsgClient::GetMessageIdByTime ( time_t  time,
int &  id 
)

get id of first message logged after a given time

Parameters:
time requested time (unix time)
id filled with id associated to first log message occurring after requested time, or zero if the last message was logged before the requested time
Returns:
true, unless an error occurs in network communication

References QBaseClient::ExecCommand(), QBaseClient::GetInt(), QStringHandler::IntToString(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().

bool QMsgClient::GetFirstMessageId ( int &  id  ) 

get id associated to the oldest message recorded by the logger

Parameters:
id filled with the requested id, or zero if no messages are present in the message queue
Returns:
true unless an error occurs in network communication

References QBaseClient::ExecCommand(), QBaseClient::GetInt(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().

bool QMsgClient::GetLastMessageId ( int &  id  ) 

get id associated to the most recent message recorded by the logger

Parameters:
id filled with the requested id, or zero if no messages are present in the message queue
Returns:
true unless an error occurs in network communication

References QBaseClient::ExecCommand(), QBaseClient::GetInt(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().

bool QMsgClient::GetFormattedMessage ( int  id,
std::string &  message 
)

get message formatted as string

Parameters:
id requested log id
message string filled with log message
Returns:
true on success, false in case of network communication error or if requested log id is invalid

References QBaseClient::ExecCommand(), QBaseClient::GetString(), QStringHandler::IntToString(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().

bool QMsgClient::GetMessage ( int  id,
QLogInfo logInfo 
)

retrieve QLogInfo object associated to a given log id

Parameters:
id requested log id
logInfo filled with requested QLogInfo object
Returns:
true on success, false in case of network communication error or if requested log id is invalid

References QBaseClient::ExecCommand(), QLogInfo::Fill(), QBaseClient::GetInt(), QBaseClient::GetString(), QStringHandler::IntToString(), QError::Set(), QNwMessageBuilder::SetCommand(), QNwMessageBuilder::SetModifier(), and QNwMessageBuilder::SetParameter().


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

Generated on Tue Nov 16 10:50:07 2010 for CUORE Software by  doxygen 1.5.6