New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Revision.pm in branches/UKMO/dev_r5021_nn_etau_revision/NEMOGCM/EXTERNAL/fcm/lib/Fcm/Keyword/Loader/Config – NEMO

source: branches/UKMO/dev_r5021_nn_etau_revision/NEMOGCM/EXTERNAL/fcm/lib/Fcm/Keyword/Loader/Config/Revision.pm @ 5448

Last change on this file since 5448 was 5448, checked in by davestorkey, 9 years ago

Clear SVN keywords from UKMO/dev_r5021_nn_etau_revision branch.

File size: 3.0 KB
Line 
1# ------------------------------------------------------------------------------
2# (C) Crown copyright Met Office. All rights reserved.
3# For further details please refer to the file COPYRIGHT.txt
4# which you should have received as part of this distribution.
5# ------------------------------------------------------------------------------
6use strict;
7use warnings;
8
9package Fcm::Keyword::Loader::Config::Revision;
10
11use Fcm::Config;
12
13sub new {
14    my ($class, $args_ref) = @_;
15    return bless({%{$args_ref}}, $class);
16}
17
18################################################################################
19# Returns the namespace where the revision keywords belong
20sub get_namespace {
21    my ($self) = @_;
22    return $self->{namespace};
23}
24
25################################################################################
26# Returns 'Fcm::Config'
27sub get_source {
28    my ($self) = @_;
29    return 'Fcm::Config';
30}
31
32################################################################################
33# Loads revision keywords from Fcm::Config to $entries
34sub load_to {
35    my ($self, $entries) = @_;
36    my $load_counter = 0;
37    my $config = $self->get_source()->instance();
38    my $rev_keyword_ref = $config->setting(
39        qw/URL_REVISION/,
40        uc($self->get_namespace()),
41    );
42    if ($rev_keyword_ref) {
43        for my $key (keys(%{$rev_keyword_ref})) {
44            $entries->add_entry($key, $rev_keyword_ref->{$key});
45            $load_counter++;
46        }
47    }
48    return ($config->is_initialising() ? 0 : defined($load_counter));
49}
50
511;
52__END__
53
54=head1 NAME
55
56Fcm::Keyword::Loader::Config::Revision
57
58=head1 SYNOPSIS
59
60    $loader = Fcm::Keyword::Loader::Config::Revision->new({namespace => $name});
61    $loader->load_to($entries);
62
63=head1 DESCRIPTION
64
65Loads revision keywords from L<Fcm::Config|Fcm::Config> into a
66L<Fcm::Keyword::Entries|Fcm::Keyword::Entries> object containing
67L<Fcm::Keyword::Entry|Fcm::Keyword::Entry> objects.
68
69=head1 METHODS
70
71=over 4
72
73=item C<new({namespace =E<gt> $namespace})>
74
75Constructor. The argument $namespace is the namespace where the revision
76keywords belong.
77
78=item get_namespace()
79
80Returns the namespace where the revision keywords belong.
81
82=item get_source()
83
84Returns the string "L<Fcm::Config|Fcm::Config>".
85
86=item load_to($entries)
87
88Loads revision keywords in the namespace given by C<$self-E<gt>get_namespace()>
89from L<Fcm::Config|Fcm::Config> to $entries. Returns true on success. (However,
90if L<Fcm::Config|Fcm::Config> is initialising, returns false to force a reload
91next time.)
92
93=back
94
95=head1 SEE ALSO
96
97L<Fcm::Config|Fcm::Config>,
98L<Fcm::Keyword|Fcm::Keyword>,
99L<Fcm::Keyword::Entries|Fcm::Keyword::Entries>,
100L<Fcm::Keyword::Entry|Fcm::Keyword::Entry>,
101L<Fcm::Keyword::Entry::Location|Fcm::Keyword::Entry::Location>,
102L<Fcm::Keyword::Loader|Fcm::Keyword::Loader>,
103L<Fcm::Keyword::Loader::Config::Location|Fcm::Keyword::Loader::Config::Location>
104L<Fcm::Keyword::Loader::VC::Revision|Fcm::Keyword::Loader::VC::Revision>
105
106=head1 COPYRIGHT
107
108E<169> Crown copyright Met Office. All rights reserved.
109
110=cut
Note: See TracBrowser for help on using the repository browser.