//+------------------------------------------------------------------+ //| opencl.mqh | //| Copyright 2021, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, MetaQuotes Ltd." #property link "https://www.mql5.com" //+------------------------------------------------------------------+ //| Подключаем библиотеки | //+------------------------------------------------------------------+ #include //+------------------------------------------------------------------+ //| Class CMyOpenCL | //| Назначение: Класс организации работы с контекстом OpenCL | //+------------------------------------------------------------------+ class CMyOpenCL : public COpenCL { public: CMyOpenCL(void) {}; ~CMyOpenCL(void) {}; template int AddBufferFromArray(T &data[],const uint data_array_offset,const uint data_array_count,const uint flags); bool CheckBuffer(const int index); }; //+------------------------------------------------------------------+ //| Метод создания буфера в контексте OpenCL | //+------------------------------------------------------------------+ template int CMyOpenCL::AddBufferFromArray(T &data[],const uint data_array_offset,const uint data_array_count,const uint flags) { //--- Поисе свободного элемента в динамическом массиве указателей int result=-1; for(int i=0; i0) { m_buffers_total=ArraySize(m_buffers); result=m_buffers_total-1; m_buffers[result]=INVALID_HANDLE; } else return result; } //--- Создаём буфер в контексте OpenCL if(!BufferFromArray(result,data,data_array_offset,data_array_count,flags)) return -1; //--- return result; } //+------------------------------------------------------------------+ //| Метод проверки действительности указателя на буфер по индексу | //| в динамическом массиве | //+------------------------------------------------------------------+ bool CMyOpenCL::CheckBuffer(const int index) { if(index<0 || index>m_buffers_total) return false; return m_buffers[index]!=INVALID_HANDLE; } //+------------------------------------------------------------------+