AwReadWrite
Read Write Library for AnyWave
AwReaderInterface.h
1 //
3 // Université d’Aix Marseille (AMU) -
4 // Institut National de la Santé et de la Recherche Médicale (INSERM)
5 // Copyright © 2013 AMU, INSERM
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation; either
10 // version 3 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //
21 //
22 //
23 // Author: Bruno Colombet – Laboratoire UMR INS INSERM 1106 - Bruno.Colombet@univ-amu.fr
24 //
26 #ifndef AW_READER_INTERFACE_H_
27 #define AW_READER_INTERFACE_H_
28 
29 #include <AwReadWriteLib.h>
30 #include <AwSensorLayout.h>
31 #include <QSemaphore>
32 
33 namespace Aw
34 {
36  enum AwReaderFlags { ReaderHasExtension = 0x00000001, ReaderTriggerChannelIsWritable = 0x00000002 };
37 }
38 
39 class AwReaderPlugin;
40 
55 class AwFileReader : public QObject
56 {
57 public:
58  enum FileStatus { NoError, WrongFormat, FileAccess, BadHeader };
60 
62  AwFileReader(const QString& filename = QString()) { m_flags = 0x00000000; infos.setFileName(filename); }
63  virtual ~AwFileReader() { }
64 
66  inline AwReaderPlugin *plugin() { return m_plugin; }
67 
68  inline void setPlugin(AwReaderPlugin *plugin) { m_plugin = plugin; }
69 
71  inline int flags() { return m_flags; }
72 
73  // Methods (PURE VIRTUAL SO HAVE TO BE IMPLEMENTED)
75  virtual FileStatus openFile(const QString &path) = 0;
77  virtual FileStatus canRead(const QString &path) = 0;
78 
83  virtual long readDataFromChannels(float start, float duration, QList<AwChannel *> &channelList) = 0;
84 
86  virtual void cleanUpAndClose() = 0;
87 
89  virtual AwChannelList triggerChannels() { return AwChannelList(); }
91  virtual AwSensorLayoutList layouts() { return AwSensorLayoutList(); }
92 
93 signals:
94  void triggerValuesWritten(bool status, int number);
95 public slots:
99  virtual void writeTriggerChannel(const QString& name, AwMarkerList& list) {}
101  virtual void clearTriggerChannel(const QString& name) {}
102 
103 protected:
104  AwReaderPlugin *m_plugin;
105  int m_flags;
106 };
107 
121 class AwReaderPlugin : public QObject
122 {
123 public:
124  AwReaderPlugin() { m_flags = 0x00000000; }
125  QString name;
126  QString version;
127  QString description;
128  QStringList fileExtensions;
129  QString manufacturer;
130 
132  inline int flags() { return m_flags; }
133 
135  virtual AwFileReader *newInstance(const QString& filename = QString()) = 0;
136 
137  virtual void deleteInstance(AwFileReader *fr) { delete fr; fr = NULL; }
139  virtual QStringList montages() { return QStringList(); }
140 protected:
141  int m_flags;
142 };
143 
144 Q_DECLARE_INTERFACE(AwReaderPlugin, "AwReaderPluginInterface_1.0")
145 Q_DECLARE_INTERFACE(AwFileReader, "AwFileReaderInterface_1.0")
146 
147 #endif /*PLUGIN_INTERFACE_H_*/
QStringList fileExtensions
A string list with supported file extensions.
Definition: AwReaderInterface.h:128
QString manufacturer
The name of the manufacturer: OPTIONAL.
Definition: AwReaderInterface.h:129
AwFileReader(const QString &filename=QString())
Definition: AwReaderInterface.h:62
Base class to implement a reader plug-in.
Definition: AwReaderInterface.h:121
int flags()
Definition: AwReaderInterface.h:132
Definition: AwReaderInterface.h:33
virtual FileStatus openFile(const QString &path)=0
virtual AwChannelList triggerChannels()
Definition: AwReaderInterface.h:89
virtual FileStatus canRead(const QString &path)=0
virtual AwFileReader * newInstance(const QString &filename=QString())=0
void setFileName(const QString &name)
Definition: AwReadWriteLib.h:141
QString version
plugin's version
Definition: AwReaderInterface.h:126
virtual AwSensorLayoutList layouts()
Definition: AwReaderInterface.h:91
virtual void cleanUpAndClose()=0
virtual long readDataFromChannels(float start, float duration, QList< AwChannel * > &channelList)=0
QString name
plugin's name: MANDATORY
Definition: AwReaderInterface.h:125
virtual QStringList montages()
Definition: AwReaderInterface.h:139
AwReaderPlugin * plugin()
Definition: AwReaderInterface.h:66
Base class to implement a file reader object.
Definition: AwReaderInterface.h:55
virtual void clearTriggerChannel(const QString &name)
Definition: AwReaderInterface.h:101
virtual void writeTriggerChannel(const QString &name, AwMarkerList &list)
Definition: AwReaderInterface.h:99
AwDataInfoReader infos
a AwDataInfoReader giving informations about channels and blocks in data file.
Definition: AwReaderInterface.h:59
int flags()
Definition: AwReaderInterface.h:71
QString description
short description: MANDATORY
Definition: AwReaderInterface.h:127
Defines class to manage file information for reader's plug-ins.
Definition: AwReadWriteLib.h:173