1 | # ------------------------------------------------------------------------------ |
---|
2 | # NAME |
---|
3 | # Fcm::ExtractSrc |
---|
4 | # |
---|
5 | # DESCRIPTION |
---|
6 | # This class is used by the extract system to define the functionalities of a |
---|
7 | # source file (or directory) in a branch. |
---|
8 | # |
---|
9 | # COPYRIGHT |
---|
10 | # (C) Crown copyright Met Office. All rights reserved. |
---|
11 | # For further details please refer to the file COPYRIGHT.txt |
---|
12 | # which you should have received as part of this distribution. |
---|
13 | # ------------------------------------------------------------------------------ |
---|
14 | |
---|
15 | package Fcm::ExtractSrc; |
---|
16 | @ISA = qw(Fcm::Base); |
---|
17 | |
---|
18 | # Standard pragma |
---|
19 | use warnings; |
---|
20 | use strict; |
---|
21 | |
---|
22 | # FCM component modules |
---|
23 | use Fcm::Base; |
---|
24 | |
---|
25 | # List of scalar property methods for this class |
---|
26 | my @scalar_properties = ( |
---|
27 | 'cache', # location of the cache of this file in the current extract |
---|
28 | 'id', # short ID of the branch where this file is from |
---|
29 | 'ignore', # if set to true, ignore this file from this source |
---|
30 | 'pkgname', # package name of this file |
---|
31 | 'rev', # last changed revision/timestamp of this file |
---|
32 | 'uri', # URL/source path of this file |
---|
33 | ); |
---|
34 | |
---|
35 | # ------------------------------------------------------------------------------ |
---|
36 | # SYNOPSIS |
---|
37 | # $obj = Fcm::ExtractSrc->new (%args); |
---|
38 | # |
---|
39 | # DESCRIPTION |
---|
40 | # This method constructs a new instance of the Fcm::ExtractSrc class. See |
---|
41 | # @scalar_properties above for allowed list of properties in the constructor. |
---|
42 | # ------------------------------------------------------------------------------ |
---|
43 | |
---|
44 | sub new { |
---|
45 | my $this = shift; |
---|
46 | my %args = @_; |
---|
47 | my $class = ref $this || $this; |
---|
48 | |
---|
49 | my $self = Fcm::Base->new (%args); |
---|
50 | |
---|
51 | for (@scalar_properties) { |
---|
52 | $self->{$_} = exists $args{$_} ? $args{$_} : undef; |
---|
53 | } |
---|
54 | |
---|
55 | bless $self, $class; |
---|
56 | return $self; |
---|
57 | } |
---|
58 | |
---|
59 | # ------------------------------------------------------------------------------ |
---|
60 | # SYNOPSIS |
---|
61 | # $value = $obj->X; |
---|
62 | # $obj->X ($value); |
---|
63 | # |
---|
64 | # DESCRIPTION |
---|
65 | # Details of these properties are explained in @scalar_properties. |
---|
66 | # ------------------------------------------------------------------------------ |
---|
67 | |
---|
68 | for my $name (@scalar_properties) { |
---|
69 | no strict 'refs'; |
---|
70 | |
---|
71 | *$name = sub { |
---|
72 | my $self = shift; |
---|
73 | |
---|
74 | # Argument specified, set property to specified argument |
---|
75 | if (@_) { |
---|
76 | $self->{$name} = $_[0]; |
---|
77 | } |
---|
78 | |
---|
79 | return $self->{$name}; |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | # ------------------------------------------------------------------------------ |
---|
84 | |
---|
85 | 1; |
---|
86 | |
---|
87 | __END__ |
---|