Debian Codegraph @

README

raw
1 Class::Factory - Base class for dynamic factory classes
2 ==========================
3
4 package My::Factory;
5
6 use strict;
7 use base qw( Class::Factory );
8
9 # Add our default types
10
11 My::Factory->add_factory_type( perl => 'My::Factory::Perl' );
12 My::Factory->add_factory_type( blech => 'My::Factory::Blech' );
13
14 # Register optional types
15
16 My::Factory->register_factory_type( java => 'My::Factory::Java' );
17
18 1;
19
20 # Create new objects using the default types
21
22 my $perl_item = My::Factory->new( 'perl', foo => 'bar' );
23 my $blech_item = My::Factory->new( 'blech', foo => 'baz' );
24
25 # Create new object using the optional type; this library is loaded
26 # on the first use
27
28 my $java_item = My::Factory->new( 'java', foo => 'quux' );
29
30 # Adding a new factory type in code
31
32 My::Factory->add_factory_type( custom => 'Other::Custom::Class' );
33 my $custom_object = My::Factory->new( 'custom', this => 'that' );
34
35 # Register a new factory type in code
36
37 My::Factory->register_factory_type( bleededge => 'Other::Customized::Class' );
38 my $edgy_object = My::Factory->new( 'bleededge', this => 'that' );
39
40 # Get a registered class name given it's factory type
41
42 my $registered_class = MyFactory->get_registered_class( 'bleededge' );
43
44 # Remove a factory type
45
46 MyFactory->remove_factory_type('custom');
47
48 # Unregister a factory type
49
50 MyFactory->unregister_factory_type('bleededge');
51
52 See POD for details
53
54 INSTALLATION
55
56 To install this module perform the typical four-part Perl salute:
57
58 perl Makefile.PL
59 make
60 make test
61 make install
62
63 DEPENDENCIES
64
65 None, although this module was written almost entirely under the
66 influence of Weezer.
67
68 get_registered_class() was written under the influence of Phix.
69
70 SIDE-EFFECTS
71
72 May include headache, insomnia, and growth spurts, although a control
73 group given English toffees in place had the same effects.
74
75 COPYRIGHT AND LICENCE
76
77 Copyright (c) 2002-2007 Chris Winters. All rights reserved.
78
79 This library is free software; you can redistribute it and/or modify
80 it under the same terms as Perl itself.
81
82 AUTHORS
83
84 Fred Moyer <[email protected]> is the current maintainer.
85
86 Chris Winters <[email protected]> is the author of Class::Factory.
87
88 Eric Andreychek <[email protected]> also helped out with code,
89 testing and good advice.
90
91 Srdjan Jankovic <[email protected]> contributed the idea for
92 'get_my_factory()' and 'get_my_factory_type()'
93
94 Sebastian Knapp <[email protected]> contributed the idea for
95 'get_registered_class()'
96
97 Marcel Gruenauer <[email protected]> contributed the methods
98 remove_factory_type() and unregister_factory_type().
99