| 1 | =head1 NAME | ||
| 2 | |||
| 3 | XAO::DO::FS::Glue::Base - glue base | ||
| 4 | |||
| 5 | =head1 SYNOPSIS | ||
| 6 | |||
| 7 | Should not be used directly. | ||
| 8 | |||
| 9 | =head1 DESCRIPTION | ||
| 10 | |||
| 11 | Provides a basic set of methods all drivers derive from. | ||
| 12 | |||
| 13 | =head1 METHODS | ||
| 14 | |||
| 15 | =over | ||
| 16 | |||
| 17 | =cut | ||
| 18 | |||
| 19 | ############################################################################### | ||
| 20 | package XAO::DO::FS::Glue::Base; | ||
| 21 | use strict; | ||
| 22 | use XAO::Utils; | ||
| 23 | use XAO::Objects; | ||
| 24 | |||
| 25 | use base XAO::Objects->load(objname => 'Atom'); | ||
| 26 | |||
| 27 | use vars qw($VERSION); | ||
| 28 | $VERSION=(0+sprintf('%u.%03u',(q$Id: Base.pm,v 2.1 2007/05/09 21:03:09 am Exp $ =~ /\s(\d+)\.(\d+)\s/))) || die "Bad VERSION"; | ||
| 29 | |||
| 30 | ############################################################################### | ||
| 31 | |||
| 32 | =item connector ($) | ||
| 33 | |||
| 34 | Returns an internal connector object that is used for communicating | ||
| 35 | requests to the database. | ||
| 36 | |||
| 37 | =cut | ||
| 38 | |||
| 39 | sub connector ($) { | ||
| 40 | my $self=shift; | ||
| 41 | my $connector=$self->{'connector'}; | ||
| 42 | if(!$connector) { | ||
| 43 | $self->{'connector'}=$connector=$self->connector_create; | ||
| 44 | } | ||
| 45 | return $connector; | ||
| 46 | } | ||
| 47 | |||
| 48 | ############################################################################### | ||
| 49 | |||
| 50 | =item connector_create ($) | ||
| 51 | |||
| 52 | Pure virtual. Returns an actual implementation of a connector | ||
| 53 | (DBI/direct connect/etc). Receives no connection arguments, should wait | ||
| 54 | for sql_connect before actually connecting to the DB. | ||
| 55 | |||
| 56 | =cut | ||
| 57 | |||
| 58 | sub connector_create ($) { | ||
| 59 | my $self=shift; | ||
| 60 | throw $self "connector_create - pure virtual method"; | ||
| 61 | } | ||
| 62 | |||
| 63 | ############################################################################### | ||
| 64 | |||
| 65 | =item DESTROY ($) | ||
| 66 | |||
| 67 | Calls sql_disconnect on the connector if one was created. | ||
| 68 | |||
| 69 | =cut | ||
| 70 | |||
| 71 | sub DESTROY ($) { | ||
| 72 | my $self=shift; | ||
| 73 | $self->{'connector'}->sql_disconnect() if $self->{'connector'}; | ||
| 74 | } | ||
| 75 | |||
| 76 | ############################################################################### | ||
| 77 | 1; | ||
| 78 | __END__ |