/[cwmp]/google/branches/store-pluggable/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/branches/store-pluggable/lib/CWMP/Store.pm

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

revision 146 by dpavlin, Fri Oct 26 20:46:09 2007 UTC revision 147 by dpavlin, Sat Oct 27 22:43:25 2007 UTC
# Line 27  CWMP::Store - parsist CPE state on disk Line 27  CWMP::Store - parsist CPE state on disk
27    my $store = CWMP::Store->new({    my $store = CWMP::Store->new({
28          module => 'DBMDeep',          module => 'DBMDeep',
29          path => '/path/to/state.db',          path => '/path/to/state.db',
30            clean => 1,
31          debug => 1,          debug => 1,
32    });    });
33    
# Line 38  sub new { Line 39  sub new {
39    
40          confess "requed parametar module is missing" unless $self->module;          confess "requed parametar module is missing" unless $self->module;
41    
42          warn "created ", __PACKAGE__, "(", dump( @_ ), ") object\n" if $self->debug;          # XXX it's important to call possible_stores once, because current_store won't work
43            my @plugins = $self->possible_stores();
44    
45          warn "Found store plugins: ", join(", ", __PACKAGE__->possible_stores() );          warn "Found store plugins: ", join(", ", @plugins ), "\n" if $self->debug;
46    
47          $self->current_store->open( @_ );          $self->current_store->open( @_ );
48    
# Line 61  sub current_store { Line 63  sub current_store {
63    
64          confess "unknown store module $module not one of ", dump( $self->possible_stores ) unless $s;          confess "unknown store module $module not one of ", dump( $self->possible_stores ) unless $s;
65    
66          warn "current store = ",dump( $s );          warn "## current store = $s\n" if $self->debug;
67    
68          return $s;          return $s;
69  }  }
# Line 100  sub update_state { Line 102  sub update_state {
102          $self->current_store->update_uid_state( $uid, $state );          $self->current_store->update_uid_state( $uid, $state );
103  }  }
104    
105  =head2 state  =head2 get_state
106    
107    my $state = $store->state( ID => $ID );    my $state = $store->get_state( ID => $ID );
108    my $state = $store->state( uid => $uid );    my $state = $store->get_state( uid => $uid );
109    
110  Returns normal unblessed hash (actually, in-memory copy of state in database).  Returns normal unblessed hash (actually, in-memory copy of state in database).
111    
112  =cut  =cut
113    
114  sub state {  sub get_state {
115          my $self = shift;          my $self = shift;
116          my ( $k, $v ) = @_;          my ( $k, $v ) = @_;
117          confess "need ID or uid" unless $k =~ m/^(ID|uid)$/;          confess "need ID or uid" unless $k =~ m/^(ID|uid)$/;
118          confess "need $k value" unless $v;          confess "need $k value" unless $v;
119    
120          warn "## state( $k => $v )\n" if $self->debug;          warn "## get_state( $k => $v )\n" if $self->debug;
121    
122          my $uid;          my $uid;
123    
# Line 134  sub state { Line 136  sub state {
136    
137  }  }
138    
139  =head2 known_CPE  =head2 all_uids
140    
141    my @cpe = $store->known_CPE;    my @cpe = $store->all_uids;
142    
143  =cut  =cut
144    
145  sub known_CPE {  sub all_uids {
146          my $self = shift;          my $self = shift;
147          my @cpes = $self->current_store->all_uids;          my @cpes = $self->current_store->all_uids;
148          warn "all CPE: ", dump( @cpes ), "\n" if $self->debug;          warn "## all_uids = ", dump( @cpes ), "\n" if $self->debug;
149          return @cpes;          return @cpes;
150  }  }
151    

Legend:
Removed from v.146  
changed lines
  Added in v.147

  ViewVC Help
Powered by ViewVC 1.1.26