TestApp.h

Parent Previous Next

///////////////////////////////////////////////////////////////////////////////////////////////////

// DreamTestApp.h

///////////////////////////////////////////////////////////////////////////////////////////////////


#pragma once;


///////////////////////////////////////////////////////////////////////////////////////////////////

// CCalcObserver


class CCalcObserver : public IDreamObserver

{

public:

 /// <summary>Constructor</summary>

 CCalcObserver();

 CCalcObserver(_bstr_t path);

 /// <summary>Destructor</summary>

 virtual ~CCalcObserver();


 /// <summary>Print logged messages</summary>

 void PrintMessages() const;

 /// <summary>Returs number of errors</summary>

 int GetNoOfErrors() const {return m_iNoOfErrors;}

 /// <summary>Returs number of warnings</summary>

 int GetNoOfWarnings() const {return m_iNoOfWarnings;}


 /// <summary>Adds new message to log</summary>

 virtual HRESULT STDMETHODCALLTYPE OnLogMessage(BSTR strLogMessage) override;

 /// <summary>Provides info about calculation error</summary>

 virtual HRESULT STDMETHODCALLTYPE OnError(IDreamErrorInfo* pErrorInfo) override;


 /// <summary>Set current evaluation step</summary>

 virtual HRESULT STDMETHODCALLTYPE SetCurrentStep(float fStep) override;

 /// <summary>Set convergence information</summary>

 virtual HRESULT STDMETHODCALLTYPE SetConvergenceInfo(float fInfo) override;


 /// <summary>Called after the calculation was terminated by user</summary>

 virtual HRESULT STDMETHODCALLTYPE OnCalculationTerminatedByUser() override;

 /// <summary>Called after finishing the calculation</summary>

 virtual HRESULT STDMETHODCALLTYPE OnCalculationFinished() override;

 /// <summary>Called before exporting output data</summary>

 virtual HRESULT STDMETHODCALLTYPE OnPreparingOutputData() override;


 /// <summary>Was calculation terminated by user? Yes (S_OK) or not (S_FALSE)</summary>

 virtual HRESULT STDMETHODCALLTYPE CalculationTerminatedByUser() override;


 /// <summary>IUnknown implementation</summary>

 virtual HRESULT STDMETHODCALLTYPE QueryInterface(const IID& iid,void** ppv) override;

 virtual ULONG STDMETHODCALLTYPE AddRef()  override;

 virtual ULONG STDMETHODCALLTYPE Release() override;


private:

 /// <summary>Log file name</summary>

 _bstr_t m_LogFile;


 /// <summary>Current step</summary>

 int   m_iCurrentStep;

 /// <summary>Convergence info</summary>

 float m_fConvergenceInfo;

 /// <summary>Reference counter</summary>

 long  m_cRef;

 /// <summary>Number of errors</summary>

 int   m_iNoOfErrors;

 /// <summary>Number of warnings</summary>

 int   m_iNoOfWarnings;

};


///////////////////////////////////////////////////////////////////////////////////////////////////

// CDreamErrorInfo


class CDreamErrorInfo : public IDreamErrorInfo

{

public:

 /// <summary>Constructor</summary>

 CDreamErrorInfo() {}

 /// <summary>Destructor</summary>

 virtual ~CDreamErrorInfo() {}

 int GetErrID() const { return _errorID; }

 int GetErrType() const { return _type; }

 BSTR GetErrDescription() const { return _errorDesc; }

};


///////////////////////////////////////////////////////////////////////////////////////////////////

// Struct for example info


struct CExample

{

 const wchar_t* m_strName;

 const wchar_t* m_strText;

};


///////////////////////////////////////////////////////////////////////////////////////////////////

// Help functions


/// <summary>Get user's choice - a number from interval <0,N></summary>

int GetUserChoice(std::wstring wsPromptLine, int iMinNo, int iMaxNo);

/// <summary>Single handler - interrupts the calculation after Ctrl+C</summary>

BOOL SignalHandler(DWORD fdwCtrlType);

/// <summary>Prints text to console using UTF8</summary>

void PrintMessageUTF8(const std::wstring sLine);


///////////////////////////////////////////////////////////////////////////////////////////////////