CBMC
timestampert Class Reference

Timestamp class hierarchy. More...

#include <timestamper.h>

+ Inheritance diagram for timestampert:

Public Types

enum class  clockt { NONE , MONOTONIC , WALL_CLOCK }
 Derived types of timestampert. More...
 

Public Member Functions

virtual ~timestampert ()=default
 
virtual std::string stamp () const
 Default timestamp: the empty string. More...
 

Static Public Member Functions

static std::unique_ptr< const timestampertmake (clockt clock_type)
 Factory method to build timestampert subclasses. More...
 

Detailed Description

Timestamp class hierarchy.

This class hierarchy supports generation of timestamps in various textual formats. The timestamps returned by instances of this class are empty; more meaningful timestamps are returned by derived classes.

Instances of this class can be instantiated to emit empty timestamps, in case the user did not specify --timestamp on the command line. The intended use of this class hierarchy is to create a pointer or std::unique_ptr called time to a timestampert, and to initialize time with either an actual timestampert object or one of the derived classes based on whether the user has asked for timestamps to be emitted. Clients can thus unconditionally call time->stamp() and prepend that string to any logging messages; if the user didn't ask for timestamps, then the object pointed to by time will be a timestampert and thus timestampert::stamp() will return only an empty string. Derived classes emit an actual timestamp followed by a space, so no conditional checking is needed by the client.

Definition at line 41 of file timestamper.h.

Member Enumeration Documentation

◆ clockt

enum timestampert::clockt
strong

Derived types of timestampert.

Enumerator
NONE 

timestampert

MONOTONIC 

monotonic_timestampert

WALL_CLOCK 

wall_clock_timestampert

Definition at line 45 of file timestamper.h.

Constructor & Destructor Documentation

◆ ~timestampert()

virtual timestampert::~timestampert ( )
virtualdefault

Member Function Documentation

◆ make()

std::unique_ptr< const timestampert > timestampert::make ( timestampert::clockt  clock_type)
static

Factory method to build timestampert subclasses.

Definition at line 19 of file timestamper.cpp.

◆ stamp()

virtual std::string timestampert::stamp ( ) const
inlinevirtual

Default timestamp: the empty string.

Reimplemented in wall_clock_timestampert, and monotonic_timestampert.

Definition at line 57 of file timestamper.h.


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