//----------------------------------------------------------------------------//
// module ThrLoadData.h //
// //
// Thread function: Calls TData::Load() in its Execute function //
// // //
// copyright (c) 2003 by Lars Haendel //
// home: www.newty.de //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 2 of the License. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
// //
//----------------------------------------------------------------------------//
#ifndef LoadDataH
#define LoadDataH
//---------------------------------------------------------------------------
#include <Classes.hpp>
//---------------------------------------------------------------------------
#include "FMain.h" // due to: TFMain
//----------------------------------------------------------------------------------------------------------------------
// thread object: Calls TData::Load() in its Execute function
class ThrLoadData : public TThread
{
private:
TData* data; // data object whose Load function will be executed
AnsiString szFilename; // filename to load data from
void (*FinishFunc)(const bool&); // callback function called in OnFinish()
const bool* f_Stop; // optional: stop flag
const TDataData* ddata; // optional: used when loading test data; data is checked if it's compatible with TDataData object
char szText[256]; // error message text
bool f_Error; // error flag
bool f_IsWithOutput; // flag: data is with output
void __fastcall OnFinish(TObject*); // call when loading is finished
void __fastcall Execute();
void __fastcall MessageBox(); // display error message
public:
// constructor
__fastcall ThrLoadData(const bool& CreateSuspended, TData*const& _data, const AnsiString& _szFilename,
void (*_FinishFunc)(const bool&), const bool*const& _f_Stop=NULL, const TDataData*const& _ddata=NULL);
void SetDData(const TDataData*const& _ddata) { ddata = _ddata; }; // 2nd possibility to pass
const bool& IsWithOutput() const { return f_IsWithOutput; }; // return true is data is with output
};
#endif