Hi Silvie,
You should move to the production version 3.00/06. The example
of STL map will work correctly.
Here are the read & write parts of Streamer generated by 3.00/06
read
====
{
timepattern_.clear();
int R__i, R__n;
R__b >> R__n;
for (R__i = 0; R__i < R__n; R__i++) {
int R__t;
R__b >> R__t;
int R__t2;
R__b >> R__t2;
timepattern_.insert(make_pair(R__t,R__t2));
}
}
write
=====
{
R__b << int(timepattern_.size());
map<int,int>::iterator R__k;
for (R__k = timepattern_.begin(); R__k != timepattern_.end(); ++R__k) {
R__b << (*R__k).first;
R__b << (*R__k).second;
}
}
Version 3.00 has still some problems with STL maps when the first argument
is not a basic type or pointer to object. These problems will be solved
in the released version of 3.01
Rene Brun
Sylvie Dagoret-Campagne wrote:
>
> Hi,
>
> Congratulation for the Clear Root User-Guide I am reading with much
> attention but I have some questions.
>
> I am using the root version 2.24/04.
>
> Here is my class :
> -----------------
>
> class SDPhotoElecCount_ROOT : public TObject
> {
> public:
> SDPhotoElecCount_ROOT(){photoelectrons_=new TMap; total_=0; Slot0_=0;}
> SDPhotoElecCount_ROOT(const SDPhotoElecCount_ROOT&);
> ~SDPhotoElecCount_ROOT(){if(photoelectrons_!=NULL) delete photoelectrons_;}
> SDPhotoElecCount_ROOT(int slot0):Slot0_(slot0){photoelectrons_=new TMap; total_=0;}
> int Slot0_; // first timebin corresponding to the arrival of the wave front
> int total_;
> vector<int> vec_;
> list<int> li_;
> deque<int> dq_;
> map<int,int> timepattern_;
> TMap* photoelectrons_;
> void Print(ostream& o) const;
> void addphotoelectron(int timslot);
>
> ClassDef(SDPhotoElecCount_ROOT,1)
> };
>
> Here is the Streamer generated :
> --------------------------------
>
> void SDPhotoElecCount_ROOT::Streamer(TBuffer &R__b)
> {
> // Stream an object of class SDPhotoElecCount_ROOT.
>
> if (R__b.IsReading()) {
> Version_t R__v = R__b.ReadVersion(); if (R__v) { }
> TObject::Streamer(R__b);
> R__b >> Slot0_;
> R__b >> total_;
> {
> int R__i, R__n;
> int R__t;
> R__b >> R__n;
> for (R__i = 0; R__i < R__n; R__i++) {
> R__b >> R__t;
> vec_.push_back(R__t);
> }
> }
> {
> int R__i, R__n;
> int R__t;
> R__b >> R__n;
> for (R__i = 0; R__i < R__n; R__i++) {
> R__b >> R__t;
> li_.push_back(R__t);
> }
> }
> {
> int R__i, R__n;
> int R__t;
> R__b >> R__n;
> for (R__i = 0; R__i < R__n; R__i++) {
> R__b >> R__t;
> dq_.push_back(R__t);
> }
> }
> R__b >> photoelectrons_;
> } else {
> R__b.WriteVersion(SDPhotoElecCount_ROOT::IsA());
> TObject::Streamer(R__b);
> R__b << Slot0_;
> R__b << total_;
> {
> R__b << vec_.size();
> vector<int>::iterator R__k;
> for (R__k = vec_.begin(); R__k != vec_.end(); ++R__k)
> R__b << *R__k;
> }
> {
> R__b << li_.size();
> list<int>::iterator R__k;
> for (R__k = li_.begin(); R__k != li_.end(); ++R__k)
> R__b << *R__k;
> }
> {
> R__b << dq_.size();
> deque<int>::iterator R__k;
> for (R__k = dq_.begin(); R__k != dq_.end(); ++R__k)
> R__b << *R__k;
> }
> R__b << photoelectrons_;
> }
> }
>
> The STL map is not handled by the streamer ?
> --------------------------------------------
>
> Yours truly.
>
> Sylvie Dagoret
>
> --
> Sylvie Dagoret-Campagne | e-mail: dagoret@lpnhep.in2p3.fr,
> LPNHE, Universite Paris VI-VII | Sylvie.Dagoret-Campagne@lpnhep.in2p3.fr
> 4, Place Jussieu Tour 33, Rdc | Telephone (33) 01 44 27 73 30
> 75252 PARIS CEDEX 05 - FRANCE | Fax (33) 01 44 27 46 38
> | Standard (33) 01 44 27 63 13
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:45 MET