MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / arch / nios2nommu / scripts / PTF / PTFSection.pm
bloba88d340556cad574400ab56a3b18589d6e0d3500
1 package PTFSection;
3 use strict;
5 # Fields:
6 # type = type of PTF Section
7 # name = name of PTF Section (can be blank)
8 # sections = array of section references
9 # assignments = hash of assignments
11 sub new {
12 my $invocant = shift;
13 my $class = ref($invocant) || $invocant;
14 my $self = {
15 @_,
16 sections => [],
17 assignments => {},
19 bless ($self, $class);
20 return $self;
23 sub addSection {
24 my ($self, $section) = @_;
25 push @{$self->{sections}}, $section;
28 sub getSections {
29 my ($self, $type) = @_;
31 if (! $type) {
32 return @{$self->{sections}};
35 my @matchedSections;
36 foreach my $section (@{$self->{sections}}) {
37 if ($section->type eq $type) {
38 push @matchedSections, $section;
42 return @matchedSections;
45 sub getSection {
46 my ($self, $type, $name) = @_;
48 if (! $name) {
49 $name = "";
52 foreach my $section (@{$self->{sections}}) {
53 if ($section->type eq $type and $section->name eq $name) {
54 return $section;
60 sub addAssignment {
61 my ($self, $name, $value) = @_;
62 $self->{assignments}{$name} = $value;
65 sub getAssignment {
66 my ($self, $name) = @_;
67 return $self->{assignments}{$name};
70 sub type {
71 my $self = shift;
72 return $self->{type};
75 sub name {
76 my $self = shift;
77 return $self->{name};