summaryrefslogtreecommitdiff
path: root/xpp/utils/zconf/Zaptel/Chans.pm
blob: 31bc5f7157d001ab0d077a49605c6c67e51e3079 (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
package Zaptel::Chans;
#
# 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;

# 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 new($$$$$) {
	my $pack = shift or die "Wasn't called as a class method\n";
	my $span = shift or die "Missing a span parameter\n";
	my $num = shift or die "Missing a channel number parameter\n";
	my $fqn = shift or die "Missing a channel fqn parameter\n";
	my $info = shift;
	my $self = {};
	bless $self, $pack;
	$self->span($span);
	$self->num($num);
	$self->fqn($fqn);
	$self->info($info);
	my $type;
	if($fqn =~ m|\bXPP_(\w+)/.*$|) {
		$type = $1;		# One of our AB
	} elsif(defined $info) {
		$type = (split(/\s+/, $info))[0];
	} else {
		$type = $fqn;
	}
	$self->type($type);
	return $self;
}

1;