MIDAS
Loading...
Searching...
No Matches
WriterFile Class Reference
Inheritance diagram for WriterFile:
Collaboration diagram for WriterFile:

Public Member Functions

 WriterFile (LOG_CHN *log_chn)
 
 ~WriterFile ()
 
int wr_open (LOG_CHN *log_chn, int run_number)
 
int wr_write (LOG_CHN *log_chn, const void *data, const int size)
 
int wr_close (LOG_CHN *log_chn, int run_number)
 
std::string wr_get_chain ()
 
- Public Member Functions inherited from WriterInterface
 WriterInterface ()
 
virtual ~WriterInterface ()
 
virtual std::string wr_get_file_ext ()
 

Private Attributes

std::string fFilename
 
int fFileno
 

Additional Inherited Members

- Public Attributes inherited from WriterInterface
bool fTrace
 
double fBytesIn
 
double fBytesOut
 

Detailed Description

Definition at line 501 of file mlogger.cxx.

Constructor & Destructor Documentation

◆ WriterFile()

WriterFile::WriterFile ( LOG_CHN log_chn)
inline

Definition at line 504 of file mlogger.cxx.

505 {
506 if (fTrace)
507 printf("WriterFile: path [%s]\n", log_chn->path.c_str());
508 fFileno = -1;
509 }
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ ~WriterFile()

WriterFile::~WriterFile ( )
inline

Definition at line 511 of file mlogger.cxx.

512 {
513 if (fTrace)
514 printf("WriterFile: destructor\n");
515 fFileno = -1;
516 }
Here is the call graph for this function:

Member Function Documentation

◆ wr_close()

int WriterFile::wr_close ( LOG_CHN log_chn,
int  run_number 
)
inlinevirtual

Implements WriterInterface.

Definition at line 572 of file mlogger.cxx.

573 {
574 int err;
575
576 if (fTrace)
577 printf("WriterFile: close path [%s]\n", log_chn->path.c_str());
578
579 assert(fFileno >= 0);
580
581 log_chn->handle = 0;
582
583 err = close(fFileno);
584 fFileno = -1;
585
586 if (err != 0) {
587 cm_msg(MERROR, "WriterFile::wr_close", "Cannot write to file \'%s\', close() errno %d (%s)", log_chn->path.c_str(), errno, strerror(errno));
588 return SS_FILE_ERROR;
589 }
590
591 return SUCCESS;
592 }
#define SS_FILE_ERROR
Definition midas.h:669
#define SUCCESS
Definition mcstd.h:54
#define MERROR
Definition midas.h:559
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
Here is the call graph for this function:

◆ wr_get_chain()

std::string WriterFile::wr_get_chain ( )
inlinevirtual

Implements WriterInterface.

Definition at line 594 of file mlogger.cxx.

595 {
596 return ">" + fFilename;
597 }
std::string fFilename
Definition mlogger.cxx:600

◆ wr_open()

int WriterFile::wr_open ( LOG_CHN log_chn,
int  run_number 
)
inlinevirtual

Implements WriterInterface.

Definition at line 518 of file mlogger.cxx.

519 {
520 fBytesIn = 0;
521 fBytesOut = 0;
522
523 if (fTrace)
524 printf("WriterFile: open path [%s]\n", log_chn->path.c_str());
525
526 assert(fFileno < 0);
527
528 if (check_file_exists(log_chn->path.c_str()))
529 return SS_FILE_EXISTS;
530
531#ifdef OS_WINNT
533#else
534 fFileno = open(log_chn->path.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_TRUNC | O_BINARY | O_LARGEFILE, 0444);
535#endif
536 if (fFileno < 0) {
537 cm_msg(MERROR, "WriterFile::wr_open", "Cannot write to file \'%s\', open() errno %d (%s)", log_chn->path.c_str(), errno, strerror(errno));
538 return SS_FILE_ERROR;
539 }
540
541 log_chn->handle = fFileno;
542
543 fFilename = log_chn->path;
544 return SUCCESS;
545 }
#define SS_FILE_EXISTS
Definition midas.h:686
#define O_BINARY
Definition msystem.h:219
#define O_LARGEFILE
Definition midas.h:210
static bool check_file_exists(const char *filename)
Definition mlogger.cxx:394
Here is the call graph for this function:

◆ wr_write()

int WriterFile::wr_write ( LOG_CHN log_chn,
const void data,
const int  size 
)
inlinevirtual

Implements WriterInterface.

Definition at line 547 of file mlogger.cxx.

548 {
549 if (fTrace)
550 printf("WriterFile: write path [%s], size %d\n", log_chn->path.c_str(), size);
551
552 if (size == 0)
553 return SUCCESS;
554
555 assert(fFileno >= 0);
556
557 fBytesIn += size;
558
559 int wr = write(fFileno, data, size);
560
561 if (wr > 0)
562 fBytesOut += wr;
563
564 if (wr != size) {
565 cm_msg(MERROR, "WriterFile::wr_write", "Cannot write to file \'%s\', write(%d) returned %d, errno: %d (%s)", log_chn->path.c_str(), size, wr, errno, strerror(errno));
566 return SS_FILE_ERROR;
567 }
568
569 return SUCCESS;
570 }
void * data
Definition mana.cxx:268
#define write(n, a, f, d)
Here is the call graph for this function:

Member Data Documentation

◆ fFilename

std::string WriterFile::fFilename
private

Definition at line 600 of file mlogger.cxx.

◆ fFileno

int WriterFile::fFileno
private

Definition at line 601 of file mlogger.cxx.


The documentation for this class was generated from the following file: