Use libsigrok C++ bindings (patch version 7).
[pulseview.git] / pv / devicemanager.h
index b7f2d49a7e016ce49e6b66dc0124b17b1779dbb3..0a47a35a004659b09da56ce7545135159a448939 100644 (file)
 #ifndef PULSEVIEW_PV_DEVICEMANAGER_H
 #define PULSEVIEW_PV_DEVICEMANAGER_H
 
-#include <glib.h>
-
 #include <list>
 #include <map>
+#include <memory>
 #include <string>
 
-struct sr_context;
-struct sr_dev_driver;
-struct sr_dev_inst;
+namespace Glib {
+       class VariantBase;
+}
+
+namespace sigrok {
+       class ConfigKey;
+       class Context;
+       class Driver;
+       class Device;
+       class HardwareDevice;
+}
 
 namespace pv {
 
@@ -38,38 +45,34 @@ class SigSession;
 class DeviceManager
 {
 public:
-       DeviceManager(struct sr_context *sr_ctx);
+       DeviceManager(std::shared_ptr<sigrok::Context> context);
 
        ~DeviceManager();
 
-       const std::list<sr_dev_inst*>& devices() const;
-
-       void use_device(sr_dev_inst *sdi, SigSession *owner);
-
-       void release_device(sr_dev_inst *sdi);
+       std::shared_ptr<sigrok::Context> context();
 
-       std::list<sr_dev_inst*> driver_scan(
-               struct sr_dev_driver *const driver,
-               GSList *const drvopts = NULL);
+       const std::list< std::shared_ptr<sigrok::HardwareDevice> >&
+               devices() const;
 
-       static std::string format_device_title(const sr_dev_inst *const sdi);
+       std::list< std::shared_ptr<sigrok::HardwareDevice> > driver_scan(
+               std::shared_ptr<sigrok::Driver> driver,
+               std::map<const sigrok::ConfigKey *, Glib::VariantBase> drvopts);
 
-private:
-       void init_drivers();
-
-       void release_devices();
+       const std::map<std::string, std::string> get_device_info(
+               const std::shared_ptr<sigrok::Device> device);
 
-       void scan_all_drivers();
+       const std::shared_ptr<sigrok::HardwareDevice> find_device_from_info(
+               const std::map<std::string, std::string> search_info);
 
-       void release_driver(struct sr_dev_driver *const driver);
-
-       static bool compare_devices(const sr_dev_inst *const a,
-               const sr_dev_inst *const b);
+       static std::string device_description(std::shared_ptr<sigrok::Device> device);
 
 private:
-       struct sr_context *const _sr_ctx;
-       std::list<sr_dev_inst*> _devices;
-       std::map<sr_dev_inst*, pv::SigSession*> _used_devices;
+       static bool compare_devices(std::shared_ptr<sigrok::HardwareDevice> a,
+               std::shared_ptr<sigrok::HardwareDevice> b);
+
+protected:
+       std::shared_ptr<sigrok::Context> _context;
+       std::list< std::shared_ptr<sigrok::HardwareDevice> > _devices;
 };
 
 } // namespace pv