////////////////////////////////////////////////////////////////////////////////////////
// File: AxeCore.h
//
// Abstract: This file contains definitions that are shared between the AXE Hosting and
// Runtime roles.
//
// (c) Microsoft. All rights reserved.
////////////////////////////////////////////////////////////////////////////////////////


#if defined( _MSC_VER )
#pragma once
#endif  // _MSC_VER

#if !defined( AXECORE_H )
#define AXECORE_H

#if NTDDI_VERSION >= NTDDI_WIN7

// This file is only for C++ clients. C is not supported.
//
#if !defined( __cplusplus )
#error C++ compiler required
#endif  // C++


////////////////////////////////////////////////////////////////////////////////////////
// Include files
////////////////////////////////////////////////////////////////////////////////////////

#include <Windows.h>  // for HRESULT
#include <Unknwn.h>  // for IUnknown
#include <AxeError.h>  // for AXE errors


// These common AXE definitions that are used in both the Solution and Assessment APIs
// exist in the Microsoft::Assessments namespace.
//
namespace Microsoft { namespace Assessments
{
    namespace Hosting
    {
        struct Assessment;
    }

    ////////////////////////////////////////////////////////////////////////////////////////
    // Enumerations
    ////////////////////////////////////////////////////////////////////////////////////////

    enum AxeProgressType
    {
        ProgressTypeNone = 0,  // always first
        ProgressTypePercent,
        ProgressTypeMessage,
        ProgressTypeHeartbeat,
        ProgressTypeIncrement,
        ProgressTypeCancelling,
        ProgressTypeRemainingTime,
        ProgressTypeWaitingForInput,
        ProgressTypeOnOff,
        ProgressTypeWarning,
        ProgressTypeError,
        ProgressTypeTestCase,
        ProgressTypeIdle,
        ProgressTypeInvalid  // always last
    };

    namespace OnOffProgressValue { enum OnOffProgressValue
    {
        None = 0,  // always first
        NotifyOnly = 0,
        CancelNotification,
        FastStartup,
        Boot,
        Shutdown,
        RebootCycle,
        Standby,
        Hibernate,
        Max  // always last
    }; }

    enum ProgressIdleValue
    {
        ProgressIdleValueNone = 0,  // always first
        ProgressIdleValueBegin,
        ProgressIdleValueEnd,
        ProgressIdleValueEnterConnectedStandby,
        ProgressIdleValueMax  // always last
    };

    enum IssueType
    {
        IssueTypeNone = 0,  // always first
        IssueTypeInfo,
        IssueTypeWarning,
        IssueTypeError,
        IssueTypeInvalid  // always last
    };


    ////////////////////////////////////////////////////////////////////////////////////////
    // Structures
    ////////////////////////////////////////////////////////////////////////////////////////

    struct AxeErrorInfo
    {
        DWORD Size;
        IssueType Kind;
        HRESULT ErrorValue;
        const WCHAR* Message;
    };

    struct PrerequisiteIssue
    {
        DWORD Size;
        const Hosting::Assessment* Assessment;
        IssueType IssueType;
        LPCWSTR ProgrammaticName;
        LPCWSTR Name;
        LPCWSTR ToolTip;
    };


    ////////////////////////////////////////////////////////////////////////////////////////
    // Interfaces
    ////////////////////////////////////////////////////////////////////////////////////////

    // ErrorList interface
    //
    struct ErrorList : public IUnknown
    {
        virtual HRESULT GetErrorCount(
            _Out_ UINT* count) const = 0;
        virtual HRESULT GetError(
            _In_ UINT errorIndex,
            _Deref_out_ const AxeErrorInfo** error) const = 0;
        virtual ~ErrorList(){}
    };

    // Logging interface
    //
    struct Logging : public IUnknown
    {
        virtual HRESULT LogBeginOperation(
            _In_ UINT operationId,
            _In_opt_z_ LPCWSTR message,
            _In_ _In_range_(0,32768) UINT blobSize,
            _In_opt_bytecount_(blobSize) BYTE* blob) = 0;
        virtual HRESULT LogEndOperation(
            _In_ UINT operationId,
            _In_opt_z_ LPCWSTR message,
            _In_ _In_range_(0,32768) UINT blobSize,
            _In_opt_bytecount_(blobSize) BYTE* blob) = 0;
        virtual HRESULT LogDiscreteOperation(
            _In_ UINT operationId,
            _In_opt_z_ LPCWSTR message,
            _In_ _In_range_(0,32768) UINT blobSize,
            _In_opt_bytecount_(blobSize) BYTE* blob) = 0;
        virtual HRESULT LogErrorCode(
            _In_ HRESULT errorCode) = 0;
        virtual HRESULT LogErrorCode(
            _In_ HRESULT errorCode,
            _In_opt_z_ LPCWSTR message) = 0;
        virtual HRESULT LogErrorCode(
            _In_ HRESULT errorCode,
            _In_opt_z_ _Printf_format_string_ LPCWSTR messageFormat,
            _In_opt_ va_list* messageArguments) = 0;
        virtual HRESULT LogMessage(
            _In_opt_z_ _Printf_format_string_ LPCWSTR message) = 0;
        virtual HRESULT LogMessage(
            _In_opt_z_ _Printf_format_string_ LPCWSTR messageFormat,
            _In_opt_ va_list* messageArguments) = 0;
        virtual HRESULT LogFileVersion(
            _In_opt_z_ LPCWSTR message,
            _In_z_ LPCWSTR fileName,
            _In_opt_z_ LPCWSTR extraInformation) = 0;
        virtual HRESULT FlushLog() = 0;
        virtual ~Logging(){}
    };

    // PrerequisiteCollection interface
    //
    struct PrerequisiteCollection : public IUnknown
    {
        virtual HRESULT GetCount(
            _Out_ INT* count) const = 0;
        virtual HRESULT GetItem(
            _In_ INT index,
            _COM_Outptr_ const PrerequisiteIssue** item) const = 0;
        virtual ~PrerequisiteCollection(){}
    };

} }  // end namespace Microsoft::Assessments


////////////////////////////////////////////////////////////////////////////////////////
// Factory function
////////////////////////////////////////////////////////////////////////////////////////

extern "C" 
{
    #define AXE_COREDLL L"axecore.dll"
}

#endif  // NTDDI_VERSION >= NTDDI_WIN7

#endif  // AXECORE_H
