1SNMP::Info::MRO(3) User Contributed Perl Documentation SNMP::Info::MRO(3)
2
3
4
6 SNMP::Info::MRO - Method resolution introspection for SNMP::Info
7
9 use SNMP::Info::MRO;
10 use Data::Printer;
11
12 # SNMP::Info::MRO::print_* functions
13 SNMP::Info::MRO::print_superclasses ('SNMP::Info::Layer3::Juniper');
14
15 # print output using Data::Printer for other functions
16 my $buff = SNMP::Info::MRO::all_methods('SNMP::Info::Layer3::Juniper');
17 p $buff;
18
20 This is a set of helpers to show where a given method in SNMP::Info has
21 been implemented, and which implementation is being used at runtime.
22
23 The following distributions are required to run this code:
24
25 • PPI
26
27 • Class::ISA
28
29 • Module::Info
30
31 • Module::Load
32
34 None of the functions are exported. For all helper functions, you can
35 pass either the name of a Perl module, or an object instance of
36 SNMP::Info.
37
38 all_methods( $module )
39 Returns the location of methods defined in $module and all its
40 ancestor classes (superclasses), either as Perl subroutines or via
41 %GLOBALS or %FUNCS configuration. The data structure looks like:
42
43 {
44 method_name => {
45 globals => [
46 [ Package::Name => 'mib_leaf.0' ],
47 [ Other::Package::Name => '1.3.6.1.4.1.9.2.1.58.0' ],
48 ],
49 },
50 other_method_name => [
51 subs => [
52 'Package::Name',
53 ],
54 funcs => [
55 [ Package::Name => 'mib_leaf_name' ],
56 ],
57 ],
58 }
59
60 It should be noted that the order of method resolution in
61 SNMP::Info is to first look for a defined subroutine (this is done
62 by Perl), then the AUTOLOAD sequence will search for a definition
63 in %GLOBALS followed by %FUNCS.
64
65 The defining class or module at runtime is always the first entry
66 in the list, if it exists:
67
68 $data->{method_name}->{subs}->[0]
69 if exists $data->{method_name}->{subs};
70
71 subroutines( $module )
72 Returns the set of subroutines defined in $module and all its
73 ancestor classes (superclasses). The data structure looks like:
74
75 {
76 method_name => [
77 'Package::Name',
78 'Other::Package::Name',
79 ],
80 other_method_name => [
81 'Package::Name',
82 ],
83 }
84
85 Should a subroutine have been defined more than once, the defining
86 classes are listed in reverse order, such that the definition used
87 at runtime is always:
88
89 $data->{method_name}->[0];
90
91 globals( $module || $object )
92 Returns a data structure showing how SNMP::Info will resolve MIB
93 Leaf Nodes configured through the %GLOBALS hashes in $module.
94
95 The data structure looks like:
96
97 {
98 method_name => [
99 [ Package::Name => 'mib_leaf_name' ],
100 [ Other::Package::Name => '1.3.6.1.4.1.9.2.1.58.0' ],
101 ],
102 other_method_name => [
103 [ Package::Name => 'mib_leaf.0' ],
104 ],
105 }
106
107 Where a method has been defined in different packages, then they
108 are listed in reverse order, such that the mapping used by
109 SNMP::Info is always:
110
111 $data->{method_name}->[0];
112
113 funcs( $module || $object )
114 Returns a data structure showing how SNMP::Info will resolve MIB
115 Tables configured through the %FUNCS hashes in $module.
116
117 See "GLOBALS" in SNMP::Info::Layer3 for further detail.
118
119 munge( $module || $object )
120 Returns a data structure showing the subroutines used for munging
121 returned values for any method defined in %FUNCS or %GLOBALS.
122
123 The data structure looks like:
124
125 {
126 method_name => [
127 [ Package::Name => '&subroutine' ],
128 [ Other::Package::Name => '&Other::Package::subroutine' ],
129 ],
130 other_method_name => [
131 [ Package::Name => '&subroutine' ],
132 ],
133 }
134
135 Where a mapping has been defined in different packages, then they
136 are listed in reverse order, such that the munge subroutine used by
137 SNMP::Info is always:
138
139 $data->{method_name}->[0];
140
141 file( $module )
142 Returns the filename from which Perl will load the given module.
143
144 superclasses( $class || $object )
145 Returns the list (in order) of the names of classes Perl will
146 search to find methods for this SNMP::Info class or object
147 instance.
148
149 Note this requires the Class::ISA distribution to be installed.
150
151 print_globals( $module || $object )
152 Pretty print the output of globals().
153
154 print_funcs( $module || $object )
155 Pretty print the output of funcs().
156
157 print_munge( $module || $object )
158 Pretty print the output of munge().
159
160 print_superclasses( $class || $object )
161 Pretty print the output of superclasses().
162
164 Oliver Gorwits <oliver@cpan.org>
165
167 This software is copyright (c) 2014 by The SNMP::Info Project.
168
169 # Redistribution and use in source and binary forms, with or without
170 # modification, are permitted provided that the following conditions are met:
171 #
172 # * Redistributions of source code must retain the above copyright notice,
173 # this list of conditions and the following disclaimer.
174 # * Redistributions in binary form must reproduce the above copyright
175 # notice, this list of conditions and the following disclaimer in the
176 # documentation and/or other materials provided with the distribution.
177 # * Neither the name of the University of California, Santa Cruz nor the
178 # names of its contributors may be used to endorse or promote products
179 # derived from this software without specific prior written permission.
180 #
181 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
182 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
183 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
184 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
185 # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
186 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
187 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
188 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
189 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
190 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
191 # POSSIBILITY OF SUCH DAMAGE.
192
193
194
195perl v5.36.1 2023-07-17 SNMP::Info::MRO(3)