Stimfit @PACKAGE_VERSION@
Loading...
Searching...
No Matches
filedesc.hpp
Go to the documentation of this file.
1//***********************************************************************************************
2//
3// Copyright (c) 1993-1997 Axon Instruments.
4// All rights reserved.
5// Permission is granted to freely to use, modify and copy the code in this file.
6//
7//***********************************************************************************************
8//
9// MODULE: FILEDESC.HPP
10// PURPOSE: Contains the class definition for the CFileDescriptor class.
11//
12
13#ifndef INC_FILEDESC_HPP
14#define INC_FILEDESC_HPP
15/*
16#include "./../Common/BufferedArray.hpp" // Virtual item array objects
17*/
18#include "./../Common/FileIO.hpp" // Low-level file I/O services
19#include "csynch.hpp" // Virtual synch array object
20/*
21//#include "DACFile.hpp" // Virtual DACFile array object
22//#include "voicetag.hpp" // Array of voice tag descriptors.
23#include "notify.hpp" // CABFNotify class -- wraps ABFCallback function.
24#include "SimpleStringCache.hpp" // Virtual annotations object
25*/
26#define FI_PARAMFILE 0x0001
27#define FI_READONLY 0x0002
28#define FI_WRITEONLY 0x0004
29
30class CFileDescriptor
31{
32private: // Member variables.
33 CFileIO m_File; // The low level File object.
34 CSynch m_VSynch; // The virtual synch array
35
36 enum { CACHE_SIZE=10 };
37// CBufferedArray m_Tags; // The tag writing object.
38// CBufferedArray m_Deltas; // The delta writing object.
39// CVoiceTagList m_VoiceTagList; // List of voice tags waiting to be saved in ABF file.
40// CDACFile m_DACFile[ABF_WAVEFORMCOUNT]; // DAC file sweeps.
41
42 UINT m_uFlags; // Various flags governing the file opened.
43// CABFNotify m_Notify; // Client notification object.
44 int m_nLastError; // Error number for last error.
45
46 UINT m_uAcquiredEpisodes; // The number of episodes written to this file.
47 UINT m_uAcquiredSamples; // The total number of samples written to this file.
48 void *m_pvReadBuffer; // Buffer to be used for de-multiplexing data
49 UINT m_uCachedEpisode; // Episode number for the episode cached in the read buffer.
50 UINT m_uCachedEpisodeSize; // Size of the cached episode.
51 UINT m_uLastEpiSize; // The size of the last episode for continuous files
52 BOOL m_bHasOverlappedData; // TRUE if the file contains overlapped data.
53 TCHAR m_szFileName[_MAX_PATH];
54
55// CSimpleStringCache m_Annotations; // The annotations writing object.
56
57private:
58 CFileDescriptor(const CFileDescriptor &FI);
59 const CFileDescriptor &operator=(const CFileDescriptor &FI);
60
61public:
64
65 void SetFlag(UINT uFlag);
67
68 BOOL IsOK();
69 BOOL Open(LPCTSTR szFileName, BOOL bReadOnly);
70/* BOOL Reopen(BOOL bReadOnly);
71
72 BOOL FillToNextBlock( ABFLONG *plBlockNum );
73 BOOL Write(const void *pvBuffer, UINT uSizeInBytes);
74*/ BOOL Read(void *pvBuffer, UINT uSizeInBytes);
75 BOOL Seek(LONGLONG llOffset, UINT uFlag, LONGLONG *pllOffset=NULL);
76/* BOOL SetEndOfFile();
77
79/* LPCSTR GetFileName() const;
80
82 void SetAcquiredEpisodes(UINT uEpisodes);
84 void SetAcquiredSamples(UINT uSamples);
85/* UINT GetAcquiredSamples() const;
86
89 void *GetReadBuffer(); // Buffer to be used for de-multiplexing data
90
91 void SetCachedEpisode(UINT uEpisode, UINT uEpisodeSize);
93 UINT GetCachedEpisodeSize() const; // Size of the cached episode.
94
95 void SetLastEpiSize(UINT uEpiSize);
97
98 // Synch array functions.
99 BOOL PutSynchEntry( UINT uStart, UINT uLength, UINT uOffset=0 );
100/* void IncreaseEventLength( UINT dwIncrease );
101*/ BOOL GetSynchEntry( UINT uEpisode, Synch *pSynch );
102/* UINT EpisodeStart( UINT uEpisode);
103 void SetEpisodeStart(UINT uEpisode, UINT uSynchTime);
104*/ UINT EpisodeLength( UINT uEpisode);
105/* UINT FileOffset( UINT uEpisode);
106 BOOL WriteSynchArray( ABFLONG *plBlockNum, ABFLONG *plCount, UINT uSampleSize );
109/* CSynch *GetSynchObject();
110*/ void ChangeSynchArray(CSynch *pNewSynch);
111/*
112 // Tag array functions.
113 BOOL PutTag( const ABFTag *pTag );
114 UINT GetTagCount() const;
115 BOOL WriteTags( ABFLONG *plBlockNum, ABFLONG *plCount );
116 BOOL UpdateTag(UINT uTag, const ABFTag *pTag);
117 BOOL ReadTags( UINT uFirstTag, ABFTag *pTagArray, UINT uNumTags);
118
119 // Voice tag functions.
120 BOOL SaveVoiceTag( LPCSTR pszFileName, ABFLONG lDataOffset, ABFVoiceTagInfo *pVTI);
121 BOOL WriteVoiceTags( ABFLONG *plBlockNum, ABFLONG *plCount );
122 BOOL GetVoiceTag( UINT uTag, LPCSTR pszFileName, ABFLONG lDataOffset,
123 ABFVoiceTagInfo *pVTI, ABFLONG lVoiceTagPtr);
124
125 // Delta functions.
126 BOOL PutDelta(const ABFDelta *pDelta);
127 UINT GetDeltaCount() const;
128 BOOL WriteDeltas( ABFLONG *plBlockNum, ABFLONG *plCount );
129 BOOL ReadDeltas(UINT uFirstDelta, ABFDelta *pDeltaArray, UINT uNumDeltas);
130
131 // DAC file functions.
132 BOOL PutDACFileSweep( UINT uDACChannel, UINT uSweep, const DAC_VALUE *pnData, UINT uLength );
133 BOOL GetDACFileSweep(UINT uDACChannel, UINT uSweep, DAC_VALUE *pnData, UINT uMaxLength);
134 UINT GetDACFileSweepCount( UINT uDACChannel ) const;
135 BOOL WriteDACFileSweeps( UINT uDACChannel, ABFLONG *plBlockNum, ABFLONG *plCount );
136
137 // Annotations functions.
138 BOOL PutAnnotation( LPCSTR pszText );
139 UINT GetAnnotationCount() const;
140 BOOL WriteAnnotations( ABFLONG *plBlockNum, ABFLONG *plCount );
141 BOOL ReadAnnotation( UINT uIndex, LPSTR pszText, UINT uBufSize );
142 BOOL ReadAllAnnotations( ABFLONG lBlockNum );
143 UINT GetMaxAnnotationSize() const;
144*/
146/* BOOL SetErrorCallback(ABFCallback fnCallback, void *pvThisPointer);
147
148*/ void SetOverlappedFlag(BOOL bOverlapped);
150
151 BOOL SetLastError(int nError);
152 int GetLastError() const;
153
154};
155
156
157//===============================================================================================
158// FUNCTION: GetFileHandle
159// PURPOSE: Returns the file handle opened in the object.
160//
162{
163// MEMBERASSERT();
164 return m_File.GetFileHandle();
165}
166
167
168//===============================================================================================
169// FUNCTION: Seek
170// PURPOSE: Change the current position of the file pointer.
171//
172inline BOOL CFileDescriptor::Seek(LONGLONG llOffset, UINT uFlag, LONGLONG *pllNewOffset)
173{
174// MEMBERASSERT();
175 return m_File.Seek(llOffset, uFlag, pllNewOffset);
176}
177
178
179//===============================================================================================
180// FUNCTION: GetFileSize
181// PURPOSE: Return the length of the file in bytes.
182//
184{
185// MEMBERASSERT();
186 return m_File.GetFileSize();
187}
188
189
190//===============================================================================================
191// PROCEDURE: Read
192// PURPOSE: Reads a block and returnd FALSE on ERROR.
193//
194inline BOOL CFileDescriptor::Read(LPVOID lpBuf, UINT uBytesToRead)
195{
196// MEMBERASSERT();
197 return m_File.Read(lpBuf, uBytesToRead) ? TRUE : SetLastError(ABF_EREADDATA);
198}
199
200//===============================================================================================
201// FUNCTION: IsOK
202// PURPOSE: Checks to see whether the object was created OK.
203//
205{
206// MEMBERASSERT();
207 return (m_nLastError==0);
208}
209
210//===============================================================================================
211// FUNCTION: PutSynchEntry
212// PURPOSE: Puts a new entry into the Synch array.
213//
214inline BOOL CFileDescriptor::PutSynchEntry( UINT uStart, UINT uLength, UINT uOffset )
215{
216// MEMBERASSERT();
217 return m_VSynch.Put( uStart, uLength, uOffset );
218}
219/*
220//===============================================================================================
221// FUNCTION: IncreaseEventLength
222// PURPOSE: Increases the length of the last entry in the synch array.
223//
224inline void CFileDescriptor::IncreaseEventLength( UINT uIncrease )
225{
226 MEMBERASSERT();
227 m_VSynch.IncreaseLastLength( uIncrease );
228}
229*/
230
231//===============================================================================================
232// FUNCTION: GetSynchEntry
233// PURPOSE: Gets the Synch information for a particular episode.
234//
236{
237// MEMBERASSERT();
238// ASSERT(uEpisode > 0);
239 return m_VSynch.Get( uEpisode-1, pSynch, 1 );
240}
241
242//===============================================================================================
243// FUNCTION: GetReadBuffer
244// PURPOSE: returns a pointer to the read buffer.
245//
247{
248// MEMBERASSERT();
249 return m_pvReadBuffer;
250}
251
252#endif // INC_FILEDESC_HPP
#define ABF_EREADDATA
Definition abffiles.h:42
void SetLastEpiSize(UINT uEpiSize)
BOOL AllocReadBuffer(UINT uBytes)
void ChangeSynchArray(CSynch *pNewSynch)
void SetCachedEpisode(UINT uEpisode, UINT uEpisodeSize)
BOOL SetLastError(int nError)
BOOL TestFlag(UINT uFlag)
UINT GetCachedEpisode() const
UINT EpisodeLength(UINT uEpisode)
void SetSynchMode(CSynch::eMODE eMode)
BOOL CheckEpisodeNumber(UINT uEpisode)
BOOL GetSynchEntry(UINT uEpisode, Synch *pSynch)
Definition filedesc.hpp:235
void FreeReadBuffer()
BOOL Read(void *pvBuffer, UINT uSizeInBytes)
Definition filedesc.hpp:194
int GetLastError() const
FILEHANDLE GetFileHandle()
Definition filedesc.hpp:161
void SetAcquiredSamples(UINT uSamples)
BOOL PutSynchEntry(UINT uStart, UINT uLength, UINT uOffset=0)
Definition filedesc.hpp:214
LONGLONG GetFileSize()
Definition filedesc.hpp:183
UINT GetAcquiredEpisodes() const
void * GetReadBuffer()
Definition filedesc.hpp:246
UINT GetLastEpiSize() const
BOOL GetOverlappedFlag() const
void SetFlag(UINT uFlag)
void SetOverlappedFlag(BOOL bOverlapped)
UINT GetCachedEpisodeSize() const
void SetAcquiredEpisodes(UINT uEpisodes)
UINT GetSynchCount() const
BOOL Open(LPCTSTR szFileName, BOOL bReadOnly)
BOOL Seek(LONGLONG llOffset, UINT uFlag, LONGLONG *pllOffset=NULL)
Definition filedesc.hpp:172
char TCHAR
Definition unix.h:123
int BOOL
Definition unix.h:49
unsigned int UINT
Definition unix.h:47
FILE * FILEHANDLE
Definition unix.h:38
#define _MAX_PATH
Definition unix.h:188
#define TRUE
Definition unix.h:171
void * LPVOID
Definition unix.h:52
LPCSTR LPCTSTR
Definition unix.h:130
long long LONGLONG
Definition unix.h:143