summaryrefslogtreecommitdiff
path: root/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
blob: 8d9d3402b97fba054a6f468877454ea1c24886de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package Zaptel::Xpp::Xbus;
#
# Written by Oron Peled <oron@actcom.co.il>
# Copyright (C) 2007, Xorcom
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
#use strict;
use Zaptel::Xpp::Xpd;

my $proc_base = "/proc/xpp";

# Accessors (miniperl does not have Class:Accessor)
sub AUTOLOAD {
	my $self = shift;
	my $name = uc($AUTOLOAD);
	$name =~ s/.*://;   # strip fully-qualified portion
	if (@_) {
		return $self->{$name} = shift;
	} else {
		return $self->{$name};
	}
}

sub xpds($) {
	my $xbus = shift;
	return @{$xbus->{XPDS}};
}

sub new($$) {
	my $pack = shift or die "Wasn't called as a class method\n";
	my $self = { @_ };
	bless $self, $pack;
	$self->{NAME} or die "Missing xbus name";
	my $prefix = "$proc_base/" . $self->{NAME};
	@{$self->{XPDS}} = ();
	foreach my $fqn (glob "$prefix/XPD-??") {
		$fqn =~ s:$proc_base/::;
		$fqn =~ /(\d+)$/;
		my $num = $1;
		my $xpd = Zaptel::Xpp::Xpd->new(
					FQN => $fqn,
					NUM =>, $num,
					XBUS => $self
					);
		push(@{$self->{XPDS}}, $xpd);
	}
	return $self;
}

1;