Taskolib  1.3.3
Public Types | Public Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
task::Message Class Reference

Detailed Description

A message carrying some text, a timestamp, and a type, to be transported with a message queue between threads.

#include <Message.h>

Public Types

enum class  Type {
  output , sequence_started , sequence_stopped , sequence_stopped_with_error ,
  step_started , step_stopped , step_stopped_with_error , undefined
}
 The type of this message. More...
 

Public Member Functions

 Message ()=default
 Construct an empty message. More...
 
 Message (Type type, std::string text, TimePoint timestamp, OptionalStepIndex index)
 Construct an initialized message from the given parameters. More...
 
OptionalStepIndex get_index () const
 Return the associated optional step index. More...
 
const std::string & get_text () const
 Return the message text. More...
 
Type get_type () const noexcept
 Return the message type. More...
 
TimePoint get_timestamp () const
 Return the timestamp. More...
 
Messageset_index (OptionalStepIndex index)
 Set the associated index. More...
 
Messageset_text (const std::string &text)
 Set the message text. More...
 
Messageset_timestamp (TimePoint timestamp)
 Set the timestamp. More...
 
Messageset_type (Type type) noexcept
 Set the message type. More...
 

Private Attributes

std::string text_
 
TimePoint timestamp_ {}
 
Type type_ { Type::output }
 
OptionalStepIndex index_
 

Static Private Attributes

static constexpr std::array< char const *, static_cast< int >Type::undefined)+1 > type_description_
 

Friends

std::ostream & operator<< (std::ostream &stream, Type const &t)
 
std::ostream & operator<< (std::ostream &stream, Message const &mess)
 

Member Enumeration Documentation

◆ Type

enum task::Message::Type
strong

The type of this message.

Enumerator
output 

a message string that was output by a step via print()

sequence_started 

a sequence has been started

sequence_stopped 

a sequence has stopped regularly

sequence_stopped_with_error 

a sequence has been stopped because of an error

step_started 

a step inside a sequence has been started

step_stopped 

a step inside a sequence has stopped regularly

step_stopped_with_error 

a step inside a sequence has been stopped because of an error

undefined 

marker for last type

Constructor & Destructor Documentation

◆ Message() [1/2]

task::Message::Message ( )
default

Construct an empty message.

◆ Message() [2/2]

task::Message::Message ( Type  type,
std::string  text,
TimePoint  timestamp,
OptionalStepIndex  index 
)
inline

Construct an initialized message from the given parameters.

Member Function Documentation

◆ get_index()

OptionalStepIndex task::Message::get_index ( ) const
inline

Return the associated optional step index.

References index_.

Referenced by task::Executor::update().

◆ get_text()

const std::string& task::Message::get_text ( ) const
inline

Return the message text.

This function returns a reference to a member variable. Be aware of the associated lifetime implications!

References text_.

Referenced by task::default_message_callback(), and task::Executor::update().

◆ get_timestamp()

TimePoint task::Message::get_timestamp ( ) const
inline

Return the timestamp.

References timestamp_.

Referenced by task::Executor::update().

◆ get_type()

Type task::Message::get_type ( ) const
inlinenoexcept

Return the message type.

References type_.

Referenced by task::default_message_callback(), and task::Executor::update().

◆ set_index()

Message& task::Message::set_index ( OptionalStepIndex  index)
inline

Set the associated index.

References index_.

◆ set_text()

Message& task::Message::set_text ( const std::string &  text)
inline

Set the message text.

References text_.

◆ set_timestamp()

Message& task::Message::set_timestamp ( TimePoint  timestamp)
inline

Set the timestamp.

References timestamp_.

◆ set_type()

Message& task::Message::set_type ( Type  type)
inlinenoexcept

Set the message type.

References type_.

Friends And Related Function Documentation

◆ operator<< [1/2]

std::ostream& operator<< ( std::ostream &  stream,
Message const &  mess 
)
friend

◆ operator<< [2/2]

std::ostream& operator<< ( std::ostream &  stream,
Type const &  t 
)
friend

Member Data Documentation

◆ index_

OptionalStepIndex task::Message::index_
private

Referenced by get_index(), and set_index().

◆ text_

std::string task::Message::text_
private

Referenced by get_text(), and set_text().

◆ timestamp_

TimePoint task::Message::timestamp_ {}
private

Referenced by get_timestamp(), and set_timestamp().

◆ type_

Type task::Message::type_ { Type::output }
private

Referenced by get_type(), and set_type().

◆ type_description_

constexpr std::array<char const*, static_cast<int>Type::undefined) + 1> task::Message::type_description_
staticconstexprprivate
Initial value:
=
{
"output",
"sequence_started",
"sequence_stopped",
"sequence_stopped_with_error",
"step_started",
"step_stopped",
"step_stopped_with_error",
"undefined"
}

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