PhoenixSwarm  3.5.0
Library to ease communication between daemons
Loading...
Searching...
No Matches
Message Class Reference

Message exchanged by Daemons. More...

#include <Representation.h>

+ Collaboration diagram for Message:

Public Member Functions

DatagetData ()
 Gets the data of the Message.
 
const DatagetData () const
 Gets the data of the Message.
 
size_t & getId ()
 Gets the id of the Message.
 
size_t getId () const
 Gets the id of the Message.
 
bool & getIsConfirmationNeeded ()
 Gets the isConfirmationNeeded of the Message.
 
bool getIsConfirmationNeeded () const
 Gets the isConfirmationNeeded of the Message.
 
PString & getSender ()
 Gets the sender of the Message.
 
const PString & getSender () const
 Gets the sender of the Message.
 
time_t & getSendTime ()
 Gets the sendTime of the Message.
 
const time_t & getSendTime () const
 Gets the sendTime of the Message.
 
MessageType::MessageTypegetType ()
 Gets the type of the Message.
 
const MessageType::MessageTypegetType () const
 Gets the type of the Message.
 
std::vector< PString > & getVecRecver ()
 Gets the vecRecver of the Message.
 
const std::vector< PString > & getVecRecver () const
 Gets the vecRecver of the Message.
 
 Message ()
 Constructor of class Message.
 
 Message (const Message &other)
 Copy Constructor of class Message.
 
Messageoperator= (const Message &other)
 Operator = of class Message.
 
template<typename Stream, DataStreamMode::DataStreamMode Mode>
bool readWriteStream (Stream &ds)
 Load the current Message with a stream.
 
void setData (const Data &data)
 Sets the data of the Message.
 
void setId (size_t id)
 Sets the id of the Message.
 
void setIsConfirmationNeeded (bool isConfirmationNeeded)
 Sets the isConfirmationNeeded of the Message.
 
void setSender (const PString &sender)
 Sets the sender of the Message.
 
void setSendTime (const time_t &sendTime)
 Sets the sendTime of the Message.
 
void setType (const MessageType::MessageType &type)
 Sets the type of the Message.
 
void setVecRecver (const std::vector< PString > &vecRecver)
 Sets the vecRecver of the Message.
 
virtual ~Message ()
 Destructor of class Message.
 

Protected Member Functions

void copyMessage (const Message &other)
 Copy Function of class Message.
 

Private Member Functions

void initialisationMessage ()
 Initialisation Function of class Message.
 

Private Attributes

Data p_data
 Data in the message.
 
size_t p_id
 Id of the message (will be usefull to trigger method when a transmission is confirmed)
 
bool p_isConfirmationNeeded
 True if the MESSAGE_CONFIRMATION is needed.
 
PString p_sender
 Address of the Daemon which sends the message.
 
time_t p_sendTime
 Time when the message was sent.
 
MessageType::MessageType p_type
 Type of the message.
 
std::vector< PString > p_vecRecver
 Addresses of Daemons which receive the message.
 

Detailed Description

Message exchanged by Daemons.

Definition at line 167 of file Representation.h.

Constructor & Destructor Documentation

◆ Message() [1/2]

Message::Message ( )

Constructor of class Message.

Definition at line 342 of file Representation.cpp.

342 {
344}
void initialisationMessage()
Initialisation Function of class Message.

References initialisationMessage().

Referenced by copyMessage(), Message(), and operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~Message()

Message::~Message ( )
virtual

Destructor of class Message.

Definition at line 347 of file Representation.cpp.

347 {
348
349}

◆ Message() [2/2]

Message::Message ( const Message & other)

Copy Constructor of class Message.

Parameters
other: Message we want ot copy

Definition at line 354 of file Representation.cpp.

354 {
355 copyMessage(other);
356}
void copyMessage(const Message &other)
Copy Function of class Message.

References copyMessage(), and Message().

+ Here is the call graph for this function:

Member Function Documentation

◆ copyMessage()

void Message::copyMessage ( const Message & other)
protected

Copy Function of class Message.

Parameters
other: Message we want ot copy

Definition at line 517 of file Representation.cpp.

