/[cwmp]/google/lib/CWMP/Store.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /google/lib/CWMP/Store.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 79 by dpavlin, Fri Jun 22 14:32:13 2007 UTC revision 85 by dpavlin, Fri Jun 22 18:36:09 2007 UTC
# Line 38  sub new { Line 38  sub new {
38    
39          warn "created ", __PACKAGE__, "(", dump( @_ ), ") object\n" if $self->debug;          warn "created ", __PACKAGE__, "(", dump( @_ ), ") object\n" if $self->debug;
40    
41            confess "need path to state.db" unless ( $self->path );
42    
43          $self->db(          $self->db(
44                  DBM::Deep->new(                  DBM::Deep->new(
45                          file => $self->path,                          file => $self->path,
# Line 63  sub update_state { Line 65  sub update_state {
65          confess "need ID" unless $ID;          confess "need ID" unless $ID;
66          confess "need state" unless $state;          confess "need state" unless $state;
67    
68          warn "## update state of $ID\n" if $self->debug;          if ( my $o = $self->db->get( $ID ) ) {
69                    warn "## update state of $ID\n" if $self->debug;
70                    $o->import( $state );
71            } else {
72                    warn "## create new state for $ID\n" if $self->debug;
73                    $self->db->put( $ID => $state );
74            }
75            
76    }
77    
78    =head2 state
79    
80      my $state = $store->state( $ID );
81    
82    Returns normal unblessed hash (actually, in-memory copy of state in database).
83    
84          $self->db->import( $ID => $state );  =cut
85    
86    sub state {
87            my $self = shift;
88            my ( $ID ) = @_;
89            confess "need ID" unless $ID;
90            return $self->db->get( $ID )->export;
91  }  }
92    
93  1;  1;

Legend:
Removed from v.79  
changed lines
  Added in v.85

  ViewVC Help
Powered by ViewVC 1.1.26