annotate lib/IMPL/Config/Descriptor.pm @ 422:b0481c071bea ref20150831

IMPL::Config::Container tests, YAMLConfiguration now works and tested
author cin
date Sun, 20 Aug 2017 00:20:41 +0300
parents 7798345304bc
children
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 = (
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
13 singleton => ACTIVATE_SINGLETON,
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
14 container => ACTIVATE_CONTAINER,
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
15 hierarchy => ACTIVATE_HIERARCHY,
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
16 context => ACTIVATE_CONTEXT,
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
17 call => ACTIVATE_CALL
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
18 );
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
19
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
20 my %activateNamesLookup = reverse %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 {
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
23 my ( $this, $context ) = @_;
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
24 die IMPL::NotImplementedException->new();
413
af8d359ee4cc working on di container
cin
parents: 407
diff changeset
25 }
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26
422
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
27 sub services {
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
28
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
29 }
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
30
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
31 sub GetName {
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
32 die IMPL::NotImplementedException->new();
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
33 }
b0481c071bea IMPL::Config::Container tests, YAMLConfiguration now works and tested
cin
parents: 421
diff changeset
34
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
35 sub ParseActivation {
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
36 my $val = pop @_;
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
37
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
38 return ACTIVATE_CALL unless $val;
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
39
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
40 return grep( $_ == $val,
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
41 ACTIVATE_SINGLETON,
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
42 ACTIVATE_CONTAINER,
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
43 ACTIVATE_HIERARCHY,
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
44 ACTIVATE_CONTEXT, ACTIVATE_CALL ) ? $val : ACTIVATE_CALL
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
45 if looks_like_number($val);
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
46
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
47 return $activateNames{ lc($val) } || ACTIVATE_CALL;
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
48 }
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
49
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
50 sub ActivationToString {
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
51 my $val = pop @_;
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
52
421
7798345304bc working on IMPL::Config, removed old stuff
cin
parents: 420
diff changeset
53 return ( $val && $activateNamesLookup{$val} ) || '';
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
54 }
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
55
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
56 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
57
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
58 __END__
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
59
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
60 =pod
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
61
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
62 =head1 NAME
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
63
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
64 C<IMPL::Config::Descriptor> - the abstract base types for the service descriptors
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
65
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
66 =head1 SYNOPSIS
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
67
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
68 =begin code
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
69
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
70 package MyDescriptor;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
71
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
72 use IMPL::declare {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
73 base => {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
74 'IMPL::Config::Descriptor' => '@_'
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 sub Activate {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
79 my ($this,$context) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
80
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
81 my $service = $context->GetService('service');
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
82 my
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
83
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
84 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
85
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
86 =end code
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
87
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
88 =head1 MEMBERS
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
89
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
90 =head1 SEE ALSO
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
91
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
92 =over
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
93
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
94 =item * L<ReferenceDescriptor> - describes a reference to the service
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
95
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
96 =item * L<ServiceDescriptor> - descibes a service factory
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
97
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
98 =item * L<ValueDescriptor> - describes a value
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
99
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
100 =back
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
101
415
3d24b10dd0d5 working on IMPL::Config::Container
cin
parents: 413
diff changeset
102 =cut