//
//  Copyright © 2001 - 2002, RESON Inc. All Rights Reserved.
//
//  No part of this file may be reproduced or transmitted in any form or by
//  any means, electronic or mechanical, including photocopy, recording, or
//  information storage or retrieval system, without permission in writing
//  from RESON Inc.
//
//  Filename:   SystemMonitor.h
//
//  Project:    6046
//
//  Author(s):  W. Arcus
//
//  Purpose:    
//
//  Notes:      
//

#if !defined(AFX_SYSTEMMONITOR_H__59CDE6D8_4C7A_41C0_ADC4_AC812FCA41B9__INCLUDED_)
#define AFX_SYSTEMMONITOR_H__59CDE6D8_4C7A_41C0_ADC4_AC812FCA41B9__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Timer.h"

typedef bool (* PFN_SYSTEM_CHECK ) ( void *pvParam, CString *pMessage, const bool &rbReportOnly );

class CSystemMonitor
{
public:

    //////////////
    // Services.
                        CSystemMonitor              (   void );
    virtual            ~CSystemMonitor              (   void );

    bool                IsEnabled                   (   void ) const;

    bool                Configure                   (   PFN_SYSTEM_CHECK        pfnPerformSystemCheck,
                                                        void                   *pvParam );

    bool                CheckSystemAndReSchedule    (   void );

    void                Set                         (   const bool             &rbEnable,
                                                        const unsigned long    &rulPeriodMilliseconds,
                                                        const bool             &rbUpdateRegistry );

    void                Enable                      (   const bool             &rbEnable );

                        operator HANDLE             (   void )  const;

private:

    //////////////
    // Attributes.

    CTimer              m_Timer;

    bool                m_bEnabled;
    unsigned long       m_ulAutoHealthCheckPeriod;

    PFN_SYSTEM_CHECK    m_pfnPerformSystemCheck;
    void               *m_pvParam;

    //////////////
    // Services.

    void                RestoreFromRegistry         (   void );
    void                SaveToRegistry              (   void );

    void                ScheduleNextSystemCheck     (   const unsigned long    &rulPeriodInMilliseconds );

};

#endif // !defined(AFX_SYSTEMMONITOR_H__59CDE6D8_4C7A_41C0_ADC4_AC812FCA41B9__INCLUDED_)
