line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package TheSchwartz::FuncMap; |
4
|
24
|
|
|
24
|
|
175
|
use strict; |
|
24
|
|
|
|
|
56
|
|
|
24
|
|
|
|
|
868
|
|
5
|
24
|
|
|
24
|
|
123
|
use base qw( Data::ObjectDriver::BaseObject ); |
|
24
|
|
|
|
|
58
|
|
|
24
|
|
|
|
|
15402
|
|
6
|
|
|
|
|
|
|
|
7
|
24
|
|
|
24
|
|
302870
|
use Carp qw( croak ); |
|
24
|
|
|
|
|
64
|
|
|
24
|
|
|
|
|
4306
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->install_properties( |
10
|
|
|
|
|
|
|
{ columns => [qw( funcid funcname )], |
11
|
|
|
|
|
|
|
datasource => 'funcmap', |
12
|
|
|
|
|
|
|
primary_key => 'funcid', |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub create_or_find { |
17
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
18
|
0
|
|
|
|
|
|
my ( $driver, $funcname ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
## Attempt to select funcmap record by name. If successful, return |
21
|
|
|
|
|
|
|
## object, otherwise proceed with insertion and return. |
22
|
0
|
|
|
|
|
|
my ($map) |
23
|
|
|
|
|
|
|
= $driver->search( |
24
|
|
|
|
|
|
|
'TheSchwartz::FuncMap' => { funcname => $funcname } ); |
25
|
0
|
0
|
|
|
|
|
return $map if $map; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
## Attempt to insert a new funcmap row. Since the funcname column is |
28
|
|
|
|
|
|
|
## UNIQUE, if the row already exists, an exception will be thrown. |
29
|
0
|
|
|
|
|
|
$map = $class->new; |
30
|
0
|
|
|
|
|
|
$map->funcname($funcname); |
31
|
0
|
|
|
|
|
|
eval { $driver->insert($map) }; |
|
0
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
## If we got an exception, try to load the record with this funcname; |
34
|
|
|
|
|
|
|
## in all likelihood, the exception was that the record was added by |
35
|
|
|
|
|
|
|
## another process. |
36
|
0
|
0
|
|
|
|
|
if ( my $err = $@ ) { |
37
|
0
|
0
|
|
|
|
|
($map) |
38
|
|
|
|
|
|
|
= $driver->search( |
39
|
|
|
|
|
|
|
'TheSchwartz::FuncMap' => { funcname => $funcname } ) |
40
|
|
|
|
|
|
|
or croak "Can't find or create funcname $funcname: $err"; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
return $map; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |