The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::log::Destination Class Referenceabstract

Generic Logging destination stream interface which writes sparta::log::Message structures to some output [file]stream. Subclasses will implement stream I/O based on construction arguments. More...

#include <Destination.hpp>

Inheritance diagram for sparta::log::Destination:

Public Member Functions

 Destination (const Destination &)=delete
 
Destinationoperator= (const Destination &)=delete
 
 Destination (const Destination &&rhp)
 
 Destination ()
 Default constructor.
 
template<std::size_t N>
bool compare (const char(&arg)[N]) const
 Comparison of destination for const char[]. Uses std::string comparison.
 
bool compare (const char *&arg) const
 Comparison of destination for const char[]. Uses std::string comparison.
 
bool compare (const std::string &arg) const
 Comparison of destination for std::string.
 
bool compare (const std::ostream &arg) const
 Handle Destination::operator== on ostreams.
 
template<typename T >
bool compare (const T &) const
 Operator= for for other unknown types.
 
virtual bool compareStrings (const std::string &) const
 Returns true if the destination behind this interface was constructed with the string s.
 
virtual bool compareOstreams (const std::ostream &) const
 Returns true if the destination behind this interface was constructed with the ostream o.
 
virtual std::string stringize (bool pretty=false) const =0
 Create a string representation of this Destination.
 
void write (const sparta::log::Message &msg)
 
uint64_t getNumMessagesReceived () const
 Get the total number of messages logged through this destination.
 
uint64_t getNumMessagesWritten () const
 Gets the total number of messages received by this destination and then written to the actual output stream.
 
uint64_t getNumMessageDuplicates () const
 Gets the total number of times that a message has arrived at this destination after already having been written to the output stream.
 

Detailed Description

Generic Logging destination stream interface which writes sparta::log::Message structures to some output [file]stream. Subclasses will implement stream I/O based on construction arguments.

Destinations are uniquely identified by their construction argument (i.e. string or ostream reference).

Destinations are managed by sparta::log::DestinationManager to ensure that there are usually no duplicates.

This Interface constains some compare and compareX methods which are used to compare the Destinations by string or ostream. Supporting destinations identified by a different attribute will require the appropriate comparison support to this class. In general, this should be 1 compare template specialization and a virtual compareTYPE function which returns false by default and is overloaded in a DestinationInstance specialization which actually compares.

Noncopyable and non-assignable

Definition at line 53 of file Destination.hpp.

Constructor & Destructor Documentation

◆ Destination() [1/2]

sparta::log::Destination::Destination ( const Destination &&  rhp)
inline

Move constructor

Note
Mutex is not copied or moved.

Definition at line 62 of file Destination.hpp.

◆ Destination() [2/2]

sparta::log::Destination::Destination ( )
inline

Default constructor.

Definition at line 70 of file Destination.hpp.

◆ ~Destination()

virtual sparta::log::Destination::~Destination ( )
inlinevirtual

Definition at line 76 of file Destination.hpp.

Member Function Documentation

◆ compare() [1/5]

bool sparta::log::Destination::compare ( const char *&  arg) const
inline

Comparison of destination for const char[]. Uses std::string comparison.

Definition at line 93 of file Destination.hpp.

Here is the call graph for this function:

◆ compare() [2/5]

template<std::size_t N>
bool sparta::log::Destination::compare ( const char(&)  arg[N]) const
inline

Comparison of destination for const char[]. Uses std::string comparison.

Definition at line 84 of file Destination.hpp.

Here is the call graph for this function:

◆ compare() [3/5]

bool sparta::log::Destination::compare ( const std::ostream &  arg) const
inline

Handle Destination::operator== on ostreams.

Definition at line 109 of file Destination.hpp.

Here is the call graph for this function:

◆ compare() [4/5]

bool sparta::log::Destination::compare ( const std::string &  arg) const
inline

Comparison of destination for std::string.

Definition at line 101 of file Destination.hpp.

Here is the call graph for this function:

◆ compare() [5/5]

template<typename T >
bool sparta::log::Destination::compare ( const T &  ) const
inline

Operator= for for other unknown types.

Note
Support for additional types of destinations will require supporting operator== for those types
This is specialized for other destination types.

Definition at line 120 of file Destination.hpp.

Here is the call graph for this function:

◆ compareOstreams()

virtual bool sparta::log::Destination::compareOstreams ( const std::ostream &  ) const
inlinevirtual

Returns true if the destination behind this interface was constructed with the ostream o.

Reimplemented in sparta::log::DestinationInstance< std::ostream >.

Definition at line 139 of file Destination.hpp.

◆ compareStrings()

virtual bool sparta::log::Destination::compareStrings ( const std::string &  ) const
inlinevirtual

Returns true if the destination behind this interface was constructed with the string s.

Reimplemented in sparta::log::DestinationInstance< std::string >.

Definition at line 131 of file Destination.hpp.

◆ getNumMessageDuplicates()

uint64_t sparta::log::Destination::getNumMessageDuplicates ( ) const
inline

Gets the total number of times that a message has arrived at this destination after already having been written to the output stream.

This is expected and can occur when multiple taps are on the propagation path of a log message. The duplicates will not be written to the same destination. Note that multiple destinations could refer to the same output file if they were constructed with different but equivalent paths or constructed with different ofstream instances with handles to the same file.

Definition at line 198 of file Destination.hpp.

◆ getNumMessagesReceived()

uint64_t sparta::log::Destination::getNumMessagesReceived ( ) const
inline

Get the total number of messages logged through this destination.

Definition at line 178 of file Destination.hpp.

◆ getNumMessagesWritten()

uint64_t sparta::log::Destination::getNumMessagesWritten ( ) const
inline

Gets the total number of messages received by this destination and then written to the actual output stream.

Definition at line 184 of file Destination.hpp.

◆ stringize()

virtual std::string sparta::log::Destination::stringize ( bool  pretty = false) const
pure virtual

Create a string representation of this Destination.

Parameters
prettyPrint a more verbose, multi-line representaiton (if available).
Returns
string representation of this node "<" <location> ">"

Subclasses should override this with representations appropriate for their type.

Implemented in sparta::log::DestinationInstance< std::ostream >, and sparta::log::DestinationInstance< std::string >.

◆ write()

void sparta::log::Destination::write ( const sparta::log::Message msg)
inline
Note
This method IS thread-safe

Definition at line 155 of file Destination.hpp.


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