FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairParAsciiFileIo.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 #ifndef FAIRPARASCIFILEIIO_H
9 #define FAIRPARASCIFILEIIO_H
10 
11 #include "FairParIo.h" // for FairParIo
12 
13 #include <Rtypes.h> // for Bool_t, Text_t, etc
14 #include <fstream> // for fstream, etc
15 
16 class TList;
17 
19 {
20  protected:
21  std::fstream* file; // pointer to a file
22 
23  public:
25 
26  // default destructor closes an open file and deletes list of I/Os
28 
29  // opens file
30  // if a file is already open, this file will be closed
31  // activates detector I/Os
32  Bool_t open(const Text_t* fname, const Text_t* status = "in");
33 
34  // concatenate files whose names are stored in the TList
35  // TList holds list od TObjStrings
36  // create file all.par in local working directory
37  // calls open to open the generated file all.par
38  Bool_t open(const TList* fnamelist, const Text_t* status = "in");
39 
40  // closes file
41  void close();
42 
43  // returns kTRUE if file is open
44  Bool_t check()
45  {
46  if (file) {
47  return (file->rdbuf()->is_open() == 1);
48  } else {
49  return kFALSE;
50  }
51  }
52 
53  // prints information about the file and the detector I/Os
54  void print();
55 
56  std::fstream* getFile();
57 
58  private:
60  FairParAsciiFileIo& operator=(const FairParAsciiFileIo&);
61 
62  ClassDef(FairParAsciiFileIo, 0); // Parameter I/O from ASCII files
63 };
64 
65 #endif /* !FAIRPARASCIIFILEIO_H */
Bool_t open(const Text_t *fname, const Text_t *status="in")
std::fstream * getFile()