CtSaving_Edf.h 2.32 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
seb's avatar
seb committed
22
23
24
25
26
27
28
29
30
31
32
#ifndef CTSAVING_EDF_H
#define CTSAVING_EDF_H

#include "CtSaving.h"

namespace lima {

  class SaveContainerEdf : public CtSaving::SaveContainer
  {
    DEB_CLASS_NAMESPC(DebModControl,"Saving EDF Container","Control");
  public:
33
    SaveContainerEdf(CtSaving::Stream& stream);
seb's avatar
seb committed
34
35
36
    virtual ~SaveContainerEdf();
  protected:
    virtual bool _open(const std::string &filename,
37
		       std::ios_base::openmode flags);
seb's avatar
seb committed
38
39
40
41
42
43
    virtual void _close();
    virtual void _writeFile(Data &data,
			    CtSaving::HeaderMap &aHeader,
			    CtSaving::FileFormat);
  private:
    void _writeEdfHeader(Data&,CtSaving::HeaderMap&);
44
45
46
47
48
49
#ifdef WIN32
    class _OfStream
    {
    public:
      _OfStream();
      ~_OfStream();
seb's avatar
seb committed
50

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
      void clear();
      void exceptions(int exc);
      void open(const char* filename,
		std::ios_base::openmode openFlags = 
		std::ios_base::in | std::ios_base::out);
      bool is_open() const;
      void close();
      long tellp() const;
      inline _OfStream& write(const char* data,int size);
      inline _OfStream& operator<< (const char *data);
      inline _OfStream& operator<< (const std::string& data);
      inline _OfStream& operator<< (const int data);
      inline _OfStream& operator<< (const long data);
    private:
      FILE* m_fout;
      int m_exc_flag;
    };
    _OfStream			 m_fout;
#else
seb's avatar
seb committed
70
    std::ofstream                m_fout;
71
#endif
seb's avatar
seb committed
72
73
74
75
  };

}
#endif // CTSAVING_EDF_H