summaryrefslogtreecommitdiff
path: root/device.cc
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2019-01-13 12:04:31 +0100
committerRobin Krahl <me@robin-krahl.de>2019-01-13 13:26:53 +0100
commit14635f49813df1699569d3b13456ea33955de54b (patch)
tree929f82436e1e7b77865b3e408ea79155cf68591a /device.cc
parent1751759356bd64cc78f8f71543c3edd5cdce8376 (diff)
downloadlibnitrokey-14635f49813df1699569d3b13456ea33955de54b.tar.gz
libnitrokey-14635f49813df1699569d3b13456ea33955de54b.tar.bz2
Add Device::create static method
The method makes it easier to create a std::shared_ptr<Device> from a model enum instance.
Diffstat (limited to 'device.cc')
-rw-r--r--device.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/device.cc b/device.cc
index 58dc0e5..aabcbfc 100644
--- a/device.cc
+++ b/device.cc
@@ -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);