From 3506a829ca48a2b8cb4c7953fe199ed10ef18424 Mon Sep 17 00:00:00 2001 From: Maarten Vanraes Date: Sat, 14 May 2016 17:43:10 +0200 Subject: make a changedpart trigger for loading/probing/saving a part --- lib/ManaTools/Shared/disk_backend.pm | 26 ++++++++++++++++++++++++++ lib/ManaTools/Shared/disk_backend/Part.pm | 7 +++++++ lib/ManaTools/Shared/disk_backend/Plugin.pm | 24 ++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/lib/ManaTools/Shared/disk_backend.pm b/lib/ManaTools/Shared/disk_backend.pm index 223d8082..d42f6499 100644 --- a/lib/ManaTools/Shared/disk_backend.pm +++ b/lib/ManaTools/Shared/disk_backend.pm @@ -336,6 +336,32 @@ sub probe { #============================================================= +=head2 changedpart + +=head3 INPUT + + $part: ManaTools::Shared::disk_backend::Part + $state: PartState (L, P, S) + +=head3 DESCRIPTION + + this method will call changedpart for all plugins, should only be called when a module is done with the changed part + +=cut + +#============================================================= +sub changedpart { + my $self = shift; + my $part = shift; + my $state = shift; + + for my $plugin (@{$self->plugins}) { + $plugin->changedpart($part, $state); + } +} + +#============================================================= + =head2 probeio =head3 OUTPUT diff --git a/lib/ManaTools/Shared/disk_backend/Part.pm b/lib/ManaTools/Shared/disk_backend/Part.pm index 4c293493..c88328ba 100644 --- a/lib/ManaTools/Shared/disk_backend/Part.pm +++ b/lib/ManaTools/Shared/disk_backend/Part.pm @@ -411,6 +411,13 @@ sub mkpart { return $part; } +sub changedpart { + my $self = shift; + my $partstate = shift; + my $db = $self->db(); + return $db->changedpart($self, $partstate); +} + has 'ins' => ( is => 'ro', isa => 'ManaTools::Shared::disk_backend::IOs', diff --git a/lib/ManaTools/Shared/disk_backend/Plugin.pm b/lib/ManaTools/Shared/disk_backend/Plugin.pm index ebd4a02f..7fb3155f 100644 --- a/lib/ManaTools/Shared/disk_backend/Plugin.pm +++ b/lib/ManaTools/Shared/disk_backend/Plugin.pm @@ -189,6 +189,30 @@ sub probe { #============================================================= +=head2 changedpart + +=head3 INPUT + + $part: ManaTools::Shared::disk_backend::Part + $state: PartState (L, P, S) + +=head3 DESCRIPTION + + this is a default method for announcing a changed Part, the idea is to override it if needed + +=cut + +#============================================================= +sub changedpart { + my $self = shift; + my $part = shift; + my $state = shift; + + 1; +} + +#============================================================= + =head2 loadio =head3 INPUT -- cgit v1.2.1