diff options
| -rw-r--r-- | device.cc | 11 | ||||
| -rw-r--r-- | libnitrokey/device.h | 6 | 
2 files changed, 17 insertions, 0 deletions
| @@ -209,6 +209,17 @@ std::vector<DeviceInfo> Device::enumerate(){    return res;  } +std::shared_ptr<Device> Device::create(DeviceModel model) { +  switch (model) { +    case DeviceModel::PRO: +      return std::make_shared<Stick10>(); +    case DeviceModel::STORAGE: +      return std::make_shared<Stick20>(); +    default: +      return {}; +  } +} +  bool Device::could_be_enumerated() {    LOG(__FUNCTION__, Loglevel::DEBUG_L2);    std::lock_guard<std::mutex> lock(mex_dev_com); diff --git a/libnitrokey/device.h b/libnitrokey/device.h index 418d335..eab3888 100644 --- a/libnitrokey/device.h +++ b/libnitrokey/device.h @@ -24,6 +24,7 @@  #include <chrono>  #include "hidapi/hidapi.h"  #include <cstdint> +#include <memory>  #include <string>  #include <vector>  #include "misc.h" @@ -154,6 +155,11 @@ public:     */    static std::vector<DeviceInfo> enumerate(); +  /** +   * Create a Device of the given model. +   */ +  static std::shared_ptr<Device> create(DeviceModel model); +          void show_stats();  //  ErrorCounters get_stats(){ return m_counters; } | 
