diff options
author | Andreas Rogge <andreas.rogge@bareos.com> | 2022-10-05 11:11:23 +0300 |
---|---|---|
committer | Andreas Rogge <andreas.rogge@bareos.com> | 2022-11-07 19:37:28 +0300 |
commit | 7a8e50f3ea94bc886ba903bee32cabe9b2a0f214 (patch) | |
tree | 228ad81c32501136c99413909b5955d594e439bc | |
parent | bab181fb5e1857f800595631f378312bcc941e11 (diff) |
stored: simplify GetDevice() function in factories
-rw-r--r-- | core/src/stored/backends/droplet_device.cc | 12 | ||||
-rw-r--r-- | core/src/stored/backends/gfapi_device.cc | 12 | ||||
-rw-r--r-- | core/src/stored/backends/unix_fifo_device.cc | 12 | ||||
-rw-r--r-- | core/src/stored/backends/unix_file_device.cc | 12 | ||||
-rw-r--r-- | core/src/stored/backends/unix_tape_device.cc | 12 | ||||
-rw-r--r-- | core/src/stored/sd_backends.cc | 11 | ||||
-rw-r--r-- | core/src/stored/sd_backends.h | 2 |
7 files changed, 9 insertions, 64 deletions
diff --git a/core/src/stored/backends/droplet_device.cc b/core/src/stored/backends/droplet_device.cc index 68d4e0182..b3d3bd0ce 100644 --- a/core/src/stored/backends/droplet_device.cc +++ b/core/src/stored/backends/droplet_device.cc @@ -1029,17 +1029,7 @@ DropletDevice::~DropletDevice() class Backend : public BackendInterface { public: - Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override - { - switch (device_type) { - case DeviceType::B_DROPLET_DEV: - return new DropletDevice; - default: - Jmsg(jcr, M_FATAL, 0, _("Request for unknown devicetype: %d\n"), - device_type); - return nullptr; - } - } + Device* GetDevice() override { return new DropletDevice; } }; #ifdef HAVE_DYNAMIC_SD_BACKENDS diff --git a/core/src/stored/backends/gfapi_device.cc b/core/src/stored/backends/gfapi_device.cc index 214754074..7b866eb5c 100644 --- a/core/src/stored/backends/gfapi_device.cc +++ b/core/src/stored/backends/gfapi_device.cc @@ -577,17 +577,7 @@ gfapi_device::gfapi_device() class Backend : public BackendInterface { public: - Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override - { - switch (device_type) { - case DeviceType::B_GFAPI_DEV: - return new gfapi_device; - default: - Jmsg(jcr, M_FATAL, 0, _("Request for unknown devicetype: %d\n"), - device_type); - return nullptr; - } - } + Device* GetDevice() override { return new gfapi_device; } }; # ifdef HAVE_DYNAMIC_SD_BACKENDS diff --git a/core/src/stored/backends/unix_fifo_device.cc b/core/src/stored/backends/unix_fifo_device.cc index c2927d429..612b52291 100644 --- a/core/src/stored/backends/unix_fifo_device.cc +++ b/core/src/stored/backends/unix_fifo_device.cc @@ -317,17 +317,7 @@ bool unix_fifo_device::d_truncate(DeviceControlRecord*) { return true; } class Backend : public BackendInterface { public: - Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override - { - switch (device_type) { - case DeviceType::B_FIFO_DEV: - return new unix_fifo_device; - default: - Jmsg(jcr, M_FATAL, 0, _("Request for unknown devicetype: %d\n"), - device_type); - return nullptr; - } - } + Device* GetDevice() override { return new unix_fifo_device; } }; #ifdef HAVE_DYNAMIC_SD_BACKENDS diff --git a/core/src/stored/backends/unix_file_device.cc b/core/src/stored/backends/unix_file_device.cc index 048f0417b..5bf95f40d 100644 --- a/core/src/stored/backends/unix_file_device.cc +++ b/core/src/stored/backends/unix_file_device.cc @@ -313,17 +313,7 @@ bail_out: class Backend : public BackendInterface { public: - Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override - { - switch (device_type) { - case DeviceType::B_FILE_DEV: - return new unix_file_device; - default: - Jmsg(jcr, M_FATAL, 0, _("Request for unknown devicetype: %d\n"), - device_type); - return nullptr; - } - } + Device* GetDevice() override { return new unix_file_device; } }; #ifdef HAVE_DYNAMIC_SD_BACKENDS diff --git a/core/src/stored/backends/unix_tape_device.cc b/core/src/stored/backends/unix_tape_device.cc index e0cfb8844..b7b62f771 100644 --- a/core/src/stored/backends/unix_tape_device.cc +++ b/core/src/stored/backends/unix_tape_device.cc @@ -61,17 +61,7 @@ unix_tape_device::unix_tape_device() class Backend : public BackendInterface { public: - Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) override - { - switch (device_type) { - case DeviceType::B_TAPE_DEV: - return new unix_tape_device; - default: - Jmsg(jcr, M_FATAL, 0, _("Request for unknown devicetype: %d\n"), - device_type); - return nullptr; - } - } + Device* GetDevice() override { return new unix_tape_device; } }; #ifdef HAVE_DYNAMIC_SD_BACKENDS diff --git a/core/src/stored/sd_backends.cc b/core/src/stored/sd_backends.cc index 1687cb35e..6f3aadb17 100644 --- a/core/src/stored/sd_backends.cc +++ b/core/src/stored/sd_backends.cc @@ -85,10 +85,7 @@ struct BackendDeviceLibraryDescriptor { return *this; } - Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) - { - return backend_interface->GetDevice(jcr, device_type); - } + Device* GetDevice() { return backend_interface->GetDevice(); } }; const std::map<DeviceType, const char*> device_type_to_name_mapping @@ -131,9 +128,7 @@ Device* InitBackendDevice(JobControlRecord* jcr, DeviceType device_type) } for (const auto& b : loaded_backends) { - if (b->device_type == device_type) { - return b->GetDevice(jcr, device_type); - } + if (b->device_type == device_type) { return b->GetDevice(); } } t_backend_base GetBackend{nullptr}; @@ -204,7 +199,7 @@ Device* InitBackendDevice(JobControlRecord* jcr, DeviceType device_type) auto b = std::make_unique<BackendDeviceLibraryDescriptor>( device_type, dynamic_library_handle, GetBackend()); - Device* d = b->GetDevice(jcr, device_type); + Device* d = b->GetDevice(); loaded_backends.push_back(std::move(b)); return d; } diff --git a/core/src/stored/sd_backends.h b/core/src/stored/sd_backends.h index b61ff4a7e..b16681246 100644 --- a/core/src/stored/sd_backends.h +++ b/core/src/stored/sd_backends.h @@ -33,7 +33,7 @@ namespace storagedaemon { class BackendInterface { public: virtual ~BackendInterface() = default; - virtual Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) = 0; + virtual Device* GetDevice() = 0; }; |