File: Generic.pm

package info (click to toggle)
systemconfigurator 2.0.10-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 724 kB
  • ctags: 313
  • sloc: perl: 7,423; makefile: 48
file content (99 lines) | stat: -rw-r--r-- 2,520 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package Time::Zone::Generic;

#   $Id: Generic.pm,v 1.4 2003/01/19 23:26:21 sdague Exp $

#   Copyright (c) 2002 International Business Machines

#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
 
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
 
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#   Sean Dague <sean@dague.net>

use strict;
use Carp;
use Data::Dumper;
use vars qw($VERSION $AUTOLOAD @ISA);

$VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/);

sub new {
    my $class = shift;
    my %this = (
                _root => "",
                _zone => "",
                _utc => "",
                _filesmod => [],
               );
    
    my %config = @_;

    $this{_root} = $config{root};

    foreach my $item (qw(zone utc)) {
        $this{"_" . $item} = $config{"time_" . $item};
    }
    
    bless \%this, $class;
}

sub files {
    my $this = shift;
    if (scalar(@_) > 0) {
        push @{$this->{_filesmod}}, @_;
    }
    return @{$this->filesmod};
}

sub footprint {
    my $this = shift;
    croak("Danger Will Robinson... footprint must be implemented by the subclass!");
}

sub setup {
    my $this = shift;
    croak("Danger Will Robinson... setup must be implemented by the subclass!");
}

sub chroot {
    my $this = shift;
    if (!$this->root) {
        return shift;
    } else {
        my $var = shift;
        return $this->root . $var;
    }
}

sub DESTROY {
    # This makes sure that AUTOLOAD doesn't bitch on trying to call DESTROY
    return 1;
}

# Default Autoloader.  Means we don't have to define accessors for private data.
# This can probably be made more efficient through method caching, but
# I haven't gotten arround to it yet.

sub AUTOLOAD {
    my ($this) = @_;
    $AUTOLOAD =~ /.*::(\w+)/
      or croak("No such method: $AUTOLOAD");
    my $var = $1;

    exists $this->{"_$var"}
      or croak("No such method: $AUTOLOAD");
    
    return $this->{"_$var"};
}

42;