1 | # ------------------------------------------------------------------------------ |
---|
2 | # (C) British Crown Copyright 2006-17 Met Office. |
---|
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 | use strict; |
---|
20 | use warnings; |
---|
21 | # ------------------------------------------------------------------------------ |
---|
22 | package FCM::Context::Make::Share::Property; |
---|
23 | use base qw{FCM::Class::HASH}; |
---|
24 | |
---|
25 | use constant { |
---|
26 | CTX_VALUE => 'FCM::Context::Make::Share::Property::Value', |
---|
27 | NS_OF_ROOT => q{}, |
---|
28 | }; |
---|
29 | |
---|
30 | __PACKAGE__->class({ctx_of => '%', id => '$'}); |
---|
31 | |
---|
32 | sub get_ctx { |
---|
33 | $_[0]->get_ctx_of(NS_OF_ROOT); |
---|
34 | } |
---|
35 | |
---|
36 | sub set_ctx { |
---|
37 | $_[0]->get_ctx_of()->{$_[0]->NS_OF_ROOT} = $_[1]; |
---|
38 | } |
---|
39 | |
---|
40 | # ------------------------------------------------------------------------------ |
---|
41 | package FCM::Context::Make::Share::Property::Value; |
---|
42 | use base qw{FCM::Class::HASH}; |
---|
43 | |
---|
44 | __PACKAGE__->class({inherited => '$', value => '$'}); |
---|
45 | |
---|
46 | # ------------------------------------------------------------------------------ |
---|
47 | 1; |
---|
48 | __END__ |
---|
49 | |
---|
50 | =head1 NAME |
---|
51 | |
---|
52 | FCM::Context::Make::Share::Property |
---|
53 | |
---|
54 | =head1 SYNOPSIS |
---|
55 | |
---|
56 | use FCM::Context::Make::Share::Property; |
---|
57 | $prop = FCM::Context::Make::Share::Property->new(\%attrib); |
---|
58 | |
---|
59 | =head1 DESCRIPTION |
---|
60 | |
---|
61 | Provides a context object to store the property of a named shell command. |
---|
62 | |
---|
63 | =head1 OBJECTS |
---|
64 | |
---|
65 | The classes described below are all sub-classes of |
---|
66 | L<FCM::Class::HASH|FCM::Class::HASH>. |
---|
67 | |
---|
68 | =head2 FCM::Context::Make::Share::Property |
---|
69 | |
---|
70 | This class represents a property. It has the following attributes: |
---|
71 | |
---|
72 | =over 4 |
---|
73 | |
---|
74 | =item ctx_of |
---|
75 | |
---|
76 | A HASH to map (keys) the name-spaces to (values) the contexts of this property. |
---|
77 | Expects each context to be an instance of |
---|
78 | L</FCM::Context::Make::Share::Property::Value>. |
---|
79 | |
---|
80 | The context of a simple property is stored in the root (i.e. the empty string) |
---|
81 | name-space. |
---|
82 | |
---|
83 | =item id |
---|
84 | |
---|
85 | The ID of this property. |
---|
86 | |
---|
87 | =back |
---|
88 | |
---|
89 | An instance of FCM::Context::Make::Share::Property has 2 additional methods: |
---|
90 | |
---|
91 | =over 4 |
---|
92 | |
---|
93 | =item $instance->get_ctx() |
---|
94 | |
---|
95 | Shorthand for: |
---|
96 | |
---|
97 | $instance->get_ctx_of(q{}). |
---|
98 | |
---|
99 | =item $instance->set_ctx($ctx) |
---|
100 | |
---|
101 | Shorthand for: |
---|
102 | |
---|
103 | $instance->get_ctx_of()->{q{}} = $ctx. |
---|
104 | |
---|
105 | =back |
---|
106 | |
---|
107 | =head2 FCM::Context::Make::Share::Property::Value |
---|
108 | |
---|
109 | This class represents a property value (associated with a name-space). It has |
---|
110 | the following attributes: |
---|
111 | |
---|
112 | =over 4 |
---|
113 | |
---|
114 | =item inherited |
---|
115 | |
---|
116 | A flag, if true, indicates that this value is inherited. |
---|
117 | |
---|
118 | =item value |
---|
119 | |
---|
120 | The value. |
---|
121 | |
---|
122 | =back |
---|
123 | |
---|
124 | =head1 CONSTANTS |
---|
125 | |
---|
126 | =over 4 |
---|
127 | |
---|
128 | =item FCM::Context::Make::Share::Property->NS_OF_ROOT |
---|
129 | |
---|
130 | The root name-space, an empty string. |
---|
131 | |
---|
132 | =back |
---|
133 | |
---|
134 | =head1 COPYRIGHT |
---|
135 | |
---|
136 | (C) Crown copyright Met Office. All rights reserved. |
---|
137 | |
---|
138 | =cut |
---|