Mercurial > pub > Impl
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 |
rev | line source |
---|---|
407 | 1 package IMPL::Config::Descriptor; |
413 | 2 use strict; |
3 use IMPL::Exception(); | |
415 | 4 use Scalar::Util qw(looks_like_number); |
5 | |
6 sub ACTIVATE_SINGLETON() { 1 } | |
7 sub ACTIVATE_CONTAINER() { 2 } | |
420 | 8 sub ACTIVATE_HIERARCHY() { 3 } |
9 sub ACTIVATE_CONTEXT() { 4 } | |
10 sub ACTIVATE_CALL() { 5 } | |
415 | 11 |
12 my %activateNames = ( | |
421 | 13 singleton => ACTIVATE_SINGLETON, |
14 container => ACTIVATE_CONTAINER, | |
15 hierarchy => ACTIVATE_HIERARCHY, | |
16 context => ACTIVATE_CONTEXT, | |
17 call => ACTIVATE_CALL | |
415 | 18 ); |
19 | |
421 | 20 my %activateNamesLookup = reverse %activateNames; |
407 | 21 |
413 | 22 sub Activate { |
421 | 23 my ( $this, $context ) = @_; |
24 die IMPL::NotImplementedException->new(); | |
413 | 25 } |
407 | 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 | 35 sub ParseActivation { |
421 | 36 my $val = pop @_; |
415 | 37 |
421 | 38 return ACTIVATE_CALL unless $val; |
415 | 39 |
421 | 40 return grep( $_ == $val, |
41 ACTIVATE_SINGLETON, | |
42 ACTIVATE_CONTAINER, | |
43 ACTIVATE_HIERARCHY, | |
44 ACTIVATE_CONTEXT, ACTIVATE_CALL ) ? $val : ACTIVATE_CALL | |
45 if looks_like_number($val); | |
415 | 46 |
421 | 47 return $activateNames{ lc($val) } || ACTIVATE_CALL; |
415 | 48 } |
49 | |
50 sub ActivationToString { | |
421 | 51 my $val = pop @_; |
415 | 52 |
421 | 53 return ( $val && $activateNamesLookup{$val} ) || ''; |
415 | 54 } |
407 | 55 |
56 1; | |
57 | |
58 __END__ | |
59 | |
60 =pod | |
61 | |
62 =head1 NAME | |
63 | |
64 C<IMPL::Config::Descriptor> - the abstract base types for the service descriptors | |
65 | |
66 =head1 SYNOPSIS | |
67 | |
68 =begin code | |
69 | |
70 package MyDescriptor; | |
71 | |
72 use IMPL::declare { | |
73 base => { | |
74 'IMPL::Config::Descriptor' => '@_' | |
75 } | |
76 }; | |
77 | |
78 sub Activate { | |
79 my ($this,$context) = @_; | |
80 | |
81 my $service = $context->GetService('service'); | |
82 my | |
83 | |
84 } | |
85 | |
86 =end code | |
87 | |
88 =head1 MEMBERS | |
89 | |
90 =head1 SEE ALSO | |
91 | |
92 =over | |
93 | |
94 =item * L<ReferenceDescriptor> - describes a reference to the service | |
95 | |
96 =item * L<ServiceDescriptor> - descibes a service factory | |
97 | |
98 =item * L<ValueDescriptor> - describes a value | |
99 | |
100 =back | |
101 | |
415 | 102 =cut |