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