LinkDef and chrono::time_point member


I am trying to write my own class containg a chrono::time_point to a tree. The class contains only one data member, a std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> variable. How do I put this in the LinkDef.h?


class MyTimepoint : public TObject { 
    std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> tp_;
    MyTimepoint() = default;
    // getters/setters
    ClassDef(MyTimepoint, 1)


#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclasses;

// #pragma link C++ class std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>-!;
#pragma link C++ class MyTimepoint+;

This compiles fine but when writing to a tree, I get this warning:

Warning in <TStreamerInfo::Build>: MyTimepoint: chrono::time_point<chrono::system_clock,chrono::duration<long,ratio<1,1000000000> > > has no streamer or dictionary, data member "tp_" will not be saved
Warning in <TStreamerInfo::Build>: chrono::time_point<chrono::system_clock,chrono::duration<long,ratio<1,1000000000> > >: chrono::duration<long,ratio<1,1000000000> > has no streamer or dictionary, data member "__d" will not be saved

It seems to work fine though. I can write time_points to a tree and read them back. But getting this warning every time is not good. So probably something is wrong here…

I’ve tried to add the chrono::time_point to the LinkDef.h file (see commented line) but then it doen’t compile any longer:

Error: Class chrono::time_point<chrono::system_clock,chrono::duration<long,ratio<1,1000000000> > > has been selected but currently the support for its I/O is not yet available. Note that chrono::time_point<chrono::system_clock,chrono::duration<long,ratio<1,1000000000> > >, even if not selected, will be available for interpreted code.

Does “support for its I/O is not yet available” mean is isn’t currently supported in ROOT? What exactly do I need to do to support time_point members?

(I know there is TTimeStamp but I prefer the chrono interface, and oviously I want to template the class to allow for different time_point precisions)

Hi Wolf,

ROOT is not yet able to support IO of this particular STL class. The reason is that behind the scenes its layout could be implementation dependent.
This is the first time we get a report about the rootcling error you reported. Is this blocking for you? Would you like ROOT to support IO of that kind of objects?


Hi Danilo,

ok, I see. It would still be nice to be able to store a standard chrono time type in a tree, if somehow possible - but of course it should be implementation independent… So if that’s not possible, no problem.

So this is NOT blocking for me. I can instead store a Long64_t (or some other type [*]) and hide away all public functions returning a chrono::time_point with #ifndef __ROOTCLING__. That is easier said than done since I also want to be able to convert to SomeDateOnlyType and SomeDateOnlyType can of course convert to some time_point.
That way writing a tree does not produce any warnings, but when reading and accessing the other date type I get the warning Warning in <TStreamerInfo::Build>: chrono::time_point<chrono::system_clock,chrono::duration<int,ratio<86400,1> > >: chrono::duration<int,ratio<86400,1> > has no streamer or dictionary, data member "__d" will not be saved.
Is there a way to make ROOT not print this warning? I tried with -! in the Linkdef, as shown above, but that results in an error. (maybe -! is wrong, I am not at all an expert on IO, I am usually storing simple pod types only)

The whole reason behind this question is that I’d like to simplify/unify my date and time types. Most of it is based on the chrono types anyway, so I thought about storing them directly.

[*] ROOT types TTimeStamp and TDatime also come into mind. Both have different member functions, but neither has all the functions that I need. So I started to create my own date and time classes, essentially only wrapping a std::chrono::time_point or a date::year_month_day (from H Hinnant’s date.h) and providing a lot of extra getter functions.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.