Commit 7c1ec48e authored by Leigh Stoller's avatar Leigh Stoller

Switch to AUTOLOAD for access methods.

parent cf03a89f
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
package OSinfo; package OSinfo;
use strict; use strict;
use Carp;
use Exporter; use Exporter;
use vars qw(@ISA @EXPORT); use vars qw(@ISA @EXPORT $AUTOLOAD);
@ISA = "Exporter"; @ISA = "Exporter";
@EXPORT = qw ( ); @EXPORT = qw ( );
...@@ -155,34 +156,27 @@ sub LookupRow($$) ...@@ -155,34 +156,27 @@ sub LookupRow($$)
return $self; return $self;
} }
# accessors
sub field($$) { return ((! ref($_[0])) ? -1 : $_[0]->{'OSINFO'}->{$_[1]}); } AUTOLOAD {
sub osname($) { return field($_[0], "osname"); } my $self = $_[0];
sub osid($) { return field($_[0], "osid"); } my $type = ref($self) or croak "$self is not an object";
sub pid($) { return field($_[0], "pid"); } my $name = $AUTOLOAD;
sub gid($) { return field($_[0], "gid"); } $name =~ s/.*://; # strip fully-qualified portion
sub pid_idx($) { return field($_[0], "pid_idx"); }
sub gid_idx($) { return field($_[0], "gid_idx"); } # A DB row proxy method call.
sub creator($) { return field($_[0], "creator"); } if (exists($self->{'OSINFO'}->{$name})) {
sub creator_idx($) { return field($_[0], "creator_idx"); } return $self->{'OSINFO'}->{$name};
sub created($) { return field($_[0], "created"); } }
sub description($) { return field($_[0], "description"); } carp("No such slot '$name' field in class $type");
sub OS($) { return field($_[0], "OS"); } return undef;
sub version($) { return field($_[0], "version"); } }
sub path($) { return field($_[0], "path"); }
sub magic($) { return field($_[0], "magic"); } # Break circular reference someplace to avoid exit errors.
sub machinetype($) { return field($_[0], "machinetype"); } sub DESTROY {
sub osfeatures($) { return field($_[0], "osfeatures"); } my $self = shift;
sub ezid($) { return field($_[0], "ezid"); }
sub shared($) { return field($_[0], "shared"); } $self->{'OSINFO'} = undef;
sub mustclean($) { return field($_[0], "mustclean"); } }
sub op_mode($) { return field($_[0], "op_mode"); }
sub nextosid($) { return field($_[0], "nextosid"); }
sub max_concurrent($) { return field($_[0], "max_concurrent"); }
sub mfs($) { return field($_[0], "mfs"); }
sub reboot_waittime($) { return field($_[0], "reboot_waittime"); }
sub def_parentosid($) { return field($_[0], "def_parentosid"); }
sub protogeni_export($) { return field($_[0], "protogeni_export"); }
# #
# Create a new os_info. This installs the new record in the DB, # Create a new os_info. This installs the new record in the DB,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment