|
1 #!perl -w |
|
2 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 |
|
17 use strict; |
|
18 |
|
19 # |
|
20 # A simple class to maintain a single 'default supported range' feature |
|
21 # object. |
|
22 # |
|
23 package FeatureDSR; |
|
24 |
|
25 sub new |
|
26 { |
|
27 my $arg = shift; |
|
28 my $class = ref($arg) || $arg; |
|
29 my($low, $high) = @_; |
|
30 my $self = { |
|
31 lowuid => $low, |
|
32 highuid => $high, |
|
33 endian => "LE", |
|
34 }; |
|
35 bless $self, $class; |
|
36 return $self; |
|
37 } |
|
38 |
|
39 sub LowUID |
|
40 { |
|
41 my $self = shift; |
|
42 return undef unless(ref($self)); |
|
43 my $arg = shift; |
|
44 return $self->{lowuid} unless(defined($arg)); |
|
45 $self->{lowuid} = $arg; |
|
46 return $arg; |
|
47 } |
|
48 |
|
49 sub HighUID |
|
50 { |
|
51 my $self = shift; |
|
52 return undef unless(ref($self)); |
|
53 my $arg = shift; |
|
54 return $self->{highuid} unless(defined($arg)); |
|
55 $self->{highuid} = $arg; |
|
56 return $arg; |
|
57 } |
|
58 |
|
59 sub Endian |
|
60 { |
|
61 my $self = shift; |
|
62 return undef unless(ref($self)); |
|
63 my $arg = shift; |
|
64 return $self->{endian} unless($arg =~ m/(LE|BE)i/); |
|
65 $arg = uc($arg); |
|
66 $self->{endian} = $arg; |
|
67 return $arg; |
|
68 } |
|
69 |
|
70 # Return the content of this object as packed binary, i.e 8 bytes |
|
71 # of the specified endian-ness. |
|
72 sub BinaryContent |
|
73 { |
|
74 my $self = shift; |
|
75 return undef unless(ref($self)); |
|
76 my $packstring = "V2"; |
|
77 $packstring = "N2" if($self->{endian} eq "BE"); |
|
78 my $retstring = pack($packstring, ( $self->LowUID, $self->HighUID ) ); |
|
79 return $retstring; |
|
80 } |
|
81 |
|
82 # Display the content of the DSR in english. |
|
83 sub Show |
|
84 { |
|
85 my $self = shift; |
|
86 return undef unless(ref($self)); |
|
87 my $fd = shift; |
|
88 $fd = *STDOUT unless(defined($fd)); |
|
89 printf $fd "LOW UID 0x%08x\n", $self->LowUID(); |
|
90 printf $fd "HIGH UID 0x%08x\n", $self->HighUID(); |
|
91 return 1; |
|
92 } |
|
93 |
|
94 1; |