2 # $Id: VDB.pm 757 2007-01-05 10:56:28Z bastian $
4 # Perl module for Kamailio
6 # Copyright (C) 2006 Collax GmbH
7 # (Bastian Friedrich <bastian.friedrich@collax.com>)
9 # This file is part of Kamailio, a free SIP server.
11 # Kamailio is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version
16 # Kamailio is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 This package is an (abstract) base class for all virtual databases. Derived
29 packages can be configured to be used by Kamailio as a database.
31 The base class itself should NOT be used in this context, as it does not
32 provide any functionality.
36 package Kamailio::VDB;
39 use Kamailio::Constants;
41 use Kamailio::VDB::Column;
42 use Kamailio::VDB::Pair;
43 use Kamailio::VDB::ReqCond;
44 use Kamailio::VDB::Result;
45 use Kamailio::VDB::Value;
46 use Kamailio::VDB::VTab;
49 our @ISA = qw ( Kamailio::Utils::Debug );
68 $self->{tablename} = $v;
70 if ($v eq "version") {
71 # "version" table is handled individually. Don't initialize VTabs.
75 if ($self->{vtabs}->{$v}) {
79 if ($v =~ m/^((.*)::)?([\w_][\d\w_]*)$/) {
87 Kamailio::log(L_DBG, "perlvdb:VDB: Setting VTab: v is $v (pkg is $pkg, func/method is $3)\n");
90 $self->{vtabs}->{$v} = new Kamailio::VDB::VTab( func => $pkg . "::" . $3);
91 } elsif ($v->can("init")) {
93 $self->{vtabs}->{$v} = new Kamailio::VDB::VTab( obj => $v );
94 } elsif ($v->can("new")) {
96 $self->{vtabs}->{$v} = new Kamailio::VDB::VTab( obj => $obj );
98 Kamailio::log(L_ERR, "perlvdb:VDB: Invalid virtual table.\n");
102 Kamailio::log(L_ERR, "perlvdb:VDB: Invalid virtual table.\n");
109 return $self->insert(@_);
114 return $self->replace(@_);
119 return $self->delete(@_);
124 return $self->update(@_);
129 return $self->query(@_);
135 Kamailio::log(L_INFO, "perlvdb:Insert not implemented in base class.\n");
140 Kamailio::log(L_INFO, "perlvdb:Replace not implemented in base class.\n");
145 Kamailio::log(L_INFO, "perlvdb:Delete not implemented in base class.\n");
150 Kamailio::log(L_INFO, "perlvdb:Update not implemented in base class.\n");
155 Kamailio::log(L_INFO, "perlvdb:Query not implemented in base class.\n");