sl@0: #!perl -w sl@0: # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: # All rights reserved. sl@0: # This component and the accompanying materials are made available sl@0: # under the terms of "Eclipse Public License v1.0" sl@0: # which accompanies this distribution, and is available sl@0: # at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: # sl@0: # Initial Contributors: sl@0: # Nokia Corporation - initial contribution. sl@0: # sl@0: # Contributors: sl@0: # sl@0: # Description: sl@0: # sl@0: sl@0: use strict; sl@0: sl@0: # sl@0: # A simple class to maintain a single 'default supported range' feature sl@0: # object. sl@0: # sl@0: package FeatureDSR; sl@0: sl@0: sub new sl@0: { sl@0: my $arg = shift; sl@0: my $class = ref($arg) || $arg; sl@0: my($low, $high) = @_; sl@0: my $self = { sl@0: lowuid => $low, sl@0: highuid => $high, sl@0: endian => "LE", sl@0: }; sl@0: bless $self, $class; sl@0: return $self; sl@0: } sl@0: sl@0: sub LowUID sl@0: { sl@0: my $self = shift; sl@0: return undef unless(ref($self)); sl@0: my $arg = shift; sl@0: return $self->{lowuid} unless(defined($arg)); sl@0: $self->{lowuid} = $arg; sl@0: return $arg; sl@0: } sl@0: sl@0: sub HighUID sl@0: { sl@0: my $self = shift; sl@0: return undef unless(ref($self)); sl@0: my $arg = shift; sl@0: return $self->{highuid} unless(defined($arg)); sl@0: $self->{highuid} = $arg; sl@0: return $arg; sl@0: } sl@0: sl@0: sub Endian sl@0: { sl@0: my $self = shift; sl@0: return undef unless(ref($self)); sl@0: my $arg = shift; sl@0: return $self->{endian} unless($arg =~ m/(LE|BE)i/); sl@0: $arg = uc($arg); sl@0: $self->{endian} = $arg; sl@0: return $arg; sl@0: } sl@0: sl@0: # Return the content of this object as packed binary, i.e 8 bytes sl@0: # of the specified endian-ness. sl@0: sub BinaryContent sl@0: { sl@0: my $self = shift; sl@0: return undef unless(ref($self)); sl@0: my $packstring = "V2"; sl@0: $packstring = "N2" if($self->{endian} eq "BE"); sl@0: my $retstring = pack($packstring, ( $self->LowUID, $self->HighUID ) ); sl@0: return $retstring; sl@0: } sl@0: sl@0: # Display the content of the DSR in english. sl@0: sub Show sl@0: { sl@0: my $self = shift; sl@0: return undef unless(ref($self)); sl@0: my $fd = shift; sl@0: $fd = *STDOUT unless(defined($fd)); sl@0: printf $fd "LOW UID 0x%08x\n", $self->LowUID(); sl@0: printf $fd "HIGH UID 0x%08x\n", $self->HighUID(); sl@0: return 1; sl@0: } sl@0: sl@0: 1;