BLAsciiFile Class Reference

#include <BLAsciiFile.hh>

List of all members.


Detailed Description

class BLAsciiFile manages file-descriptors for writing ASCII files.

Multiple fopen()-s of a given filename will all get the same FILE *. Multiple fclose()-s of the FILE* are handled properly (fhe first closes the file, successive ones do nothing).

The filename-s must match exactly as given, no conversion to absolute paths (or any other canonicalization) is performed..

Only does writing.

Static Public Member Functions

static FILE * fopen (G4String name)
 fopen() will open a file for writing, returning the same FILE * for multiple opens.
static void fclose (FILE *f)
 fclose() will close the FILE*, handling multiple calls.

Static Private Attributes

static std::map< G4String, FILE * > fds


Member Function Documentation

static FILE* BLAsciiFile::fopen ( G4String  name  )  [inline, static]

fopen() will open a file for writing, returning the same FILE * for multiple opens.

References fds.

Referenced by AsciiNTuple::AsciiNTuple(), BLFOR009::BLFOR009(), BLTrackFile::BLTrackFile(), BLCMDtotalenergy::callback(), BLCMDprofile::command(), and BLCMDprintf::command().

00044                                           {
00045                 if(fds.count(name) == 0) {
00046                         FILE *f = ::fopen(name.c_str(),"w");
00047                         if(f != 0)
00048                                 fds[name] = f;
00049                         return f;
00050                 }
00051                 return fds[name];
00052         }

static void BLAsciiFile::fclose ( FILE *  f  )  [inline, static]

fclose() will close the FILE*, handling multiple calls.

References fds.

Referenced by BLCMDtotalenergy::callback(), BLCMDprofile::callback(), BLCMDprintf::callback(), AsciiNTuple::close(), BLFOR009::close(), and BLTrackFile::~BLTrackFile().

00055                                     {
00056                 std::map<G4String,FILE*>::iterator i;
00057                 for(i=fds.begin(); i!=fds.end(); ++i) {
00058                         if(i->second != f) continue;
00059 			::fclose(f);
00060                         fds.erase(i);
00061                         break;
00062                 }
00063         }


Member Data Documentation

std::map< G4String, FILE * > BLAsciiFile::fds [static, private]

Referenced by fclose(), and fopen().


The documentation for this class was generated from the following files:
g4beamline