recordreader.h
1 /***************************************************************************
2  Copyright (C) 2002-2015 Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13 ***************************************************************************/
14 #ifndef RECORDREADER_H_
15 #define RECORDREADER_H_
16 
17 #include "recorder.h"
18 
20 public:
21  XRawStreamRecordReader(const char *name, bool runtime, const shared_ptr<XDriverList> &driverlist);
22  virtual ~XRawStreamRecordReader() = default;
23 
24  void terminate();
25  void join();
26 
27  const shared_ptr<XComboNode> &speed() const {return m_speed;}
28  const shared_ptr<XBoolNode> &fastForward() const {return m_fastForward;}
29  const shared_ptr<XBoolNode> &rewind() const {return m_rewind;}
30  const shared_ptr<XTouchableNode> &stop() const {return m_stop;}
31  const shared_ptr<XTouchableNode> &first() const {return m_first;}
32  const shared_ptr<XTouchableNode> &next() const {return m_next;}
33  const shared_ptr<XTouchableNode> &back() const {return m_back;}
34  const shared_ptr<XStringNode> &posString() const {return m_posString;}
35 private:
36  struct XRecordError : public XKameError {
37  XRecordError(const XString &msg, const char *file, int line)
38  : XKameError(msg, file, line) {}
39  virtual ~XRecordError() throw() {}
40  };
41  struct XIOError : public XRecordError {
42  XIOError(const char *file, int line);
43  XIOError(const XString &msg, const char *file, int line);
44  virtual ~XIOError() throw() {}
45  };
46  struct XBufferOverflowError : public XIOError {
47  XBufferOverflowError(const char *file, int line);
48  virtual ~XBufferOverflowError() throw() {}
49  };
50  struct XBrokenRecordError : public XRecordError {
51  XBrokenRecordError(const char *file, int line);
52  virtual ~XBrokenRecordError() throw() {}
53  };
54  struct XNoDriverError : public XRecordError {
55  XNoDriverError(const XString &driver_name, const char *file, int line);
56  virtual ~XNoDriverError() throw() {}
57  XString name;
58  };
59 
60  const shared_ptr<XComboNode> m_speed;
61  const shared_ptr<XBoolNode> m_fastForward;
62  const shared_ptr<XBoolNode> m_rewind;
63  const shared_ptr<XTouchableNode> m_stop;
64  const shared_ptr<XTouchableNode> m_first, m_next, m_back;
65  const shared_ptr<XStringNode> m_posString;
66  void onPlayCondChanged(const Snapshot &shot, XValueNodeBase *);
67  void onStop(const Snapshot &shot, XTouchableNode *);
68  void onFirst(const Snapshot &shot, XTouchableNode *);
69  void onNext(const Snapshot &shot, XTouchableNode *);
70  void onBack(const Snapshot &shot, XTouchableNode *);
71 
72  void onOpen(const Snapshot &shot, XValueNodeBase *);
73  shared_ptr<XListener> m_lsnOnOpen;
74 
75  uint32_t m_allsize;
76  XTime m_time;
77 
78  //! change position without parsing
79  void first_(void *) throw (XIOError &);
80  void previous_(void *) throw (XRecordError &);
81  void next_(void *) throw (XRecordError &);
82  void goToHeader(void *) throw (XRecordError &);
83 
84  void readHeader(void *) throw (XRecordError &);
85  //! Parse current pos and go next
86  void parseOne(void *, XMutex &mutex) throw (XRecordError &);
87 
88  void gzgetline(void*fd, unsigned char*buf, unsigned int len, int del) throw (XIOError &);
89 
90  typedef shared_ptr<XThread<XRawStreamRecordReader> > tThread;
91  typedef std::vector<tThread> tThreadList;
92  typedef tThreadList::iterator tThreadIt;
93  tThreadList m_threads;
94  void *execute(const atomic<bool> &);
95  XCondition m_condition;
96  double m_periodicTerm;
97  XMutex m_drivermutex;
98 
99  shared_ptr<XListener> m_lsnStop, m_lsnFirst, m_lsnNext, m_lsnBack;
100  shared_ptr<XListener> m_lsnPlayCond;
101 };
102 
103 #endif /*RECORDREADER_H_*/

Generated for KAME4 by  doxygen 1.8.3