← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:14 2015

Filename/var/www/foswikidev/core/lib/Foswiki/Configure/Pluggable.pm
StatementsExecuted 7 statements in 134µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11120µs33µsFoswiki::Configure::Pluggable::::BEGIN@49Foswiki::Configure::Pluggable::BEGIN@49
11110µs14µsFoswiki::Configure::Pluggable::::BEGIN@50Foswiki::Configure::Pluggable::BEGIN@50
1119µs38µsFoswiki::Configure::Pluggable::::BEGIN@52Foswiki::Configure::Pluggable::BEGIN@52
0000s0sFoswiki::Configure::Pluggable::::loadFoswiki::Configure::Pluggable::load
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2
3=begin TML
4
5---+ package Foswiki::Configure::Pluggable
6
7A Pluggable is a code module that generates items for a hard-coded block
8in a configuration, marked by *NAME* in the .spec.
9
10Pluggables are used for blocks in the configuration that cannot be handled
11by the configuration abstraction, for example blocks used for
12downloading extensions, managing plugins, and managing languages.
13
14A pluggable block will normally inject programatically
15generated configuration entries (subclasses of Foswiki::Configure::Item) into
16the configuration, usually by appending to the $open configuration item
17(which will normally be a Foswiki::Configure::Section).
18
19Pluggable implementations are loaded by the parser by calling the
20=load= static method in this class. The implementations are packages
21in Foswiki::Configure::Pluggables, and must provide at least the following
22function:
23
24---++ StaticMethod construct( \@settings, $file, $line )
25
26Implemented by subclasses to create the pluggable. Pluggables are
27created in-place, by generating and adding Foswiki::Configure::Item
28objects and adding them to the settings array.
29
30 * =\@settings= - ref to the top level array of settings
31 * =$file=, =$line= - file and line in the .spec that triggered the pluggable
32
33Note that there is no need for constructors to worry about the hierarchical
34structure of .spec. The structure is only generated after all items have
35been generated, by analysis of section markers placed in the settings array.
36So items should be added by simply pushing them into @$settings. However,
37should a pluggable require a structure within the containing section, it is
38OK to push new =Foswiki::Configure::Section= objects to @$settings and
39populate them using =->addChild=.
40
41Note also that values added by pluggables should *NOT* have defined_at
42set. The presence of this field is used to indicate whether a field was
43defined explicitly, or in a pluggable.
44
45=cut
46
47package Foswiki::Configure::Pluggable;
48
49229µs246µs
# spent 33µs (20+13) within Foswiki::Configure::Pluggable::BEGIN@49 which was called: # once (20µs+13µs) by Foswiki::Configure::LoadSpec::BEGIN@66 at line 49
use strict;
# spent 33µs making 1 call to Foswiki::Configure::Pluggable::BEGIN@49 # spent 13µs making 1 call to strict::import
50224µs218µs
# spent 14µs (10+4) within Foswiki::Configure::Pluggable::BEGIN@50 which was called: # once (10µs+4µs) by Foswiki::Configure::LoadSpec::BEGIN@66 at line 50
use warnings;
# spent 14µs making 1 call to Foswiki::Configure::Pluggable::BEGIN@50 # spent 4µs making 1 call to warnings::import
51
52279µs266µs
# spent 38µs (9+29) within Foswiki::Configure::Pluggable::BEGIN@52 which was called: # once (9µs+29µs) by Foswiki::Configure::LoadSpec::BEGIN@66 at line 52
use Assert;
# spent 38µs making 1 call to Foswiki::Configure::Pluggable::BEGIN@52 # spent 29µs making 1 call to Exporter::import
53
54=begin TML
55
56---++ StaticMethod load($id)
57
58Loads a pluggable section from =Foswiki::Configure::Pluggables::$id=
59
60Will die if there's a problem.
61
62Returns the result from the Pluggable class's =construct=
63
64=cut
65
66sub load {
67 my $name = shift;
68
69 my $modelName = 'Foswiki::Configure::Pluggables::' . $name;
70 eval("require $modelName; ${modelName}::construct(\@_);");
71 die $@ if $@;
72}
73
7412µs1;
75__END__