FBB::*Clock(3bobcat)

Classes wrapping std::*_clock
(libbobcat-dev_6.07.00)

2005-2025

NAME

FBB::*Clock - classes wrapping std::chrono::*_clock facilities

SYNOPSIS

#include <bobcat/fileclock>
#include <bobcat/highresolutionclock>
#include <bobcat/steadyclock>
#include <bobcat/systemclock>

Each of these files also includes the std::chrono header file.

DESCRIPTION

The C++ std::chrono namespace defines clock-types and their operations. The bobcat *Clock classes define wrappers around the four standard C++ clock-types offering interfaces which are easier to handle than the standard std::chrono clocks.

, and is the commonly used clock type.

Member names of the bobcat clock-classes don't use underscores. Names consisting of multiple words are `camel-cased' (like timePoint).

Note:

The type std::chrono::file_clock (and therefore FileClock) is available since the C++-2a standard: specify the --std=c++2a (or more recent) compiler option when using FileClock.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

FBB::ClockTypes
FBB::ClockBase
FBB::HighSysClock
these are internally used only classes; their facilities are covered in this man-page.

TYPEDEFS AND ENUMS

Clock Types:

Sub-types:

CONSTRUCTORS

The constructors are illustrated for SystemClock but are also available for the other clock types.

Copy and move constructors (and assignment operators) are available.

OVERLOADED OPERATORS

Using DurationType to represent std::chrono::duration<int64_t, Ratio>, where Ratio is a std::ratio type (for clocks Ratio equals nano).

FREE FUNCTIONS

ADDITIONAL STEADYCLOCK FREE FUNCTIONS

The SteadyClock type is primarily used for timing purposes. The following two functions are available for SteadyClock objects:

MEMBER FUNCTIONS

All of the following members are available for each of bobcat's clock types:

ADDITIONAL SYSTEM / HIGHRESOLUTION CLOCK MEMBERS

Primarily for displaying the clock's time the SystemClock and HighResolutionClock classes support these members:

EXAMPLE

#include <iostream>
#include <string>
#include <thread>

#include <bobcat/fileclock> 
#include <bobcat/highresolutionclock> 
#include <bobcat/steadyclock> 
#include <bobcat/systemclock> 

using namespace std;
using namespace FBB;

int main()
{
    SystemClock sysNow{  };
    cout << "system clock at " << sysNow    << "\n"
            "elapsed: " << sysNow.elapsed() << "\n\n";

                                    // same timespec, elapsed ns.
    FileClock fileNow{ sysNow };    // is clock-specific
    cout << "file clock at " << fileNow << "\n"
            "elapsed: " << fileNow.elapsed() << "\n\n";

    SystemClock sysNow2{ fileNow };
    cout << "system clock at " << sysNow2 << "\n"
            "elapsed: " << sysNow2.elapsed() << "\n\n";

    cout << sysNow2("%Y %b %d, %H:%M:%S")           << "\n"
            "\n"
            "minimum time: " << sysNow2.min()       << "\n"
            "maximum time: " << SystemClock::max()  << "\n\n";

    // conversion to less precise time specification:
    cout << "100 minutes is " << toDouble<hours>(100min) << " hours\n\n";

    HighResolutionClock hrc{ fileNow };
    cout << "high resolution clock at " << hrc << "\n\n";

    SteadyClock sc0;            // computing 'since' itself takes several
    auto passed = since(sc0);   // (variable) hundred nano seconds
    cout << "sc0 since: " << passed << '\n';

    SteadyClock sc;

    this_thread::sleep_for(1s);

    cout << 
        "ELAPSED:  " << since(sc) << '\n' <<
        "(small delay...)\n"
        "as count: " << countSince(sc) << "\n\n";
}



FILES

bobcat/fileclock, - the FileClock class interface
bobcat/highresulutionclock - the HighResolutionClock class interface
bobcat/steadyclock - the SteadyClock class interface
bobcat/systemclock - the SystemClock class interface

SEE ALSO

bobcat(7), time(3),

BUGS

None Reported.

BOBCAT PROJECT FILES

Debian Bobcat project files:

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).