File Coverage

blib/lib/Video/CPL/Target.pm
Criterion Covered Total %
statement 37 52 71.1
branch 7 14 50.0
condition n/a
subroutine 8 12 66.6
pod 3 7 42.8
total 55 85 64.7


line stmt bran cond sub pod time code
1             package Video::CPL::Target;
2              
3 1     1   3 use warnings;
  1         1  
  1         24  
4 1     1   3 use strict;
  1         1  
  1         14  
5 1     1   2 use Carp;
  1         2  
  1         36  
6 1     1   4 use Data::Dumper;
  1         1  
  1         31  
7 1     1   3 use XML::Writer;
  1         1  
  1         334  
8              
9             =head1 NAME
10              
11             Video::CPL::Target - The great new Video::CPL::Target!
12              
13             =head1 VERSION
14              
15             Version 0.09
16              
17             =cut
18              
19             our $VERSION = '0.09';
20              
21              
22             =head1 SYNOPSIS
23              
24             Quick summary of what the module does.
25              
26             Perhaps a little code snippet.
27              
28             use Video::CPL::Target;
29              
30             my $foo = Video::CPL::Target->new();
31             ...
32              
33             =head1 EXPORT
34              
35             A list of functions that can be exported. You can delete this section
36             if you don't export anything, such as for a purely object-oriented module.
37              
38             =head1 SUBROUTINES/METHODS
39              
40             =cut
41              
42             our @FIELDS = qw(cuePointRef association modal);
43              
44             #cuePointRef : new model is that this is a string
45              
46             #dynamic INIT-block creation of these routines has too many problems. spell it out.
47 0 0   0 0 0 sub cuePointRef { my $obj = shift; $obj->{cuePointRef} = shift if @_; return $obj->{cuePointRef};};
  0         0  
  0         0  
48 0 0   0 0 0 sub association { my $obj = shift; $obj->{association} = shift if @_; return $obj->{association};};
  0         0  
  0         0  
49 0 0   0 0 0 sub modal { my $obj = shift; $obj->{modal} = shift if @_; return $obj->{modal};};
  0         0  
  0         0  
50              
51             =head2 new()
52              
53             Create a new Target object.
54              
55             =cut
56              
57             sub new {
58 4     4 1 7 my $pkg = shift;
59 4         7 my %p = @_;
60 4         6 my $ret = {};
61 4         6 bless $ret,$pkg;
62 4         11 foreach my $x (@FIELDS){
63 12 100       29 $ret->{$x} = $p{$x} if defined $p{$x};
64             }
65 4         7 foreach my $x (keys %p){
66 4 50       10 confess("Parameter ('$x') given to Video::CPL::Target::new, but not understood\n") if !defined $ret->{$x};
67             }
68 4         12 return $ret;
69             }
70              
71             =head2 xmlo
72            
73             Given an XML::Writer object, add the xml information for this Target.
74              
75             =cut
76              
77             sub xmlo {
78 2     2 1 2 my $obj = shift;
79 2         2 my $xo = shift;
80 2         3 my %p;
81 2         3 foreach my $x (@FIELDS){
82 6 100       13 $p{$x} = $obj->{$x} if defined $obj->{$x};
83             }
84 2         4 $xo->emptyTag("target",%p);
85             }
86              
87             =head2 xml()
88              
89             Return the xml format of a Target object.
90              
91             =cut
92              
93             sub xml {
94 0     0 1 0 my $obj = shift;
95 0         0 my $a;
96 0         0 my $xo = new XML::Writer(OUTPUT=>\$a);
97 0         0 $obj->xmlo($xo);
98 0         0 $xo->end();
99 0         0 return $a;
100             }
101              
102             sub fromxml {
103 2     2 0 3 my $s = shift;
104 2         1 my %s = %{$s};
  2         5  
105 2         3 my %p;
106 2         2 foreach my $q (@FIELDS){
107 6 100       13 $p{$q} = $s{$q} if defined $s{$q};
108             }
109 2         917 return new Video::CPL::Target(%p);
110             }
111              
112             =head1 AUTHOR
113              
114             Carl Rosenberg, C<< >>
115              
116             =head1 BUGS
117              
118             Please report any bugs or feature requests to Coincident TV.
119              
120             =head1 SUPPORT
121              
122             You can find documentation for this module with the perldoc command.
123              
124             perldoc Video::CPL::Target
125              
126             =head1 LICENSE AND COPYRIGHT
127              
128             Copyright 2010 Coincident TV
129              
130             Licensed under the Apache License, Version 2.0 (the "License");
131             you may not use this file except in compliance with the License.
132             You may obtain a copy of the License at
133              
134             http://www.apache.org/licenses/LICENSE-2.0
135              
136             Unless required by applicable law or agreed to in writing, software
137             distributed under the License is distributed on an "AS IS" BASIS,
138             WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139             See the License for the specific language governing permissions and
140             limitations under the License.
141              
142             =cut
143              
144             1;