/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef _SCENARIO_ENGINE_DATA_HANDLER_H_ #define _SCENARIO_ENGINE_DATA_HANDLER_H_ #include "ScenarioEngineBaseDataHandler.h" #include "ScenarioEngineUtils.h" #define BASE_EXECUTION_COUNT 5 namespace ScenarioEngine { template class ScenarioDataHandler : public BaseDataHandler { public: ScenarioDataHandler(ScenarioDataType* testDataArray, unsigned int testDataArrayLength); virtual ~ScenarioDataHandler(); unsigned int getScenarioRunsNumber(unsigned int testNumber) const; int runScenario(unsigned int subScenarioNumber, THostAppServices& hostAppService); int runScenario(unsigned int testNumber, unsigned int runNumber, THostAppServices& hostAppService); using BaseDataHandler::runScenario; protected: virtual int runScenarioImpl(const ScenarioDataType& testData, unsigned int runNumber, THostAppServices& hostAppService) = 0; virtual int runScenarioImpl(const ScenarioDataType& testData, THostAppServices& hostAppService); }; template class PerfScenarioDataHandler : public ScenarioDataHandler { public: PerfScenarioDataHandler(ScenarioDataType* testDataArray, unsigned int testDataArrayLength); virtual ~PerfScenarioDataHandler(); void setPerfIterationsCount(unsigned int perfIterationCount); unsigned int getPerfIterationsCount(); private: unsigned int m_perfIterationCount = BASE_EXECUTION_COUNT; }; } namespace ScenarioEngine { template ScenarioDataHandler::ScenarioDataHandler(ScenarioDataType* testDataArray, unsigned int testDataArrayLength) : BaseDataHandler(testDataArray, testDataArrayLength) { } template ScenarioDataHandler::~ScenarioDataHandler() { } template unsigned int ScenarioDataHandler::getScenarioRunsNumber(unsigned int testNumber) const { if (testNumber >= ScenarioDataHandler::m_testDataCollection.size()) { return static_cast (-1); } return ScenarioDataHandler::m_testDataCollection[testNumber].runsNum; } template int ScenarioDataHandler::runScenario(unsigned int subScenarioNumber, THostAppServices& hostAppService) { unsigned int currentScenarioNumber = 0; typename std::vector::iterator nextDataIterator = ScenarioDataHandler::m_testDataCollection.begin(); for (; nextDataIterator != ScenarioDataHandler::m_testDataCollection.end(); ++nextDataIterator) { if ((currentScenarioNumber < subScenarioNumber) && (subScenarioNumber <= currentScenarioNumber + (*nextDataIterator).runsNum)) { return runScenarioImpl(*nextDataIterator, subScenarioNumber - currentScenarioNumber - 1, hostAppService); } currentScenarioNumber += (*nextDataIterator).runsNum; } printConsoleString(L"END_OF_TESTS_REACHED\n"); return 0; } template int ScenarioDataHandler::runScenario(unsigned int testNumber, unsigned int runNumber, THostAppServices& hostAppService) { if (ScenarioDataHandler::m_testDataCollection.size() < testNumber) { return -1; } const ScenarioDataType& testData = ScenarioDataHandler::m_testDataCollection[testNumber]; if (testData.runsNum < runNumber) { return -1; } return runScenarioImpl(testData, runNumber, hostAppService); } template int ScenarioDataHandler::runScenarioImpl(const ScenarioDataType& testData, THostAppServices& hostAppService) { int result = 0; for (unsigned int runIndex = 0; runIndex < testData.runsNum; ++runIndex) { int currentResult = runScenarioImpl(testData, runIndex, hostAppService); if (currentResult != 0) { result = currentResult; } } return result; } template PerfScenarioDataHandler::PerfScenarioDataHandler(ScenarioDataType* testDataArray, unsigned int testDataArrayLength) : ScenarioDataHandler(testDataArray, testDataArrayLength) { } template PerfScenarioDataHandler::~PerfScenarioDataHandler() { } template void PerfScenarioDataHandler::setPerfIterationsCount(unsigned int perfIterationCount) { m_perfIterationCount = perfIterationCount; } template unsigned int PerfScenarioDataHandler::getPerfIterationsCount() { return m_perfIterationCount; } } #endif