use strict;
use warnings;
+require Exporter;
+use vars qw(@ISA @EXPORT $TYPE_BOOL $TYPE_TAG $TYPE_ARTIST $TYPE_ALBUM $TYPE_FILE);
+@ISA=qw(Exporter);
+@EXPORT=qw($TYPE_BOOL $TYPE_TAG $TYPE_ARTIST $TYPE_ALBUM $TYPE_FILE);
+($TYPE_BOOL, $TYPE_TAG, $TYPE_ARTIST, $TYPE_ALBUM, $TYPE_FILE)=(1..5);
+
sub new
{
my $proto=shift;
$self->{type}=shift;
$self->{name}=shift;
$self->{parents_id}=shift;
- if($self->{type} ne "boolean")
+ if($self->{type} != $TYPE_BOOL)
{
- my $table=ucfirst($self->{type});
- $table .= "s" unless($table=~/s$/);
+ my $table='';
+ if ($self->{type} == $TYPE_TAG) { $table="tags"; }
+ elsif($self->{type} == $TYPE_ARTIST) { $table="artists"; }
+ elsif($self->{type} == $TYPE_ALBUM) { $table="albums"; }
+ elsif($self->{type} == $TYPE_FILE) { $table="files"; }
$self->{id}=$db->lookup_id($table, $self->{name}, $self->{parents_id});
return undef unless(defined($self->{id}));
}
@outjoins = @joins = ("INNER");
}
- if($self->type() ne "boolean")
+ if($self->type() != $TYPE_BOOL)
{
my $cnt=scalar(@joins)+1;
$str .= "t" . scalar(@joins) . ".id='" . $self->{id} . "'";
sub used_tags
{
my($self)=@_;
- if($self->type() eq "boolean")
+ if($self->type() == $TYPE_BOOL)
{
my @used=();
push(@used, $self->left()->used_tags()) if($self->left());