PhoenixSwarm  5.1.1
Library to ease communication between daemons
Loading...
Searching...
No Matches
Swarm::Message Class Reference

Message exchanged by Daemons. More...

#include <Representation.h>

+ Collaboration diagram for Swarm::Message:

Public Member Functions

Swarm::DatagetData ()
 Gets the data of the Message.
 
const Swarm::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 Swarm::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

Swarm::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 168 of file Representation.h.

Constructor & Destructor Documentation

◆ Message() [1/2]

Message::Message ( )

Constructor of class Message.

Definition at line 344 of file Representation.cpp.

344 {
346}
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 349 of file Representation.cpp.

349 {
350
351}

◆ Message() [2/2]

Message::Message ( const Message & other)

Copy Constructor of class Message.

Parameters
other: Message we want ot copy

Definition at line 356 of file Representation.cpp.

356 {
357 copyMessage(other);
358}
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 519 of file Representation.cpp.

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

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]

Swarm::Data & Message::getData ( )

Gets the data of the Message.

Returns
data of the Message

Definition at line 512 of file Representation.cpp.

512 {
513 return p_data;
514}

References p_data.

◆ getData() [2/2]

const Swarm::Data & Message::getData ( ) const

Gets the data of the Message.

Returns
data of the Message

Definition at line 505 of file Representation.cpp.

505 {
506 return p_data;
507}

References p_data.

Referenced by CheckStream< Swarm::Message >::check_stream(), Swarm::BaseDaemon::processConfirmedMessage(), and Swarm::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 442 of file Representation.cpp.

442 {
443 return p_id;
444}

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 435 of file Representation.cpp.

435 {
436 return p_id;
437}

References p_id.

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

+ 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 456 of file Representation.cpp.

456 {
458}

References p_isConfirmationNeeded.

◆ getIsConfirmationNeeded() [2/2]

bool Message::getIsConfirmationNeeded ( ) const

Gets the isConfirmationNeeded of the Message.

Returns
isConfirmationNeeded of the Message

Definition at line 449 of file Representation.cpp.

449 {
451}

References p_isConfirmationNeeded.

Referenced by CheckStream< Swarm::Message >::check_stream(), Swarm::Daemon< _TBackend >::processInputMessage(), and Swarm::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 470 of file Representation.cpp.

470 {
471 return p_sender;
472}

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 463 of file Representation.cpp.

463 {
464 return p_sender;
465}

References p_sender.

Referenced by CheckStream< Swarm::Message >::check_stream(), and Swarm::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 428 of file Representation.cpp.

428 {
429 return p_sendTime;
430}

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 421 of file Representation.cpp.

421 {
422 return p_sendTime;
423}

References p_sendTime.

Referenced by CheckStream< Swarm::Message >::check_stream(), Swarm::BaseDaemon::checkMessageTimeout(), Swarm::BaseDaemon::processConfirmedMessage(), and Swarm::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 498 of file Representation.cpp.

498 {
499 return p_type;
500}

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 491 of file Representation.cpp.

491 {
492 return p_type;
493}

References p_type.

Referenced by CheckStream< Swarm::Message >::check_stream(), and Swarm::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 484 of file Representation.cpp.

484 {
485 return p_vecRecver;
486}

References p_vecRecver.

◆ getVecRecver() [2/2]

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

◆ initialisationMessage()

void Message::initialisationMessage ( )
private

Initialisation Function of class Message.

Definition at line 530 of file Representation.cpp.

530 {
531 p_id = 0lu;
533 p_sender = "";
534}

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 364 of file Representation.cpp.

364 {
365 copyMessage(other);
366 return *this;
367}

References copyMessage(), and Message().

+ Here is the call graph for this function:

◆ readWriteStream()

template<typename Stream, DataStreamMode::DataStreamMode Mode>
bool Swarm::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 201 of file Representation.h.

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

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

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

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

◆ setData()

void Message::setData ( const Swarm::Data & data)

Sets the data of the Message.

Parameters
data: data of the Message

Definition at line 414 of file Representation.cpp.

414 {
415 p_data = data;
416}

References p_data.

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

+ 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 379 of file Representation.cpp.

379 {
380 p_id = id;
381}

References p_id.

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

+ 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 386 of file Representation.cpp.

386 {
387 p_isConfirmationNeeded = isConfirmationNeeded;
388}

References p_isConfirmationNeeded.

Referenced by Swarm::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 393 of file Representation.cpp.

393 {
394 p_sender = sender;
395}

References p_sender.

Referenced by Swarm::Daemon< _TBackend >::processInputMessage(), and Swarm::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 372 of file Representation.cpp.

372 {
373 p_sendTime = sendTime;
374}

References p_sendTime.

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

+ 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 407 of file Representation.cpp.

407 {
408 p_type = type;
409}

References p_type.

Referenced by Swarm::Daemon< _TBackend >::processInputMessage(), and Swarm::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 400 of file Representation.cpp.

400 {
401 p_vecRecver = vecRecver;
402}

References p_vecRecver.

Member Data Documentation

◆ p_data

Swarm::Data Swarm::Message::p_data
private

Data in the message.

Definition at line 230 of file Representation.h.

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

◆ p_id

size_t Swarm::Message::p_id
private

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

Definition at line 220 of file Representation.h.

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

◆ p_isConfirmationNeeded

bool Swarm::Message::p_isConfirmationNeeded
private

True if the MESSAGE_CONFIRMATION is needed.

Definition at line 222 of file Representation.h.

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

◆ p_sender

PString Swarm::Message::p_sender
private

Address of the Daemon which sends the message.

Definition at line 224 of file Representation.h.

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

◆ p_sendTime

time_t Swarm::Message::p_sendTime
private

Time when the message was sent.

Definition at line 218 of file Representation.h.

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

◆ p_type

MessageType::MessageType Swarm::Message::p_type
private

Type of the message.

Definition at line 228 of file Representation.h.

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

◆ p_vecRecver

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

Addresses of Daemons which receive the message.

Definition at line 226 of file Representation.h.

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


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