#include "hparasciifileio.h"
#include "hdetpario.h"
#include "hades.h"
#include "hspectrometer.h"
#include <string.h>
ClassImp(HParAsciiFileIo)
HParAsciiFileIo::HParAsciiFileIo() {
file=0;
}
HParAsciiFileIo::~HParAsciiFileIo() {
close();
}
Bool_t HParAsciiFileIo::open(const Text_t* fname,const Text_t* status) {
close();
if(!((strcmp(status,"in")==0) || (strcmp(status,"out")==0))){
printf(" put the right stream option for file :%2s\n",fname);
printf(" writing state : out \n");
printf(" reading state : in \n");
printf(" open aborted \n");
return kFALSE;
}
file=new fstream();
if(strcmp(status,"in")==0){file->open( fname, ios::in);};
if(strcmp(status,"out")==0){file->open( fname, ios::out);};
filebuf* buf = file->rdbuf();
if (file && (buf->is_open()==1)) {
gHades->getSetup()->activateParIo(this);
return kTRUE;
}
return kFALSE;
}
void HParAsciiFileIo::close() {
if (file) {
file->close();
delete file;
file=0;
}
if (detParIoList) detParIoList->Delete();
}
void HParAsciiFileIo::print() {
if (check()) {
printf("Ascii I/O is open\n");
TIter next(detParIoList);
HDetParIo* io;
cout<<"detector I/Os: ";
while ((io=(HDetParIo*)next())) {
cout<<" "<<io->GetName();
}
cout<<'\n';
}
else printf("No pointer to file\n");
}
fstream* HParAsciiFileIo::getFile() {
return file;
}
Last change: Sat May 22 13:06:22 2010
Last generated: 2010-05-22 13:06
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.