class root_resource;
class hard_event;
- class device : public _cl_device_id {
+ class device : public ref_counter, public _cl_device_id {
public:
device(clover::platform &platform, pipe_loader_device *ldev);
device(device &&dev);
using namespace clover;
-platform::platform() {
+platform::platform() : adaptor_range(derefs(), devs) {
int n = pipe_loader_probe(NULL, 0);
std::vector<pipe_loader_device *> ldevs(n);
for (pipe_loader_device *ldev : ldevs) {
try {
- devs.emplace_back(*this, ldev);
+ devs.push_back(transfer(new device(*this, ldev)));
} catch (error &) {}
}
}
#include "core/object.hpp"
#include "core/device.hpp"
+#include "util/range.hpp"
namespace clover {
- class platform : public _cl_platform_id {
+ class platform : public _cl_platform_id,
+ public adaptor_range<
+ derefs, std::vector<ref_ptr<device>> &> {
public:
- typedef std::vector<device>::iterator iterator;
-
platform();
- ///
- /// Container of all compute devices that are available in the platform.
- ///
- /// @{
- iterator begin() {
- return devs.begin();
- }
-
- iterator end() {
- return devs.end();
- }
-
- device &front() {
- return devs.front();
- }
-
- device &back() {
- return devs.back();
- }
- /// @}
-
protected:
- std::vector<device> devs;
+ std::vector<ref_ptr<device>> devs;
};
}