QNwMessageBuilder Class Reference

List of all members.


Detailed Description

utility class used to build client side network messages suitable for the syntax used in the apollo client/server communication

Author:
Sergio Di Domizio

Public Member Functions

 QNwMessageBuilder ()
 ctor
virtual ~QNwMessageBuilder ()
 dtor
bool SetCommand (const std::string &command)
 set command name
void SetModifier (const std::string &modifier)
 set command modifier
bool AddParameter (std::string parName, std::string parVal)
 add parameter in parameters map.
bool SetParameter (std::string parName, std::string parVal)
 same as AddParameter(), except for the fact that the pre-existing list of values associated to parName is flushed before adding parVal.
bool SetParameterList (std::string parName, std::list< std::string > values)
 set multiple values parameter in parameters map. Pre-existing content of list associated to parName is overwritten.
bool BuildMessage (std::string &nwMessage) const
 fill nwMessage with formatted network message
void Clear ()
 clear command, modifier and parameters map

Private Member Functions

bool Cleanup (std::string &value)
 removes trailing spaces and escapes special tokens on value

Private Attributes

const std::string kTokens
std::string fCommand
std::string fModifier
std::map< std::string,
std::list< std::string > > 
fParameters

Member Function Documentation

bool QNwMessageBuilder::SetCommand ( const std::string &  command  ) 

set command name

Returns:
true unless, after removing trailing spaces, command is empty

References QStringHandler::DoubleSwallowSpaces(), and fCommand.

Referenced by QSlowControlClient::AdjustFEOffset(), QSlowControlClient::GetBasket(), QSlowControlClient::GetBSCutFreq(), QSlowControlClient::GetBSFilterEnable(), QDaqClient::GetCurrentRunNumber(), QDaqClient::GetDaqStatus(), QSlowControlClient::GetEleRegister(), QSlowControlClient::GetFEBias(), QSlowControlClient::GetFEBiasPolarity(), QSlowControlClient::GetFEGain(), QSlowControlClient::GetFEInput(), QSlowControlClient::GetFELoadResistor(), QSlowControlClient::GetFEOffsetDAC(), QSlowControlClient::GetFEOffsetMSB(), QSlowControlClient::GetFEOffsetPolarity(), QSlowControlClient::GetFEOffsetSpecialBit(), QSlowControlClient::GetFETestSignal(), QMsgClient::GetFirstMessageId(), QMsgClient::GetFormattedMessage(), QSlowControlClient::GetInterface(), QMsgClient::GetLastMessageId(), QMsgClient::GetMessage(), QMsgClient::GetMessageIdByTime(), QSlowControlClient::GetMode(), QSlowControlClient::GetPSupplyIout(), QSlowControlClient::GetPSupplyIset(), QSlowControlClient::GetPSupplyOutputEnable(), QSlowControlClient::GetPSupplyVout(), QSlowControlClient::GetPSupplyVset(), QSlowControlClient::GetPulserRegister(), QMsgClient::GetRegisteredProcesses(), QMsgClient::GetStatus(), QCommandHandler::HandleCommand(), QSlowControlClient::LoadDevice(), QMsgClient::RegisterProcess(), QMsgClient::SendLog(), QMsgClient::SendStatus(), QSlowControlClient::SetBaseMode(), QSlowControlClient::SetBSCutFreq(), QSlowControlClient::SetBSFilterEnable(), QSlowControlClient::SetEleRegister(), QSlowControlClient::SetFEBias(), QSlowControlClient::SetFEBiasPolarity(), QSlowControlClient::SetFEGain(), QSlowControlClient::SetFEInput(), QSlowControlClient::SetFELoadResistor(), QSlowControlClient::SetFEOffsetDAC(), QSlowControlClient::SetFEOffsetMSB(), QSlowControlClient::SetFEOffsetPolarity(), QSlowControlClient::SetFEOffsetSpecialBit(), QSlowControlClient::SetFETestSignal(), QSlowControlClient::SetPSupplyIset(), QSlowControlClient::SetPSupplyOutputEnable(), QSlowControlClient::SetPSupplyVset(), QSlowControlClient::SetRunMode(), QSlowControlClient::SetTuningMode(), QSlowControlClient::SetWriteMode(), QDaqClient::StartRun(), QDaqClient::StopRun(), QMsgClient::UnregisterProcess(), and QSlowControlClient::WritePulser().

bool QNwMessageBuilder::AddParameter ( std::string  parName,
std::string  parVal 
)

add parameter in parameters map.

Parameters:
parVal parameter value formatted as a string.
Returns:
true unless parName or parVal are invalid (see detailed description)
parName and parVal cannot be non empty or composed by spaces only.
Before being added to the parameters map, trailing spaces are removed from parName and parVal.
Then the special tokens in parName and parVal are escaped using the backslash character. If all of these operations are succesful, parVal is appended to the list of values associated to parName.

References Cleanup(), and fParameters.

bool QNwMessageBuilder::SetParameterList ( std::string  parName,
std::list< std::string >  values 
)

set multiple values parameter in parameters map. Pre-existing content of list associated to parName is overwritten.

Parameters:
values list of parameter values formatted as string
Returns:
true unless parName or any of the elements in values are invalid (see detailed description for AddParameter())

References Cleanup(), and fParameters.

Referenced by QCommandHandler::HandleCommand().

bool QNwMessageBuilder::BuildMessage ( std::string &  nwMessage  )  const

fill nwMessage with formatted network message

Returns:
true unless command is not set
the formatted message has all special tokens escaped and contains the "End of Message" character (newline).

References fCommand, QNetworkString::FixNewLines(), fModifier, and fParameters.

Referenced by QBaseClient::ExecCommand(), and QCommandHandler::HandleCommand().

bool QNwMessageBuilder::Cleanup ( std::string &  value  )  [private]

removes trailing spaces and escapes special tokens on value

Returns:
true unless value contains white spaces only

References QStringHandler::DoubleSwallowSpaces(), QStringHandler::Escape(), and kTokens.

Referenced by AddParameter(), SetParameter(), and SetParameterList().


Member Data Documentation

const std::string QNwMessageBuilder::kTokens [private]

special tokens used in network message syntax: ';', '=', ' ' and ''

Referenced by Cleanup().

std::string QNwMessageBuilder::fCommand [private]

command name

Referenced by BuildMessage(), Clear(), and SetCommand().

std::string QNwMessageBuilder::fModifier [private]

command modifier

Referenced by BuildMessage(), Clear(), and SetModifier().

std::map<std::string, std::list<std::string> > QNwMessageBuilder::fParameters [private]

key: parameter name, value: list of parameter values formatted as string

Referenced by AddParameter(), BuildMessage(), Clear(), QNwMessageBuilder(), SetParameter(), and SetParameterList().


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