annotate lib/IMPL/Config/Descriptor.pm @ 420:df591e3afd10 ref20150831

sync
author cin
date Sat, 25 Feb 2017 22:35:26 +0300
parents 3d24b10dd0d5
children 7798345304bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
1 package IMPL::Config::Descriptor;
413
af8d359ee4cc working on di container
cin
parents: 407
diff changeset
2 use strict;
af8d359ee4cc working on di container
cin
parents: 407
diff changeset
3 use IMPL::Exception();
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
4 use Scalar::Util qw(looks_like_number);
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
5
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
6 sub ACTIVATE_SINGLETON() { 1 }
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
7 sub ACTIVATE_CONTAINER() { 2 }
420
cin
parents: 415
diff changeset
8 sub ACTIVATE_HIERARCHY() { 3 }
cin
parents: 415
diff changeset
9 sub ACTIVATE_CONTEXT() { 4 }
cin
parents: 415
diff changeset
10 sub ACTIVATE_CALL() { 5 }
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
11
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
12 my %activateNames = (
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
13 singleton => ACTIVATE_SINGLETON,
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
14 container => ACTIVATE_CONTAINER,
420
cin
parents: 415
diff changeset
15 hierarchy => ACTIVATE_HIERARCHY,
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
16 context => ACTIVATE_CONTEXT,
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
17 call => ACTIVATE_CALL
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
18 );
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
19
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
20 my %activateNamesLookup = map { $activateNames{$_}, $_ } keys %activateNames;
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21
413
af8d359ee4cc working on di container
cin
parents: 407
diff changeset
22 sub Activate {
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
23 my ( $this, $context ) = @_;
413
af8d359ee4cc working on di container
cin
parents: 407
diff changeset
24 die IMPL::NotImplementedException->new();
af8d359ee4cc working on di container
cin
parents: 407
diff changeset
25 }
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
27 sub ParseActivation {
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
28 my $val = pop @_;
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
29
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
30 return ACTIVATE_CALL unless $val;
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
31
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
32 return grep $_ == $val,
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
33 ACTIVATE_SINGLETON,
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
34 ACTIVATE_CONTAINER,
420
cin
parents: 415
diff changeset
35 ACTIVATE_HIERARCHY,
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
36 ACTIVATE_CONTEXT, ACTIVATE_CALL ? $val : ACTIVATE_CALL
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
37 if looks_like_number($val);
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
38
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
39 return $activateNames{ lc($val) } || ACTIVATE_CALL;
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
40 }
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
41
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
42 sub ActivationToString {
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
43 my $val = pop @_;
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
44
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
45 return ( $val && $activateNamesLookup{$val} ) || '';
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
46 }
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
47
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
48 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
49
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
50 __END__
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
51
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
52 =pod
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
53
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
54 =head1 NAME
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
55
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
56 C<IMPL::Config::Descriptor> - the abstract base types for the service descriptors
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
57
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
58 =head1 SYNOPSIS
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
59
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
60 =begin code
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
61
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
62 package MyDescriptor;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
63
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
64 use IMPL::declare {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
65 base => {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
66 'IMPL::Config::Descriptor' => '@_'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
67 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
68 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
69
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
70 sub Activate {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
71 my ($this,$context) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
72
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
73 my $service = $context->GetService('service');
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
74 my
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
75
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
76 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
77
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
78 =end code
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
79
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
80 =head1 MEMBERS
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
81
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
82 =head1 SEE ALSO
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
83
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
84 =over
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
85
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
86 =item * L<ReferenceDescriptor> - describes a reference to the service
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
87
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
88 =item * L<ServiceDescriptor> - descibes a service factory
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
89
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
90 =item * L<ValueDescriptor> - describes a value
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
91
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
92 =back
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
93
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
94 =cut