1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
typedef cl_int (*cfi)(void*, cl_uint, size_t, void*, size_t*);
template<class T>
T getInfo(cfi func, void *obj, cl_uint name)
{
T tmp { T() };
cl_int status = func(obj, name, sizeof(tmp), &tmp, 0);
if (status == CL_SUCCESS || status == CL_INVALID_VALUE) return tmp;
else throw Exception(status);
}
template <class Holder, class Info, cfi Func>
struct StructureInfo
{
Holder operator*() const { return data; }
template<class T>
T getInfo(Info name) const { return getInfo<T>(Func, data, name); }
protected:
Holder data; //!< Real OpenCL encapsulated structure.
};
struct Platform : public StructureInfo<cl_platform_id, cl_platform_info, (cfi) clGetPlatformInfo>
{
...
|