1 |
#____________________________________________________________________
|
2 |
# File: ToolCache.pm
|
3 |
#____________________________________________________________________
|
4 |
#
|
5 |
# Author: Shaun Ashby <Shaun.Ashby@cern.ch>
|
6 |
# Copyright: 2003 (C) Shaun Ashby
|
7 |
#
|
8 |
#--------------------------------------------------------------------
|
9 |
package BuildSystem::ToolCache;
|
10 |
require 5.004;
|
11 |
|
12 |
use Exporter;
|
13 |
@ISA=qw(Exporter);
|
14 |
#
|
15 |
sub new()
|
16 |
{
|
17 |
my $proto=shift;
|
18 |
my $class=ref($proto) || $proto;
|
19 |
my $self={};
|
20 |
$self->{SETUP}={};
|
21 |
bless $self,$class;
|
22 |
return $self;
|
23 |
}
|
24 |
|
25 |
sub setup()
|
26 |
{
|
27 |
my $self=shift;
|
28 |
return $self->{SETUP};
|
29 |
}
|
30 |
|
31 |
sub name()
|
32 |
{
|
33 |
my $self = shift;
|
34 |
# Set the name of the cache file:
|
35 |
@_ ? $self->{CACHENAME} = shift #
|
36 |
: $self->{CACHENAME};
|
37 |
}
|
38 |
|
39 |
sub dirty()
|
40 |
{
|
41 |
my $self = shift;
|
42 |
$self->{internal}{dirty}=1;
|
43 |
}
|
44 |
|
45 |
sub isdirty()
|
46 |
{
|
47 |
my $self = shift;
|
48 |
my $dirty = $self->{internal}{dirty} || 0;
|
49 |
return $dirty;
|
50 |
}
|
51 |
|
52 |
sub writecache()
|
53 |
{
|
54 |
my $self=shift;
|
55 |
if (exists $self->{internal}{dirty})
|
56 |
{
|
57 |
my $file=$self->{CACHENAME};
|
58 |
delete $self->{internal};
|
59 |
use Cache::CacheUtilities;
|
60 |
&Cache::CacheUtilities::write($self,$file);
|
61 |
}
|
62 |
}
|
63 |
|
64 |
1;
|
65 |
|