Doxy/ClassData.pm untested

filter: Statementstmt 0.0% 0 / 60 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 81 CC 3 SCAR 11.5
CC
3
Cov
0%
add_info
6.0
get_method
6.0
BEGIN
2.0
CRAP 3.1
1 ## @file
2 # (Enter your file info here)
3 #
4 # @copy 2007 MailerMailer LLC
5 # $Id: ClassData.pm 498 2008-08-22 15:35:28Z kamelkev $
6  
7 ## @class RWDE::Doxy::ClassData
8 # This class stores an intermediate representation of a class (or package).
9 package RWDE::Doxy::ClassData;
10  
11 use strict;
12 use warnings;
13  
14 use Error qw(:try);
15 use RWDE::Exceptions;
16  
17 use RWDE::Doxy::MethodData;
18  
19 use base qw(RWDE::RObject);
20  
21 our (%fields, %static_fields, %modifiable_fields, @fieldnames, @static_fieldnames, @modifiable_fieldnames);
22  
23 use vars qw($VERSION);
24 $VERSION = sprintf "%d", q$Revision: 518 $ =~ /(\d+)/;
25  
26 BEGIN {
27  
28 #all of the static fields present
29 %static_fields = (
30  
31 # Field => [Type, Descr]
32 );
33  
34 #all of the fields allowed to be modified
35 %modifiable_fields = (
36  
37 # Field => [Type, Descr]
38 class_name => [ 'char', 'Name of the class' ],
39 class_methods => [ 'hash', 'Hash of methods for this class. The keys will be the method names and the values will be corresponding MethodData objects' ],
40  
41 #Array is used for class_info because we need to preserver order.
42 class_info => [ 'array', 'list of all of the doxygen info lines that existed in the source file_content' ]
43  
44 );
45  
46 %fields = (%static_fields, %modifiable_fields);
47  
48 @static_fieldnames = sort keys %static_fields;
49 @modifiable_fieldnames = sort keys %modifiable_fields;
50 @fieldnames = sort keys %fields;
51 }
52  
53 ## @method void initialize($class_name)
54 # (Enter initialize info here)
55 # @param class_name (Enter explanation for param here)
56 sub initialize() {
57 my ($self, $params) = @_;
58  
59 $self->class_name($$params{class_name});
60  
61 $self->class_methods({});
62 $self->class_info([]);
63  
64 return ();
65 }
66  
67 #Create a new class data object and add it to file_classes hash
68 ## @method object add_new_method()
69 # (Enter add_new_method info here)
70 # @return (Enter explanation for return value here)
71 sub add_new_method() {
72 my ($self, $params) = @_;
73  
74 my $method_data = new RWDE::Doxy::MethodData($params);
75  
76 $self->class_methods->{ $method_data->method_name } = $method_data;
77  
78 return $method_data;
79 }
80  
81 #Add a param to the parameter list
82 ## @method void add_info($info_line)
83 # (Enter add_info info here)
84 # @param info_line (Enter explanation for param here)
85 sub add_info() {
86 my ($self, $params) = @_;
87  
88 throw RWDE::DataMissingException({ info => 'No info line to add to info_list' })
89 unless defined($$params{info_line});
90  
91 my $class_info = $self->class_info;
92  
93 push(@{$class_info}, $$params{info_line});
94  
95 return ();
96 }
97  
98 ## @method object get_method($method_name)
99 # Returns the class_method object for a class name or creates and returns a new one if one does not exists.
100 # @param method_name (Enter explanation for param here)
101 # @return (Enter explanation for return value here)
102 sub get_method() {
103 my ($self, $params) = @_;
104  
105 my @required = qw( method_name );
106 RWDE::RObject->check_params({ required => \@required, supplied => $params });
107  
108 my $method_data;
109  
110 if (not defined($self->class_methods->{ $$params{method_name} })) {
111 $method_data = $self->add_new_method({ method_name => $$params{method_name} });
112 }
113 else {
114 $method_data = $self->class_methods->{ $$params{method_name} };
115 }
116  
117 return $method_data;
118 }
119  
120 1;