File Coverage

blib/lib/Autodia/Diagram/Superclass.pm
Criterion Covered Total %
statement 9 72 12.5
branch 0 16 0.0
condition 0 7 0.0
subroutine 3 13 23.0
pod 0 8 0.0
total 12 116 10.3


line stmt bran cond sub pod time code
1             ################################################################
2             # Autodia - Automatic Dia XML.(C)Copyright 2001-2009 A Trevena #
3             # #
4             # AutoDia comes with ABSOLUTELY NO WARRANTY; see COPYING file #
5             # This is free software, and you are welcome to redistribute #
6             # it under certain conditions; see COPYING file for details #
7             ################################################################
8              
9             package Autodia::Diagram::Superclass;
10 1     1   6 use strict;
  1         1  
  1         38  
11              
12 1     1   6 use Carp qw(cluck);
  1         2  
  1         50  
13              
14 1     1   6 use base qw(Autodia::Diagram::Object);
  1         3  
  1         802  
15              
16             #---------------------------------------------------------------------
17              
18             #####################
19             # Constructor Methods
20              
21             sub new
22             {
23 0     0 0   my $class = shift;
24 0           my $name = shift;
25              
26 0 0         cluck "new method called with no name\n" unless ($name);
27              
28 0           my $DiagramSuperclass = {};
29              
30 0   0       bless ($DiagramSuperclass, ref($class) || $class);
31 0           $DiagramSuperclass->_initialise($name);
32 0           return $DiagramSuperclass;
33             }
34              
35             #--------------------------------------------------------------------
36             # Access Methods
37              
38             sub Inheritances
39             {
40 0     0 0   my $self = shift;
41              
42 0           my @inheritances = ();
43 0 0         if (ref $self->{"inheritances"}) {
44 0           @inheritances = @{$self->{"inheritances"}};
  0            
45             }
46 0           return @inheritances;
47              
48             }
49              
50              
51             sub add_inheritance
52             {
53 0     0 0   my $self = shift;
54 0           my $new_inheritance = shift;
55 0           my @inheritances;
56              
57 0           $new_inheritance->Parent($self->Id);
58              
59 0 0         if (defined $self->{"inheritances"})
60 0           { @inheritances = @{$self->{"inheritances"}}; }
  0            
61 0           push(@inheritances, $new_inheritance);
62 0           $self->{"inheritances"} = \@inheritances;
63              
64 0           return scalar(@inheritances);
65             }
66              
67              
68             sub Relations {
69 0     0 0   my $self = shift;
70 0 0         return (ref $self->{"relations"}) ? @{$self->{"relations"}} : () ;
  0            
71             }
72              
73             sub add_relation {
74 0     0 0   my $self = shift;
75 0           my $new_relation = shift;
76 0   0       $self->{relations} ||= [];
77 0           push(@{$self->{relations}}, $new_relation);
  0            
78 0           return 1;
79             }
80              
81             sub Redundant {
82 0     0 0   my $self = shift;
83 0   0       my $replacement = shift || 0;
84              
85 0 0         if ($replacement) {
86 0 0         if ($self->{"_redundant"}) {
87 0           my $current_replacement = $self->{"_redundant"};
88 0           return -1;
89             }
90 0           $self->{"_redundant"} = $replacement;
91 0           return 1;
92             }
93 0           $self->{_redundant} = 0;
94 0           return 0;
95             }
96              
97             sub Name {
98 0     0 0   my $self = shift;
99 0           my $name = shift;
100              
101 0 0         if ($name)
102             {
103 0           $self->{"name"} = $name;
104 0           return 1;
105             }
106             else
107 0           { return $self->{"name"}; }
108             }
109              
110             sub LocalId
111             {
112 0     0 0   my $self = shift;
113 0           my $return_val = 1;
114 0           my $new_id = shift;
115              
116 0 0         if ($new_id)
117 0           { $self->{"local_id"} = $new_id }
118             else
119 0           { $return_val = $self->{"local_id"}; }
120              
121 0           return $return_val;
122             }
123              
124             #--------------------------------------------------------------------------
125             # Internal Methods
126              
127             sub _initialise # over-rides method in DiagramObject
128             {
129 0     0     my $self = shift;
130 0           my $name = shift;
131 0           $self->{"name"} = $name;
132 0           $self->{"type"} = "superclass";
133 0           return 1;
134             }
135              
136             sub _update # over-rides method in DiagramObject
137             {
138 0     0     my $self = shift;
139 0           $self->reposition();
140 0           return 1;
141             }
142              
143             1;
144              
145             ##########################################################################
146              
147             =head1
148              
149             =cut