RE: Boost libraries and ROOT

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Wed, 16 Apr 2008 12:31:28 -0500


Hi,

Just a general comment :)

> You could modify all the headers and source files for
> the Boost libraries you want to use to include the relevant CINT magic
> (ClassDef/ClassImp and LinkDef.h files) and generate all the
> dictionaries, and then load them up.

ClassDef/ClassImp are no longer required to be able to store your object in ROOT file. You _just_ need a dictionary for the class your want to persist (and all the type of their data members).

Now the hard part is that the CINT parser fails on the boost headers. Your best option is usually to hide the boost header file from CINT #ifndef __CINT__

    #include <boost/tuple/tuple.hpp>
    #include <boost/tuple/tuple_comparison.hpp>
    #include <boost/tuple/tuple_io.hpp>

#else
... place here revelant forward declaration .... #endif

and possibly

    class OptimalCuts{        

    public :
#ifndef __CINT__

        boost::tuples::tuple<int, double>T; #endif

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of Kevin Lynch
Sent: Wednesday, April 16, 2008 10:52 AM To: aalvesju_at_cern.ch; augalves_at_cbpf.br
Cc: ROOT Talk
Subject: Re: [ROOT] Boost libraries and ROOT

Antonio Augusto Alves Junior wrote:
> Hello all,
>
> Please, can someone to give some example of usage of the Boost Libraries
> with ROOT?
>
> regards
> Augusto
>

It's not clear what you are asking for. If you want to use Boost libraries and the Root libraries in compiled code, you won't have any issues. I do this all the time ... mostly I use stuff that ended up in TR1 (smart_ptr, tuple, bind, function, etc), but I've also been known to use multi_index, numeric_cast, random, and a few others. It all works just fine.

If you want to use some specific Boost library as interpreted code, then you will likely be in for a long, tough slog to get it working. Boost makes EXTREMELY heavy use of advanced template features, as well as lots of config headers and #ifdef'd workarounds for various compilers and STL implementations. You could modify all the headers and source files for the Boost libraries you want to use to include the relevant CINT magic (ClassDef/ClassImp and LinkDef.h files) and generate all the dictionaries, and then load them up. You'll have to do all this work if you want to persist Boost objects to TTrees/TFiles, since you need the dictionary in this case.

Personally, I've never bothered with all that ... if the project is complicated enough that I need Boost, I'm going the compiled route anyway. And I just accept that I'm too lazy to put any Boost objects in TTrees or TFiles :-)

Finally, a few years back, someone posted a message to roottalk about efforts to Rootify the Boost smart pointers .... I think it was called "ROOST". I haven't heard anything more since then, but perhaps there's been some more progress.

-- 
----------------------------------------------------------------------------
---
Kevin Lynch				voice:	(617) 353-6025
Physics Department			Fax: (617) 353-9393
Boston University			office:	 PRB-361
590 Commonwealth Ave.			e-mail:	 krlynch_at_bu.edu
Boston, MA 02215 USA			http://budoe.bu.edu/~krlynch
----------------------------------------------------------------------------
---
Received on Wed Apr 16 2008 - 19:35:03 CEST

This archive was generated by hypermail 2.2.0 : Wed Apr 16 2008 - 23:50:01 CEST