ROSE 0.11.145.147
Public Member Functions | List of all members
Sawyer::Message::Mesg Class Reference

Description

A single message.

A message consists of a string and can be in a partial, completed, or canceled state. More text can be added to a message while it is in the partial state, but once the message is marked as completed or canceled the text becomes immutable. Messages also have properties, which are fed into the plumbing lattice and adjusted as they traverse to the final destinations during a process called "baking".

Thread safety: This object uses global state, but is otherwise not thread-safe except where noted.

Definition at line 513 of file Message.h.

#include <Sawyer/Message.h>

Public Member Functions

 Mesg ()
 Creates a new, partial message that is empty.
 
 Mesg (const std::string &facilityName, Importance imp)
 Creates a new, partial message that is empty.
 
 Mesg (const MesgProps &props)
 Creates a new, partial message that is empty.
 
 Mesg (const std::string &mesg)
 Creates a new, completed message with the specified text.
 
 Mesg (const std::string &facilityName, Importance imp, const std::string &mesg)
 Creates a new, completed message with the specified text.
 
 Mesg (const MesgProps &props, const std::string &mesg)
 Creates a new, completed message with the specified text.
 
unsigned id () const
 Return unique message ID.
 
const std::string & text () const
 Return the message text.
 
bool isComplete () const
 Returns true if the message has entered the completed state.
 
bool isCanceled () const
 Returns true if the message has entered the canceled state.
 
bool isEmpty () const
 Returns true if the message has no text.
 
bool hasText () const
 Returns true if the message has text other than white space.
 
void complete ()
 Cause the message to enter the completed state.
 
void cancel ()
 Cause the message to enter the canceled state.
 
void post (const BakedDestinations &) const
 Send a message to its final destinations.
 
const MesgPropsproperties () const
 Returns a reference to message properties.
 
MesgPropsproperties ()
 Returns a reference to message properties.
 
void insert (const std::string &)
 Append additional text to the end of the message.
 
void insert (char)
 Append additional text to the end of the message.
 

Constructor & Destructor Documentation

◆ Mesg() [1/6]

Sawyer::Message::Mesg::Mesg ( )
inline

Creates a new, partial message that is empty.

Definition at line 525 of file Message.h.

◆ Mesg() [2/6]

Sawyer::Message::Mesg::Mesg ( const std::string &  facilityName,
Importance  imp 
)
inline

Creates a new, partial message that is empty.

Sets the facility name and importance properties as specified.

Definition at line 529 of file Message.h.

References Sawyer::Message::MesgProps::facilityName, and Sawyer::Message::MesgProps::importance.

◆ Mesg() [3/6]

Sawyer::Message::Mesg::Mesg ( const MesgProps props)
inlineexplicit

Creates a new, partial message that is empty.

Initializes message properties as specified.

Definition at line 536 of file Message.h.

◆ Mesg() [4/6]

Sawyer::Message::Mesg::Mesg ( const std::string &  mesg)
inlineexplicit

Creates a new, completed message with the specified text.

Definition at line 540 of file Message.h.

◆ Mesg() [5/6]

Sawyer::Message::Mesg::Mesg ( const std::string &  facilityName,
Importance  imp,
const std::string &  mesg 
)
inline

Creates a new, completed message with the specified text.

Also sets the facility name and importance properties as specified.

Definition at line 545 of file Message.h.

References Sawyer::Message::MesgProps::facilityName, and Sawyer::Message::MesgProps::importance.

◆ Mesg() [6/6]

Sawyer::Message::Mesg::Mesg ( const MesgProps props,
const std::string &  mesg 
)
inline

Creates a new, completed message with the specified text.

Also sets the message properties as specified.

Definition at line 552 of file Message.h.

Member Function Documentation

◆ id()

unsigned Sawyer::Message::Mesg::id ( ) const
inline

Return unique message ID.

Each message has an identification number that is unique within a process.

Definition at line 556 of file Message.h.

◆ text()

const std::string & Sawyer::Message::Mesg::text ( ) const
inline

Return the message text.

Definition at line 559 of file Message.h.

◆ isComplete()

bool Sawyer::Message::Mesg::isComplete ( ) const
inline

Returns true if the message has entered the completed state.

Once a message is completed its text cannot be changed.

Definition at line 562 of file Message.h.

◆ isCanceled()

bool Sawyer::Message::Mesg::isCanceled ( ) const
inline

Returns true if the message has entered the canceled state.

Messages typically only enter this state when they are being destroyed.

Definition at line 566 of file Message.h.

◆ isEmpty()

bool Sawyer::Message::Mesg::isEmpty ( ) const
inline

Returns true if the message has no text.

This is similar, but not identical to the the inverse of the hasText method.

Definition at line 570 of file Message.h.

◆ hasText()

bool Sawyer::Message::Mesg::hasText ( ) const

Returns true if the message has text other than white space.

This is similar, but not identical to the inverse of the isEmpty method.

◆ properties() [1/2]

const MesgProps & Sawyer::Message::Mesg::properties ( ) const
inline

Returns a reference to message properties.

Once a message's properties are "baked" by sending them through the plumbing lattice, changing the message properties has no effect on the text that is emitted by the message sinks. A stream typically bakes the message when the first text is inserted.

Definition at line 580 of file Message.h.

◆ properties() [2/2]

MesgProps & Sawyer::Message::Mesg::properties ( )
inline

Returns a reference to message properties.

Once a message's properties are "baked" by sending them through the plumbing lattice, changing the message properties has no effect on the text that is emitted by the message sinks. A stream typically bakes the message when the first text is inserted.

Definition at line 581 of file Message.h.

◆ complete()

void Sawyer::Message::Mesg::complete ( )
inline

Cause the message to enter the completed state.

Once a message enters this state its text cannot be modified.

Definition at line 585 of file Message.h.

◆ cancel()

void Sawyer::Message::Mesg::cancel ( )
inline

Cause the message to enter the canceled state.

This typically happens automatically when a message is being destroyed. Once a message enters this state its text cannot be modified.

Definition at line 589 of file Message.h.

◆ insert() [1/2]

void Sawyer::Message::Mesg::insert ( const std::string &  )

Append additional text to the end of the message.

If the message is in the completed or canceled state then an std::runtime_error is thrown.

◆ insert() [2/2]

void Sawyer::Message::Mesg::insert ( char  )

Append additional text to the end of the message.

If the message is in the completed or canceled state then an std::runtime_error is thrown.


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