1#!/usr/bin/perl 2# 3# $Header: /Users/claude/fuzz/lib/Genezzo/SpaceMan/RCS/SMFreeBlock.pm,v 1.3 2007/02/05 05:48:33 claude Exp claude $ 4# 5# copyright (c) 2006, 2007 Jeffrey I Cohen, all rights reserved, worldwide 6# 7# 8package Genezzo::SpaceMan::SMFreeBlock; 9 10use strict; 11use warnings; 12 13use Carp; 14use Genezzo::Util; 15 16BEGIN { 17 use Exporter (); 18 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); 19 20 # set the version for version checking 21# $VERSION = 1.00; 22 # if using RCS/CVS, this may be preferred 23 $VERSION = do { my @r = (q$Revision: 1.3 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker 24 25 @ISA = qw(Exporter); 26 @EXPORT = ( ); # qw(&NumVal); 27 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], 28 29 # your exported package globals go here, 30 # as well as any optionally exported functions 31# @EXPORT_OK = qw($Var1 %Hashit &func3 &func5); 32 @EXPORT_OK = (); 33 34} 35 36our $GZERR = sub { 37 my %args = (@_); 38 39 return 40 unless (exists($args{msg})); 41 42 if (exists($args{self})) 43 { 44 my $self = $args{self}; 45 if (defined($self) && exists($self->{GZERR})) 46 { 47 my $err_cb = $self->{GZERR}; 48 return &$err_cb(%args); 49 } 50 } 51 52 my $warn = 0; 53 if (exists($args{severity})) 54 { 55 my $sev = uc($args{severity}); 56 $sev = 'WARNING' 57 if ($sev =~ m/warn/i); 58 59 # don't print 'INFO' prefix 60 if ($args{severity} !~ m/info/i) 61 { 62 printf ("%s: ", $sev); 63 $warn = 1; 64 } 65 66 } 67 # XXX XXX XXX 68 print __PACKAGE__, ": ", $args{msg}; 69# print $args{msg}; 70# carp $args{msg} 71# if (warnings::enabled() && $warn); 72 73}; 74 75 76sub _init 77{ 78 #whoami; 79 #greet @_; 80 my $self = shift; 81 my %required = ( 82 blocknum => "no blocknum !", 83 current_extent => "no extent !", 84 extent_size => "no extent size !", 85 extent_position => "no extent position!" 86 ); 87 88 my %optional = ( 89 firstextent => 0, 90 newextent => 0 91 ); 92 93 my %args = (%optional, 94 @_); 95 96 return undef 97 unless (Validate(\%args, \%required)); 98 99 $self->{blocknum} = $args{blocknum}; 100 $self->{current_extent} = $args{current_extent}; 101 $self->{extent_size} = $args{extent_size}; 102 $self->{extent_position} = $args{extent_position}; 103 $self->{firstextent} = $args{firstextent}; 104 $self->{newextent} = $args{newextent}; 105 106 return 1; 107 108} 109 110sub new 111{ 112 my $invocant = shift; 113 my $class = ref($invocant) || $invocant ; 114 my $self = { }; 115 116# whoami @_; 117 my %args = (@_); 118 return undef 119 unless (_init($self,%args)); 120 121 if ((exists($args{GZERR})) 122 && (defined($args{GZERR})) 123 && (length($args{GZERR}))) 124 { 125 # NOTE: don't supply our GZERR here - will get 126 # recursive failure... 127 $self->{GZERR} = $args{GZERR}; 128 } 129 130 my $blessref = bless $self, $class; 131 132 return $blessref; 133 134} # end new 135 136sub GetBlocknum 137{ 138 my $self = shift; 139 140 return $self->{blocknum}; 141} 142 143sub GetCurrentExtent 144{ 145 my $self = shift; 146 147 return $self->{current_extent}; 148} 149sub GetExtentSize 150{ 151 my $self = shift; 152 153 return $self->{extent_size}; 154} 155sub GetExtentPosition 156{ 157 my $self = shift; 158 159 return $self->{extent_position}; 160} 161 162sub IsNewExtent 163{ 164 my $self = shift; 165 166 return $self->{newextent}; 167} 168 169sub IsFirstExtent 170{ 171 my $self = shift; 172 173 return $self->{firstextent}; 174} 175 176 1771; # don't forget to return a true value from the file 178 179__END__ 180 181=head1 NAME 182 183Genezzo::SpaceMan::SMFreeBlock.pm - FreeBlock Space Management 184 185=head1 SYNOPSIS 186 187 use Genezzo::SpaceMan::SMFreeBlock; 188 189=head1 DESCRIPTION 190 191SMFreeBlock is a data structure which describes the basic space 192objects associated with each block. 193 194=head1 FUNCTIONS 195 196=over 4 197 198=item GetBlocknum 199 200=item GetCurrentExtent 201 202=item GetExtentSize 203 204=item IsNewExtent 205 206=item IsFirstExtent 207 208=back 209 210 211=head2 EXPORT 212 213=head1 TODO 214 215=over 4 216 217=item Under Construction 218 219=back 220 221 222 223=head1 AUTHOR 224 225Jeffrey I. Cohen, jcohen@genezzo.com 226 227=head1 SEE ALSO 228 229perl(1), L<Genezzo::SpaceMan::SMFile>, L<Genezzo::SpaceMan::SMExtent>. 230 231Copyright (c) 2006, 2007 Jeffrey I Cohen. All rights reserved. 232 233 This program is free software; you can redistribute it and/or modify 234 it under the terms of the GNU General Public License as published by 235 the Free Software Foundation; either version 2 of the License, or 236 any later version. 237 238 This program is distributed in the hope that it will be useful, 239 but WITHOUT ANY WARRANTY; without even the implied warranty of 240 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 241 GNU General Public License for more details. 242 243 You should have received a copy of the GNU General Public License 244 along with this program; if not, write to the Free Software 245 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 246 247Address bug reports and comments to: jcohen@genezzo.com 248 249For more information, please visit the Genezzo homepage 250at L<http://www.genezzo.com> 251 252=cut 253