Use boost classes with TTree


By trying to solve the overflow problem of TTimeStamp (The use of time_t implies that overflow conditions occurs somewhere around Jan 18, 19:14:07, 2038), I started to use Boost.Date_Time.
My new date class works fine with root in general, but when I try to store it in a branch of a tree, I get a lot of warnings looking like this:

Since a lot of those boost types come from metaprogramming, I can’t add all of them to LinkDef.h. What would be the best way to make this library compatible?


I believe that creating a dictionary for the classes the instances of which are persistified is a requirement at the moment.



After adding some of the classes, when I load my shared library in the interpreter (I am using root 6), I get the following error:

[quote]MyDict dictionary forward declarations’ payload:9:75: error: no type named ‘int64_t’ in namespace 'boost’
namespace boost{namespace date_time{template <class base_duration, boost::int64_t frac_of_second> class attribute((annotate("$clingAutoload$Mydictheader.h"))) subsecond_duration;
Warning in TInterpreter::TCling::RegisterModule: Problems in compiling forward declarations for module [/quote]

It is just the first few lines. The actual error is extremely long.

It looks like boost::int64_t cannot be forward declared, does anyone have an idea?

As an alternative, you could create a branch with a year/I:month/b:day/b leaves (add hour:min:sec if you need that). The advantage is that this is a very simple data structure (no need for dictionaries) and sometimes you want to separate the timestamp into human readable dates anyway.

Another alternative: use std::chrono::time_point::time_since_epoch (and make a duration_caststd::chrono::seconds or use whatever resolution you need) and store the resulting value for example as a /L leaf.

On the other hand, for me:

root [0] sizeof(time_t) (unsigned long) 8 root [1] sizeof(TTimeStamp().GetTimeSpec().tv_sec) (unsigned long) 8

This is in contract to where it says that time_t is by default 32 bit. So maybe switch to somewhre with time_t = 64bit and do not need to care about this at all?