| 1 | # | ||
| 2 | # AI::ExpertSystem::KnowledgeDB::Factory | ||
| 3 | # | ||
| 4 | # Author(s): Pablo Fischer (pfischer@cpan.org) | ||
| 5 | # Created: 11/29/2009 19:12:25 PST 19:12:25 | ||
| 6 | package AI::ExpertSystem::Advanced::KnowledgeDB::Factory; | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | AI::ExpertSystem::Advanced::KnowledgeDB::Factory - Knowledge DB driver factory | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | Uses the factory pattern to create instances of knowledge database drivers. | ||
| 15 | |||
| 16 | =head1 SYNOPSIS | ||
| 17 | |||
| 18 | use AI::ExpertSystem::Advanced::KnowledgeDB::Factory; | ||
| 19 | |||
| 20 | my $yaml_kdb = AI::ExpertSystem::Advanced::KnowledgeDB::Factory->new('yaml', | ||
| 21 | { | ||
| 22 | filename => 'examples/knowledge_db_one.yaml' | ||
| 23 | }); | ||
| 24 | |||
| 25 | =cut | ||
| 26 | use strict; | ||
| 27 | use warnings; | ||
| 28 | use Class::Factory; | ||
| 29 | use base qw(Class::Factory); | ||
| 30 | |||
| 31 | our $VERSION = '0.02'; | ||
| 32 | |||
| 33 | sub new { | ||
| 34 | my ($pkg, $type, @params) = @_; | ||
| 35 | my $class = $pkg->get_factory_class($type); | ||
| 36 | return undef unless ($class); | ||
| 37 | my $self = "$class"->new(@params); | ||
| 38 | return $self; | ||
| 39 | } | ||
| 40 | |||
| 41 | __PACKAGE__->register_factory_type(yaml => | ||
| 42 | 'AI::ExpertSystem::Advanced::KnowledgeDB::YAML'); | ||
| 43 | |||
| 44 | =head1 AUTHOR | ||
| 45 | |||
| 46 | Pablo Fischer (pablo@pablo.com.mx). | ||
| 47 | |||
| 48 | =head1 COPYRIGHT | ||
| 49 | |||
| 50 | Copyright (C) 2010 by Pablo Fischer. | ||
| 51 | |||
| 52 | This library is free software; you can redistribute it and/or modify | ||
| 53 | it under the same terms as Perl itself. | ||
| 54 | |||
| 55 | =cut | ||
| 56 | |||
| 57 | 1; |