//**************************************************************************************************
//                                          SimnBase.hpp                                           *
//                                         --------------                                          *
// Description : This class is the base class for all simulation classes.                          *
// Started     : 2008-05-01                                                                        *
// Last Update : 2018-09-25                                                                        *
// Copyright   : (C) 2008-2018 MSWaters                                                            *
//**************************************************************************************************

//**************************************************************************************************
//                                                                                                 *
//      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;      *
//      either version 3 of the License, or (at your option) any later version.                    *
//                                                                                                 *
//**************************************************************************************************

#ifndef SIMNBASE_HPP
#define SIMNBASE_HPP

// Application Includes

#include "TypeDefs.hpp"
#include "CmdBase.hpp"
#include "netlist/NetList.hpp"
#include "utility/CnvtType.hpp"

//**************************************************************************************************

class SimnBase : public NetList
{
  protected :

    // Attribute to identify the simulation engine type
    eTypeSimEng    m_eSimEng;

    // Error message generated by bValidate( )
    wxString       m_osErrMsg;

    // Function to extract information from the circuit description
    virtual  bool  bLoadSimEng ( void ) = 0;
    virtual  bool  bLoadSimCmds( void ) = 0;
    virtual  bool  bLoadSigSrc ( void );

    // Functions to save the circuit description to file
             bool  bSaveSigSrc ( void );

  public :

    // The signal source component
    Component      m_oCpntSigSrc;

                   SimnBase( void );
                   SimnBase( const SimnBase & roSimn );
    virtual       ~SimnBase( );

    virtual  bool  bClear     ( void );
    virtual  bool  bClrCmds   ( void ) = 0;
    virtual  bool  bClrTstPts ( void ) = 0;

    virtual  bool  bValidate  ( void ) override;
    virtual  bool  bIsValid   ( void ) override
                                        { return( NetList::bIsValid( ) && m_osErrMsg.IsEmpty( ) ); }

    virtual  bool  bLoad      ( void ) override;
    virtual  bool  bSave      ( void ) override;

    virtual  bool  bSetAnaType( eTypeCmd eAnaType ) = 0;
             void   SetErrMsg ( const wxString & rosErrMsg )
                                                       { if( bIsValid( ) ) m_osErrMsg = rosErrMsg; }

    virtual  bool  bAddTstNode( const wxString & rosNode ) = 0;
    virtual  bool  bAddTstCpnt( const wxString & rosCpnt ) = 0;

                   eTypeSimEng        eGetSimEng  ( void ) const { return( m_eSimEng ); }
    virtual        eTypeCmd           eGetAnaType ( void ) const = 0;
    virtual  const wxArrayString & rosaGetTstNodes( void ) const = 0;
    virtual  const wxArrayString & rosaGetTstCpnts( void ) const = 0;
             const wxString &       rosGetErrMsg  ( void ) const { return( m_osErrMsg ); }

    SimnBase & operator = ( const SimnBase & roSimn );

    virtual  void  Print( const wxString & rosPrefix=wxT("  ") ) override;
};

//**************************************************************************************************

#endif // SIMNBASE_HPP