517 {
518 p_sendTime = other.p_sendTime;
519 p_id = other.p_id;
521 p_sender = other.p_sender;
522 p_vecRecver = other.p_vecRecver;
523 p_type = other.p_type;
524 p_data = other.p_data;
525}
MessageType::MessageType p_type
Type of the message.
Data p_data
Data in the message.
bool p_isConfirmationNeeded
True if the MESSAGE_CONFIRMATION is needed.
std::vector< PString > p_vecRecver
Addresses of Daemons which receive the message.
PString p_sender
Address of the Daemon which sends the message.
time_t p_sendTime
Time when the message was sent.
size_t p_id
Id of the message (will be usefull to trigger method when a transmission is confirmed)

References Message(), p_data, p_id, p_isConfirmationNeeded, p_sender, p_sendTime, p_type, and p_vecRecver.

Referenced by Message(), and operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getData() [1/2]

Data & Message::getData ( )

Gets the data of the Message.

Returns
data of the Message

Definition at line 510 of file Representation.cpp.

510 {
511 return p_data;
512}

References p_data.

◆ getData() [2/2]

const Data & Message::getData ( ) const

Gets the data of the Message.

Returns
data of the Message

Definition at line 503 of file Representation.cpp.

503 {
504 return p_data;
505}

References p_data.

Referenced by CheckStream< Message >::check_stream(), BaseDaemon::processConfirmedMessage(), and Daemon< _TBackend >::processInputMessage().

+ Here is the caller graph for this function:

◆ getId() [1/2]

size_t & Message::getId ( )

Gets the id of the Message.

Returns
id of the Message

Definition at line 440 of file Representation.cpp.

440 {
441 return p_id;
442}

References p_id.

◆ getId() [2/2]

size_t Message::getId ( ) const

Gets the id of the Message.

Returns
id of the Message

Definition at line 433 of file Representation.cpp.

433 {
434 return p_id;
435}

References p_id.

Referenced by BaseDaemon::addMessageToConfirm(), CheckStream< Message >::check_stream(), and Daemon< _TBackend >::processInputMessage().

+ Here is the caller graph for this function:

◆ getIsConfirmationNeeded() [1/2]

bool & Message::getIsConfirmationNeeded ( )

Gets the isConfirmationNeeded of the Message.

Returns
isConfirmationNeeded of the Message

Definition at line 454 of file Representation.cpp.

454 {
456}

References p_isConfirmationNeeded.

◆ getIsConfirmationNeeded() [2/2]

bool Message::getIsConfirmationNeeded ( ) const

Gets the isConfirmationNeeded of the Message.

Returns
isConfirmationNeeded of the Message

Definition at line 447 of file Representation.cpp.

447 {
449}

References p_isConfirmationNeeded.

Referenced by CheckStream< Message >::check_stream(), Daemon< _TBackend >::processInputMessage(), and Daemon< _TBackend >::sendMessage().

+ Here is the caller graph for this function:

◆ getSender() [1/2]

PString & Message::getSender ( )

Gets the sender of the Message.

Returns
sender of the Message

Definition at line 468 of file Representation.cpp.

468 {
469 return p_sender;
470}

References p_sender.

◆ getSender() [2/2]

const PString & Message::getSender ( ) const

Gets the sender of the Message.

Returns
sender of the Message

Definition at line 461 of file Representation.cpp.

461 {
462 return p_sender;
463}

References p_sender.

Referenced by CheckStream< Message >::check_stream(), and Daemon< _TBackend >::processInputMessage().

+ Here is the caller graph for this function:

◆ getSendTime() [1/2]

time_t & Message::getSendTime ( )

Gets the sendTime of the Message.

Returns
sendTime of the Message

Definition at line 426 of file Representation.cpp.

426 {
427 return p_sendTime;
428}

References p_sendTime.

◆ getSendTime() [2/2]

const time_t & Message::getSendTime ( ) const

Gets the sendTime of the Message.

Returns
sendTime of the Message

Definition at line 419 of file Representation.cpp.

419 {
420 return p_sendTime;
421}

References p_sendTime.

