|
1 # |
|
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 the License "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 # This package contains routines to create features data file. |
|
18 use featurefile; |
|
19 package featuresdat; |
|
20 |
|
21 BEGIN |
|
22 { |
|
23 @ISA = qw (featurefile); # Declare this a child of featurefile class |
|
24 } |
|
25 |
|
26 use featureparser; |
|
27 use strict; |
|
28 |
|
29 # Class constructor |
|
30 sub new |
|
31 { |
|
32 my ($class,$xmlDBHandle) = @_; |
|
33 my $object = $class->SUPER::new($xmlDBHandle); # Invoke base class new function |
|
34 |
|
35 $object->{_FEATURELIST} = undef; |
|
36 $object->{_FEATUREHASHMAP} = undef; |
|
37 $object->{_FILEVERSION} = 0x0001; |
|
38 |
|
39 return $object; |
|
40 } |
|
41 |
|
42 # Subroutine to create feature map |
|
43 # @param $object - Object reference which is passed implicitly |
|
44 sub createFeatureMap |
|
45 { |
|
46 my $object = shift; |
|
47 |
|
48 foreach my $fidMain (@{$object->{_FEATURELIST}}) |
|
49 { |
|
50 my $fid = $fidMain->{uid}; |
|
51 |
|
52 # Check whether the feature is present in feature list XMl file or not. |
|
53 # If not, then generate an error message and discard this feature. |
|
54 if (!$object->isPresentInFeatureListXML($fidMain)) |
|
55 { |
|
56 next; |
|
57 } |
|
58 |
|
59 # "0th" bit of the Status Flag is set depending on whether the feature is included by using "FEATURE" keyword or |
|
60 # excluded using "EXCLUDE_FEATURE" keyword (i.e. "0th" bit will be set as '1' if the feature is included or else will |
|
61 # be set as '0' if feature is excluded). |
|
62 if ($fidMain->{include} == 1) |
|
63 { |
|
64 $fidMain->{SF} |= 1; |
|
65 } |
|
66 elsif ($fidMain->{exclude} == 1) |
|
67 { |
|
68 $fidMain->{SF} &= 0xFFFFFFFE; |
|
69 } |
|
70 |
|
71 $object->{_FEATUREHASHMAP}->{$fid} = { SF=>$fidMain->{SF}, UD=>$fidMain->{UD} }; |
|
72 } |
|
73 } |
|
74 |
|
75 # Subroutine to write the feature entries in the features data file. |
|
76 # @param $object - Object reference which is passed implicitly |
|
77 sub writeFeatures |
|
78 { |
|
79 my $object = shift; |
|
80 |
|
81 foreach my $featureId (sort {$a <=> $b} (keys %{$object->{_FEATUREHASHMAP}})) |
|
82 { |
|
83 $object->write2File($featureId); |
|
84 $object->write2File($object->{_FEATUREHASHMAP}->{$featureId}->{SF}); |
|
85 $object->write2File($object->{_FEATUREHASHMAP}->{$featureId}->{UD}); |
|
86 } |
|
87 } |
|
88 |
|
89 # Subroutine to set the count of Default Support Range(D.S.R) |
|
90 # @param $object - Object reference which is passed implicitly |
|
91 sub setDefaultRangeCount |
|
92 { |
|
93 my $object = shift; |
|
94 |
|
95 # Set the Default Range Count only for core image feature database file. |
|
96 if ($object->{_FEATUREFILENAME} =~ /features.dat$/i ) |
|
97 { |
|
98 $object->{_DEFAULTRANGECOUNT} = ($object->{_XMLDBHANDLE})->defaultIncludeCount(); |
|
99 } |
|
100 else |
|
101 { |
|
102 $object->{_DEFAULTRANGECOUNT} = 0; |
|
103 } |
|
104 } |
|
105 |
|
106 1; |