1 /***************************************************************************
2 filesource.h - description
4 begin : Son Feb 10 2002
5 copyright : (C) 2002 by Thomas Kabelmann
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
22 *FileSource is an asynchronous class for reloading star data while running
23 *the program. It's basing on QDataSource class and implements the function
24 *for reading a file step by step and send these data to an QDataSink object.
25 *KStarsData uses this class for asynchronous io.
26 *@author Thomas Kabelmann
36 class FileSource
: public QDataSource
{
39 /**constructor needs an KStarsData object, a file name and the new magnitude
41 FileSource( KStarsData
*ksdata
, float magnitude
);
46 /**send a value indicating whether the object is ready to send data.
47 *@return 1 if data is ready to send; return -1 if the stream is finished.
51 /**Is this object rewindable?
52 *@return false, because it's not needed to rewind.
54 bool rewindable() { return false; }
56 /**The function for sending data to an QDataSink object. Here will all data
57 *operations defined. Because this function is virtual, we need a second int
58 *parameter, but we don't use it, so it's unnamed.
59 *@p sink pointer to the QDataSink object which will receive the data stream
61 void sendTo( QDataSink
*sink
, int );
63 /**@return current magnitude to load (always returns maxMagnitude)
65 float magnitude() { return maxMagnitude
; }
71 KSFileReader
*fileReader
;
73 // which sao file should be opened and which line
74 int fileNumber
, lineNumber
;
79 // new magnitude to load
84 /**maxLines defines how many lines in data file should be read and
85 *send to QDataSink. This is only needed if a data block is longer
86 *than the max defined lines. I figured out this value of 500
87 *on a fast system, so if it is to high the value might be decreased.
88 *A high value means faster reloading but perhaps on slow systems this
89 *might interrupt the main event loop.
90 *A low value needs longer to reload data, but it doesn't interrupt the
91 *main event loop (it's smoother).
92 *But it's important to know that 500 lines to read is very fast, but
93 *appending to QList in StarDataSink will take the most time and this
94 *will also defined with this value.
98 /**The loaded data will stored in a string array and a pointer to first
99 *object in array will send to StarDataSink.
101 QString stringArray
[ maxLines
];