source: LMDZ6/branches/Amaury_dev/tools/fcm/lib/FCM1/ExtractSrc.pm @ 5099

Last change on this file since 5099 was 5095, checked in by abarral, 4 months ago

Revert cosp*/ from the trunk, as it's external code
Add missing bits from FCM2 source

File size: 2.9 KB
Line 
1# ------------------------------------------------------------------------------
2# Copyright (C) 2006-2021 British Crown (Met Office) & Contributors.
3#
4# This file is part of FCM, tools for managing and building source code.
5#
6# FCM is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# FCM is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with FCM. If not, see <http://www.gnu.org/licenses/>.
18# ------------------------------------------------------------------------------
19# NAME
20#   FCM1::ExtractSrc
21#
22# DESCRIPTION
23#   This class is used by the extract system to define the functionalities of a
24#   source file (or directory) in a branch.
25#
26# ------------------------------------------------------------------------------
27
28package FCM1::ExtractSrc;
29@ISA = qw(FCM1::Base);
30
31# Standard pragma
32use warnings;
33use strict;
34
35# FCM component modules
36use FCM1::Base;
37
38# List of scalar property methods for this class
39my @scalar_properties = (
40  'cache',   # location of the cache of this file in the current extract
41  'id',      # short ID of the branch where this file is from
42  'ignore',  # if set to true, ignore this file from this source
43  'pkgname', # package name of this file
44  'rev',     # last changed revision/timestamp of this file
45  'uri',     # URL/source path of this file
46);
47
48# ------------------------------------------------------------------------------
49# SYNOPSIS
50#   $obj = FCM1::ExtractSrc->new (%args);
51#
52# DESCRIPTION
53#   This method constructs a new instance of the FCM1::ExtractSrc class. See
54#   @scalar_properties above for allowed list of properties in the constructor.
55# ------------------------------------------------------------------------------
56
57sub new {
58  my $this  = shift;
59  my %args  = @_;
60  my $class = ref $this || $this;
61
62  my $self = FCM1::Base->new (%args);
63
64  for (@scalar_properties) {
65    $self->{$_} = exists $args{$_} ? $args{$_} : undef;
66  }
67
68  bless $self, $class;
69  return $self;
70}
71
72# ------------------------------------------------------------------------------
73# SYNOPSIS
74#   $value = $obj->X;
75#   $obj->X ($value);
76#
77# DESCRIPTION
78#   Details of these properties are explained in @scalar_properties.
79# ------------------------------------------------------------------------------
80
81for my $name (@scalar_properties) {
82  no strict 'refs';
83
84  *$name = sub {
85    my $self = shift;
86
87    # Argument specified, set property to specified argument
88    if (@_) {
89      $self->{$name} = $_[0];
90    }
91
92    return $self->{$name};
93  }
94}
95
96# ------------------------------------------------------------------------------
97
981;
99
100__END__
Note: See TracBrowser for help on using the repository browser.