summaryrefslogtreecommitdiffstats
path: root/tksao/fitsy++/strm.h
blob: 55ef4c05cd4934ffe26d4b34f122d08288fc6479 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (C) 1999-2016
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#ifndef __fitsstream_h__
#define __fitsstream_h__

#include "file.h"
#include "zlib.h"

typedef struct gzStream_ {
  z_stream zstream;
  int id;
  int transparent;
  unsigned char header[2];
  int useHeader;
  unsigned char* buf;
} *gzStream;

template<class T>
class FitsStream : public FitsFile {
 protected:
  T stream_;
  FitsFile::FlushMode flush_;
  int dataManage_;           // flag, true if we manage data

  FitsHead* headRead();
  int dataRead(size_t bytes, int validate =1);
  void dataSkip(size_t);
  void dataSkipBlock(size_t);
  void skipEnd();

  size_t read(char*, size_t);
  void close();
  void found();
  void error();

public:
  FitsStream();
  virtual ~FitsStream();

  T stream() {return stream_;}
  FitsFile::FlushMode flush() {return flush_;}
  int dataManage() {return dataManage_;}

  void done() {close();}
};

template<class T>
class FitsFitsStream : public virtual FitsStream<T> {
protected:
  void processExact();
  void processRelax();

public:
  FitsFitsStream(FitsFile::ScanMode, FitsFile::FlushMode);
};

template<class T>
class FitsFitsNextStream : public FitsStream<T> {
public:
  FitsFitsNextStream(FitsFile* prev);
};

template<class T>
class FitsArrStream : public virtual FitsStream<T> {
public:
  FitsArrStream(FitsFile::FlushMode);
};

template<class T>
class FitsNRRDStream : public virtual FitsStream<T> {
public:
  FitsNRRDStream(FitsFile::FlushMode);
};

template<class T>
class FitsMosaicStream : public virtual FitsStream<T> {
public:
  FitsMosaicStream(FitsFile::FlushMode);
};

template<class T>
class FitsMosaicNextStream : public FitsStream<T> {
public:
  FitsMosaicNextStream(FitsFile* prev, FitsFile::FlushMode);
};

#endif