Hi Ralph, You should use a class instead of a struct. I have made a working example writing/reading a BPM_ALL_BASE object. the tar file includes a small script to create a library and a small script monitor.C to write & read Rene Brun On Mon, 2 Jun 2003, Ralph Steinhagen wrote: > Hello! > > I would like to save an object of the bellow declared BPM_ALL_BASE. > This class has two pointer to call the class 'monitor_info'. > > First I declared a static array of 'single_monitor' in 'monitor_info' and the > root standard streamer functions decomposed this array properly so that the > needed data could be saved to file. > I decided to use a variable length array to save some memory because both > 'monitor_info' classes differs largely in size (factor 1000:1) but can and > should be described equally. > > Is there a easy solution to save a variable length array of C struct without > decomposing the C struct into three singular arrays or to write a new > streamer? > > Thanks in advance. > > Ralph Steinhagen > > [..] excerpts out of the code > > struct single_monitor > { > Char_t name[20]; > Float_t pos; > Int_t plane; // 1: horizontal 2: vertical > }; > > class monitor_info: public TObject > { public: > monitor_info(); > ~monitor_info(); > Int_t GetMonitorCount(); > Char_t* GetMonitorName(Int_t i); > Float_t GetMonitorPosition(Int_t i); > Int_t GetMonitorPlane(Int_t i); > const Char_t* GetMonitorNamePlane(Int_t i); > Int_t AddMonitor(Int_t i, Char_t *name, Float_t pos, Int_t plane); > Int_t IsMonitorPlane(Int_t i, Int_t plane); > > private: > Int_t fcount; > single_monitor *fmonitor; //[fcount] > > ClassDef(monitor_info,1) > }; > > > class BPM_ALL_BASE : public TObject > { > public: > Int_t Cycletype; > > monitor_info *MOPOS_Monitor; //-> > monitor_info *REALTIME_Monitor; //-> > > BPM_ALL_BASE(); > ~BPM_ALL_BASE(); > > private: > > ClassDef(BPM_ALL_BASE,1) > }; > > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET