Re: [ROOT] Sending mixed templated/non-templated objects through ROOT I/O

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Fri Oct 13 2000 - 19:25:52 MEST


 You may provide a custom Registry::Streamer method for you class
 That defines how to stream you objects from your container into ROOT buffer and how to recreate
 your container back.

You can use
http://root.cern.ch/root/htmldoc/src/TCollection.cxx.html#TCollection:Streamer

as example.
  Hope this helps.
                 Valery

----- Original Message -----
From: Brett Viren <bv@bnl.gov>
To: <roottalk@pcroot.cern.ch>
Sent: 13 октября 2000 г. 13:14
Subject: [ROOT] Sending mixed templated/non-templated objects through ROOT I/O

> Hi.
>
> I have a heterogeneous container which maps (using an STL map) STL
> strings to arbitrarily typed values.  I want to be able to send this
> container through ROOT I/O.  I have learned how to send simple
> templated objects through ROOT I/O, but I can't seem to figure out how
> to do it in the case of my container.
>
> This container is implimented in 3 classes.  The container is called
> Registry and it holds values of type (pointer to) RegistryItem.  Each
> type T of value is stored in a templated subclass of RegistryItem
> called RegistryItemXxx<T>.  These are outlined below:
>
> // The container
> class Registry
> {
> public:
>         // non-templated ctor/dtor
>
>         // templated accessors
>         template<class T>    T GetVal(string key);
>         template<class T> void SetVal(string key, T value);
> private:
>         map<string, RegistryItem*> fMap;
> };
>
>
> // The generic class which the container holds
> class RegistryItem
> {
> public:
>         // non-templated ctor/dtor
>         // that's it
> };
>
> // The templated class holding a specific typed value
> template<class T>
> class RegistryItemXxx : public RegistryItem
> {
> public:
>         // templated ctor/dtor
>
>         // templated accessors
>           T* Get(void);
>         void Set(T* data);
> private:
>         T* fData;
> };
>
>
> The Registry::GetVal() method uses dynamic_cast<RegistryItemXxx<T>*>()
> to turn a generic RegistryItem into the correctly typed version.  This
> provides type safe access.
>
>
> Can any one give me some guidance on how to proceed to get this
> container to go through ROOT I/O ?
>
> Thanks,
> -Brett.
>



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:35 MET