2 # ============================================================================
3 # Zebra perl API header
4 # =============================================================================
7 # ============================================================================
8 package IDZebra::Session;
10 use IDZebra::Logger qw(:flags :calls);
11 use IDZebra::Repository;
14 our @ISA = qw(IDZebra::Logger);
17 # -----------------------------------------------------------------------------
18 # Class constructors, destructor
19 # -----------------------------------------------------------------------------
21 my ($proto,$service) = @_;
22 my $class = ref($proto) || $proto;
24 $self->{service} = $service;
25 $self->{sessionID} = $service->{sessc};
26 bless ($self, $class);
31 my ($proto,$service) = @_;
33 if (ref($proto)) { $self = $proto; } else {
34 $self = $proto->new($service);
36 unless (defined($self->{zh})) {
37 $self->{zh}=IDZebra::open($self->{service}{zs}) if ($self->{service});
39 $self->Repository(); # Make a dummy record group
41 $self->{odr_input} = IDZebra::odr_createmem($IDZebra::ODR_DECODE);
42 $self->{odr_output} = IDZebra::odr_createmem($IDZebra::ODR_ENCODE);
51 IDZebra::close($self->{zh});
55 if ($self->{odr_input}) {
56 IDZebra::odr_destroy($self->{odr_input});
57 $self->{odr_input} = undef;
60 if ($self->{odr_output}) {
61 IDZebra::odr_destroy($self->{odr_output});
62 $self->{odr_output} = undef;
65 delete($self->{service}{sessions}{$self->{sessionID}});
66 delete($self->{service});
71 print STDERR "Destroy_session\n";
74 # -----------------------------------------------------------------------------
76 # -----------------------------------------------------------------------------
79 return(IDZebra::errCode($self->{zh}));
84 return(IDZebra::errString($self->{zh}));
89 return(IDZebra::errAdd($self->{zh}));
92 # -----------------------------------------------------------------------------
94 # -----------------------------------------------------------------------------
97 unless ($self->{trans_started}) {
98 $self->{trans_started} = 1;
99 IDZebra::begin_trans($self->{zh});
105 if ($self->{trans_started}) {
106 $self->{trans_started} = 0;
107 IDZebra::end_trans($self->{zh});
112 my ($self, $value) = @_;
113 if ($#_ > 0) { IDZebra::set_shadow_enable($self->{zh},$value); }
114 return (IDZebra::get_shadow_enable($self->{zh}));
119 if ($self->shadow_enable) {
120 return(IDZebra::commit($self->{zh}));
124 # -----------------------------------------------------------------------------
125 # We don't really need that...
126 # -----------------------------------------------------------------------------
128 my ($self, $name) = @_;
129 if ($name !~/^(input|output)$/) {
130 croak("Undefined ODR '$name'");
132 IDZebra::odr_reset($self->{"odr_$name"});
135 # -----------------------------------------------------------------------------
137 # -----------------------------------------------------------------------------
140 return(IDZebra::init($self->{zh}));
145 return(IDZebra::compact($self->{zh}));
148 # -----------------------------------------------------------------------------
150 # -----------------------------------------------------------------------------
152 my ($self, %args) = @_;
154 $self->{rep} = IDZebra::Repository->new($self, %args);
156 $self->{rep}->modify(%args);
159 return ($self->{rep});
162 # -----------------------------------------------------------------------------
163 # Search and retrieval
164 # -----------------------------------------------------------------------------
165 sub select_databases {
166 my ($self, @databases) = @_;
167 return (IDZebra::select_databases($self->{zh},
174 return(IDZebra::begin_read($self->{zh}));
179 IDZebra::end_read($self->{zh});
183 my ($self, $query, $setname) = @_;
184 return (IDZebra::search_PQF($self->{zh},
207 Peter Popovics, pop@technomat.hu
211 IDZebra, IDZebra::Data1, Zebra documentation