Referenced by CheckStream< Message >::check_stream(), BaseDaemon::checkMessageTimeout(), BaseDaemon::processConfirmedMessage(), and Daemon< _TBackend >::processInputMessage().

+ Here is the caller graph for this function:

◆ getType() [1/2]

MessageType::MessageType & Message::getType ( )

Gets the type of the Message.

Returns
type of the Message

Definition at line 496 of file Representation.cpp.

496 {
497 return p_type;
498}

References p_type.

◆ getType() [2/2]

const MessageType::MessageType & Message::getType ( ) const

Gets the type of the Message.

Returns
type of the Message

Definition at line 489 of file Representation.cpp.

489 {
490 return p_type;
491}

References p_type.

Referenced by CheckStream< Message >::check_stream(), and Daemon< _TBackend >::processInputMessage().

+ Here is the caller graph for this function:

◆ getVecRecver() [1/2]

std::vector< PString > & Message::getVecRecver ( )

Gets the vecRecver of the Message.

Returns
vecRecver of the Message

Definition at line 482 of file Representation.cpp.

482 {
483 return p_vecRecver;
484}

References p_vecRecver.

◆ getVecRecver() [2/2]

const std::vector< PString > & Message::getVecRecver ( ) const

Gets the vecRecver of the Message.

Returns
vecRecver of the Message

Definition at line 475 of file Representation.cpp.

475 {
476 return p_vecRecver;
477}

References p_vecRecver.

Referenced by CheckStream< Message >::check_stream(), BaseDaemon::checkMessageTimeout(), BaseDaemon::processConfirmedMessage(), Daemon< _TBackend >::processInputMessage(), Daemon< _TBackend >::sendData(), and Daemon< _TBackend >::sendMessage().

+ Here is the caller graph for this function:

◆ initialisationMessage()

void Message::initialisationMessage ( )
private

Initialisation Function of class Message.

Definition at line 528 of file Representation.cpp.

528 {
529 p_id = 0lu;
531 p_sender = "";
532}

References p_id, p_isConfirmationNeeded, and p_sender.

Referenced by Message().

+ Here is the caller graph for this function:

◆ operator=()

Message & Message::operator= ( const Message & other)

Operator = of class Message.

Parameters
other: Message we want ot copy
Returns
copied class Message

Definition at line 362 of file Representation.cpp.

362 {
363 copyMessage(other);
364 return *this;
365}

References copyMessage(), and Message().

+ Here is the call graph for this function:

◆ readWriteStream()

template<typename Stream, DataStreamMode::DataStreamMode Mode>
bool Message::readWriteStream ( Stream & ds)
inline

Load the current Message with a stream.

Parameters
[out]ds: stream to be used
Returns
true on success, false otherwise

Definition at line 200 of file Representation.h.

200 {
201 bool b(true);
202 b &= DataStream<Stream, Mode, time_t >::data_stream(ds, p_sendTime);
203 b &= DataStream<Stream, Mode, size_t >::data_stream(ds, p_id);
204 b &= DataStream<Stream, Mode, bool >::data_stream(ds, p_isConfirmationNeeded);
205 b &= DataStream<Stream, Mode, PString >::data_stream(ds, p_sender);
206 b &= DataStream<Stream, Mode, std::vector<PString> >::data_stream(ds, p_vecRecver);
207 b &= DataStream<Stream, Mode, MessageType::MessageType >::data_stream(ds, p_type);
209 return b;
210 }
static bool data_stream(Stream &ds, Data &data)
Generic function to load/save/serialise/deserialise Data.

References DataStream< Stream, Mode, Data >::data_stream(), p_data, p_id, p_isConfirmationNeeded, p_sender, p_sendTime, p_type, and p_vecRecver.

Referenced by DataStream< Stream, Mode, Message >::data_stream().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setData()

void Message::setData ( const Data & data)

Sets the data of the Message.

Parameters
data: data of the Message

Definition at line 412 of file Representation.cpp.

412 {
413 p_data = data;
414}

References p_data.

Referenced by Daemon< _TBackend >::sendData().

+ Here is the caller graph for this function:

◆ setId()

void Message::setId ( size_t id)

Sets the id of the Message.

Parameters
id: id of the Message

Definition at line 377 of file Representation.cpp.

377 {
378 p_id = id;
379}

References p_id.

Referenced by Daemon< _TBackend >::processInputMessage(), and Daemon< _TBackend >::sendData().

+ Here is the caller graph for this function:

◆ setIsConfirmationNeeded()

void Message::setIsConfirmationNeeded ( bool isConfirmationNeeded)

Sets the isConfirmationNeeded of the Message.

Parameters
isConfirmationNeeded: isConfirmationNeeded of the Message

Definition at line 384 of file Representation.cpp.

384 {
385 p_isConfirmationNeeded = isConfirmationNeeded;
386}

References p_isConfirmationNeeded.

Referenced by Daemon< _TBackend >::sendData().

+ Here is the caller graph for this function:

◆ setSender()

void Message::setSender ( const PString & sender)

Sets the sender of the Message.

Parameters
sender: sender of the Message

Definition at line 391 of file Representation.cpp.

391 {
392 p_sender = sender;
393}

References p_sender.

Referenced by Daemon< _TBackend >::processInputMessage(), and Daemon< _TBackend >::sendData().

+ Here is the caller graph for this function:

◆ setSendTime()

void Message::setSendTime ( const time_t & sendTime)

Sets the sendTime of the Message.

Parameters
sendTime: sendTime of the Message

Definition at line 370 of file Representation.cpp.

370 {
371 p_sendTime = sendTime;
372}

References p_sendTime.

Referenced by Daemon< _TBackend >::processInputMessage(), and Daemon< _TBackend >::sendData().

+ Here is the caller graph for this function:

◆ setType()

void Message::setType ( const MessageType::MessageType & type)

Sets the type of the Message.

Parameters
type: type of the Message

Definition at line 405 of file Representation.cpp.

405 {
406 p_type = type;
407}

References p_type.

Referenced by Daemon< _TBackend >::processInputMessage(), and Daemon< _TBackend >::sendData().

+ Here is the caller graph for this function:

◆ setVecRecver()

void Message::setVecRecver ( const std::vector< PString > & vecRecver)

Sets the vecRecver of the Message.

Parameters
vecRecver: vecRecver of the Message

Definition at line 398 of file Representation.cpp.

398 {
399 p_vecRecver = vecRecver;
400}

References p_vecRecver.

Member Data Documentation

◆ p_data

Data Message::p_data
private

Data in the message.

Definition at line 229 of file Representation.h.

Referenced by copyMessage(), getData(), getData(), readWriteStream(), and setData().

◆ p_id

size_t Message::p_id
private

Id of the message (will be usefull to trigger method when a transmission is confirmed)

Definition at line 219 of file Representation.h.

Referenced by copyMessage(), getId(), getId(), initialisationMessage(), readWriteStream(), and setId().

◆ p_isConfirmationNeeded

bool Message::p_isConfirmationNeeded
private

True if the MESSAGE_CONFIRMATION is needed.

Definition at line 221 of file Representation.h.

Referenced by copyMessage(), getIsConfirmationNeeded(), getIsConfirmationNeeded(), initialisationMessage(), readWriteStream(), and setIsConfirmationNeeded().

◆ p_sender

PString Message::p_sender
private

Address of the Daemon which sends the message.

Definition at line 223 of file Representation.h.

Referenced by copyMessage(), getSender(), getSender(), initialisationMessage(), readWriteStream(), and setSender().

◆ p_sendTime

time_t Message::p_sendTime
private

Time when the message was sent.

Definition at line 217 of file Representation.h.

Referenced by copyMessage(), getSendTime(), getSendTime(), readWriteStream(), and setSendTime().

◆ p_type

MessageType::MessageType Message::p_type
private

Type of the message.

Definition at line 227 of file Representation.h.

Referenced by copyMessage(), getType(), getType(), readWriteStream(), and setType().

◆ p_vecRecver

std::vector<PString> Message::p_vecRecver
private

Addresses of Daemons which receive the message.

Definition at line 225 of file Representation.h.

Referenced by copyMessage(), getVecRecver(), getVecRecver(), readWriteStream(), and setVecRecver().


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