FBB::*Clock(3bobcat)
π FBB::*Clock β classes wrapping std::chrono::*_clock facilities π
hiii bestie, welcome to the bobcat manual, section 3 β¨ this page is FBB::*Clock(3bobcat), and it's the whole saga of the clock wrapper classes. buckle up, it's giving very thorough queen energy and honestly? we love her for it.
πΈ 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. no extra work for you, bestie, it's all handled π
β¨ DESCRIPTION β¨
so the C++ std::chrono namespace defines clock-types and all their operations. the bobcat *Clock classes define wrappers around the four standard C++ clock-types, offering interfaces that are way easier to handle than the standard std::chrono clocks. it's the same energy, just more user-friendly π«Ά
FileClockwrapsstd::chrono::file_clock;HighResolutionClockwrapsstd::chrono::high_resolution_clock;SteadyClockwrapsstd::chrono::steady_clock;SystemClockwrapsstd::chrono::system_clock, and is the commonly used clock type. she's the main character, fr fr π
Member names of the bobcat clock-classes don't use underscores. Names consisting of multiple words are camel-cased (like timePoint). iykyk πͺ
Note: the typestd::chrono::file_clock(and thereforeFileClock) is available since the C++-2a standard: specify the--std=c++2a(or more recent) compiler option when usingFileClock. bestie do NOT forget this flag orFileClocksimply will not show up π
π NAMESPACE π
FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. so like, that's where they live π
π¦ INHERITS FROM π¦
FBB::ClockTypes
FBB::ClockBase
FBB::HighSysClock
these are internally used only classes; their facilities are covered in this man-page. so you don't touch them directly, but everything they do is here below π
π TYPEDEFS AND ENUMS π
- The
std::chronotypesnanoseconds,microseconds,milliseconds,seconds,minutesandhoursare also available in the namespaceFBB; β¨
Clock Types:
FBB::FileClockprovides thestd::chrono::file_clockfacilities;FBB::HighResolutionClockprovides thestd::chrono::high_resolution_clockfacilities;FBB::SteadyClockprovides thestd::chrono::steady_clockfacilities;FBB::SystemClockprovides thestd::chrono::system_clockfacilities.
Sub-types:
Duration: each clock type defines the typeDurationasstd::chrono::duration<int64_t, std::nano>;Period: the sub-typeperiodof theDurationtype. In practice its subtypesden(DenType) andnum(NumType) are used;DenType: the denominator type of the ratio type used by the clock type (see also the static memberden);NumType: the numerator type of the ratio type used by the clock type (see also the static membernum);
π CONSTRUCTORS π
okay so the constructors are illustrated for SystemClock but bestie they're also available for the other clock types. it's a whole family thing π
SystemClock(SystemClock::TimePoint = SystemClock::now())β each clock-constructor can be initialized with a time point. By default the clock's time point is initialized by the time point returned by the clock type's staticnowmember;SystemClock(Clock const &otherClock)β each clock type can be initialized with another clock type object (except for aSteadyClocktype object): when constructed they refer to the same points in time.
Copy and move constructors (and assignment operators) are available. so you can copy, move, assign β the whole glow-up β¨
π₯ OVERLOADED OPERATORS π₯
Using DurationType to represent std::chrono::duration<int64_t, Ratio>, where Ratio is a std::ratio type (for clocks Ratio equals nano).
ClockType &operator+=(DurationType const &amount)β addsamountto the current clock'sTimePoint. E.g.,
SystemClock sc;
sc += 1h;
ClockType &operator+=(int secs);β addssecsseconds to the current clock'sTimePoint;ClockType &operator-=(DurationType const &amount);β subtractsamountfrom the current clock'sTimePoint. Not available forSteadyClock; πClockType &operator-=(int secs);β subtractssecsseconds from the current clock'sTimePoint;SteadyClock &operator-=(SteadyClock const &rhs)β only available for classSteadyClock:rhs.elapsed()is subtracted from the current object's time-point. See also the functionssinceandcountSincebelow.std::ostream &operator<<(std::ostream &out, ClockType const &clock)β not available forSteadyClock; clock's (UTC)TimePointis inserted intoout. E.g.,
cout << SystemClock{}; // could insert
// 2025-01-04 08:25:10.035509381
ClockType operator+(Type1 const &lhs, Type2 const &rhs)β not available forSteadyClock. EitherType1orType2must be anFBBClock type (likeSystemClock). The other type can either be anint(representing number of seconds) or aDurationType(likeseconds,hours). A clock object of the same type as the Clock argument is returned, whoseTimePointis initialized to the sum of the argument'sTimePointand the value of the other argument;ClockType operator-(ClockType const &lhs, Type const &rhs)β both argument types can beSteadyClock. AsSteadyClockobjects are used for timing purposes this operator returns aSteadyClockobject whose time specification is equal to the difference of thelhsandrhstime specifications (see also the functionssinceandcountSincebelow). Otherwise thelhsargument must be anFBBClock type (likeSystemClock), andTypecan either be anint(representing number of seconds) or aDurationType(likeseconds,hours), returning a clock object whoseTimePointis initialized to the difference of thelhs'sTimePointand therhsvalue;
π FREE FUNCTIONS π
auto toClock<DestClock>(ClockType const &clock)β returns theDestClock::TimePointcorresponding to theTimePointofclock. It is not available for conversions from or to theSteadyClocktype. E.g.,
FileClock fc;
cout << toClock<SystemClock>(fc) << '\n';
double toDouble<Duration>(ClockType const &src)β returns thedoublevalue corresponding toClockType'sstd::chrono::durationconverted to theDurationstd::chrono::duration. E.g.,
toDouble<hours>(90min); // returns 1.5
Dest toDuration(Src const &src)β returnssrc'sDurationconverted to the (at least as precise)Destduration. E.g.,
toDuration<seconds>(1min).count(); // returns 60
π§ ADDITIONAL STEADYCLOCK FREE FUNCTIONS π§
the SteadyClock type is primarily used for timing purposes. The following two functions are available for SteadyClock objects:
SteadyClock::Duration since(SteadyClock const &time0)β The difference in nanoseconds (Durations) of a localSteadyClockobject andtime0is returned. E.g.,
SteadyClock start;
// do something
cout << "Elapsed time: " << since(start) << '\n';
size_t countSince(SteadyClock const &time0)β Same as the previous function, but the number of nanoseconds are returned as asize_tvalue.
π MEMBER FUNCTIONS π
All of the following members are available for each of bobcat's clock types. no gatekeeping here, every clock gets the whole menu π
long int count()β returnstimePoint's value. The clock types have memberstimePoint(): this member returns the number of nano seconds as an integral value since the beginning of the clock's era. E.g.,
FileClock{}.clock(); // returns, e.g.,
// -4701673791896351066
static long int ClockTypes::count(TimePoint const &timePoint)β returnstimePoint's value. This function can also be used forSteadyClockobjects. E.g.,
ClockTypes::count(SteadyClock::now()); // returns, e.g.,
// 8310904806233
static DenType::den()β returns the denominator of the ratio used by the clocks (=1'000'000'000);Duration elapsed() constβ returns theDurationvalue of the current Clock object (= number of nano-seconds since the beginning of the clock's era). E.g.,
SystemClock{}.elapsed(); // returns, e.g.,
// 1735989478991599467ns
static Duration ClockTypes::elapsed(TimePoint const &timePoint)β returnstimePoint'sDuration. Clock types have memberstimePoint()returning the clock's time point;static TimePoint max()β returns theTimePointof the used clock type corresponding to the clock's maximum (UTC) time. E.g.,
cout << SystemClock::max(); // inserts:
// 2262-04-11 23:47:16...
static TimePoint min()β returns theTimePointof the used clock type corresponding to the clock's minimum (UTC) time;static TimePoint now()β returns theTimePointof the used clock type corresponding to the current (UTC) time. E.g.,
cout << SystemClock::now() << '\n';
static NumType::num()β returns the numerator of the ratio used by the clocks (=1);static Period period()β returns the clock'sPeriod(having membersdenandnum);TimePoint const &timePoint() constβ returns the object'sTimePoint;double toDouble<Dest>() constβ returns thedoublevalue corresponding to the object'sstd::chrono::durationconverted to theDeststd::chrono::duration. E.g.,
SystemClock{}.toDouble<hours>(); // returns, e.g., 482221
static Duration zero()β returns the clock'sDurationrepresenting0nanoseconds;
β¨ ADDITIONAL SYSTEM / HIGHRESOLUTION CLOCK MEMBERS β¨
so both SystemClock and HighResolutionClock have these extra members, and ngl they exist mostly so you can show off the clock's time on screen π
here's the whole squad:
std::time_t timeT() constβ hands you the object'sTimePointconverted into atime_t(peeptime(3)for the lore π)Clock &setTime(std::time_t seconds)β sets theTimePointto whateversecondsyou pass in, then returns the current object, like a lil glow-up β¨Clock const &operator()(char const *putTime, bool localTime = true) constβ this one primes the current object for the next insertion operator, using theputTimespec to configure thestd::put_timemanipulator (cf. C++ Annotations, section 6.4.4 (Theput_timemanipulator)). By default the time shows up in local time. Passfalseas the 2nd argument and you get UTC instead. Once you call this member and then insert the object into astd::ostream, theput_timemanipulator is used just once. Call this member again andput_timegets used over and over, repeat forever, very demure π For example:
SystemClock sc;
cout << // inserts, e.g.,
sc("%Y") << β\nβ << // 2025
sc("%y") << β\nβ << // 25
sc << β\nβ; // 2025-01-04 14:18:47...
πΈ EXAMPLE πΈ
ok bestie here's the whole thing in action, no cap:
#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 π
these are the headers, the whole friend group fr fr:
bobcat/fileclock, - the FileClock class interfacebobcat/highresulutionclock- the HighResolutionClock class interfacebobcat/steadyclock- the SteadyClock class interfacebobcat/systemclock- the SystemClock class interface
heads up bestie: yes, bobcat/highresulutionclock really is spelled like that in the original β don't blame me, blame the header π iykyk, just copy it exactly as written!
π SEE ALSO π
π BUGS π
None Reported.
(iconic behaviour honestly, not a single bug in the group chat π«Ά)
π BOBCAT PROJECT FILES π
- https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
libbobcat6: debian package containing the shared library, changelog and copyright note;libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;
π 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).
and that's the whole page bestie, you ate that π
the source and version for all of this loveliness is libbobcat-dev_6.15.01, dated 2005-2026, and it's the FBB::*Clock(3bobcat) manual page β go forth and clockify everything, periodt π¦β¨π
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms