compute-runtime/unit_tests/helpers/raii_hw_helper.h

32 lines
700 B
C++

/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/helpers/hw_helper.h"
namespace NEO {
extern HwHelper *hwHelperFactory[IGFX_MAX_CORE];
template <class MockHelper>
class RAIIHwHelperFactory {
public:
GFXCORE_FAMILY gfxCoreFamily;
HwHelper *hwHelper;
MockHelper mockHwHelper;
RAIIHwHelperFactory(GFXCORE_FAMILY gfxCoreFamily) {
this->gfxCoreFamily = gfxCoreFamily;
hwHelper = hwHelperFactory[this->gfxCoreFamily];
hwHelperFactory[this->gfxCoreFamily] = &mockHwHelper;
}
~RAIIHwHelperFactory() {
hwHelperFactory[this->gfxCoreFamily] = hwHelper;
}
};
} // namespace NEO