From 4c5419893ea9b74b30c1ebe9c56fd60a02b83ef8 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Thu, 6 Feb 2014 18:11:31 +0100
Subject: [PATCH] reporting: simplify code (remove sections object)
---
matlab/reports/@page/addSection.m | 5 +--
matlab/reports/@page/numSections.m | 4 +--
matlab/reports/@page/page.m | 4 +--
matlab/reports/@page/write.m | 7 ++--
matlab/reports/@report/addGraph.m | 4 +--
matlab/reports/@report/addSeries.m | 8 ++---
matlab/reports/@report/addTable.m | 4 +--
matlab/reports/@report/addVspace.m | 4 +--
matlab/reports/@section/subsasgn.m | 6 +++-
matlab/reports/@sections/addSection.m | 23 ------------
matlab/reports/@sections/display.m | 32 -----------------
matlab/reports/@sections/end.m | 35 -------------------
matlab/reports/@sections/getSections.m | 22 ------------
matlab/reports/@sections/numSections.m | 22 ------------
matlab/reports/@sections/sections.m | 43 -----------------------
matlab/reports/@sections/subsasgn.m | 39 ---------------------
matlab/reports/@sections/subsref.m | 48 --------------------------
matlab/reports/@sections/write.m | 39 ---------------------
18 files changed, 27 insertions(+), 322 deletions(-)
delete mode 100644 matlab/reports/@sections/addSection.m
delete mode 100644 matlab/reports/@sections/display.m
delete mode 100644 matlab/reports/@sections/end.m
delete mode 100644 matlab/reports/@sections/getSections.m
delete mode 100644 matlab/reports/@sections/numSections.m
delete mode 100644 matlab/reports/@sections/sections.m
delete mode 100644 matlab/reports/@sections/subsasgn.m
delete mode 100644 matlab/reports/@sections/subsref.m
delete mode 100644 matlab/reports/@sections/write.m
diff --git a/matlab/reports/@page/addSection.m b/matlab/reports/@page/addSection.m
index b24c16b89e..958940f1c7 100644
--- a/matlab/reports/@page/addSection.m
+++ b/matlab/reports/@page/addSection.m
@@ -13,7 +13,7 @@ function p = addSection(p, varargin)
% SPECIAL REQUIREMENTS
% none
-% Copyright (C) 2013 Dynare Team
+% Copyright (C) 2013-2014 Dynare Team
%
% This file is part of Dynare.
%
@@ -30,5 +30,6 @@ function p = addSection(p, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-p.sections = p.sections.addSection(varargin{:});
+fprintf(1, '/');
+p.sections{end+1} = section(varargin{:});
end
diff --git a/matlab/reports/@page/numSections.m b/matlab/reports/@page/numSections.m
index faa61e7b72..aa0b0a1bed 100644
--- a/matlab/reports/@page/numSections.m
+++ b/matlab/reports/@page/numSections.m
@@ -11,7 +11,7 @@ function ns = numSections(p)
% SPECIAL REQUIREMENTS
% none
-% Copyright (C) 2013 Dynare Team
+% Copyright (C) 2013-2014 Dynare Team
%
% This file is part of Dynare.
%
@@ -28,5 +28,5 @@ function ns = numSections(p)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-ns = p.sections.numSections();
+ns = length(p.sections);
end
\ No newline at end of file
diff --git a/matlab/reports/@page/page.m b/matlab/reports/@page/page.m
index b36adb1c5f..2f2b9a67d8 100644
--- a/matlab/reports/@page/page.m
+++ b/matlab/reports/@page/page.m
@@ -12,7 +12,7 @@ function o = page(varargin)
% SPECIAL REQUIREMENTS
% none
-% Copyright (C) 2013 Dynare Team
+% Copyright (C) 2013-2014 Dynare Team
%
% This file is part of Dynare.
%
@@ -35,7 +35,7 @@ o.title = {};
o.titleFormat = {};
o.orientation = '';
o.footnote = {};
-o.sections = sections();
+o.sections = {};
if nargin == 1
assert(isa(varargin{1}, 'page'), ['@page.page: with one arg to Page ' ...
diff --git a/matlab/reports/@page/write.m b/matlab/reports/@page/write.m
index 09a7f62184..12ab8673d2 100644
--- a/matlab/reports/@page/write.m
+++ b/matlab/reports/@page/write.m
@@ -12,7 +12,7 @@ function o = write(o, fid)
% SPECIAL REQUIREMENTS
% none
-% Copyright (C) 2013 Dynare Team
+% Copyright (C) 2013-2014 Dynare Team
%
% This file is part of Dynare.
%
@@ -46,7 +46,10 @@ for i=1:length(o.title)
fprintf(fid,'\\multicolumn{1}{c}{%s %s}\\\\\n', o.titleFormat{i}, o.title{i});
end
-o.sections.write(fid);
+nps = length(o.sections);
+for i=1:nps
+ o.sections{i}.write(fid);
+end
if strcmpi(o.orientation, 'landscape')
fprintf(fid, '\\end{landscape}\n');
diff --git a/matlab/reports/@report/addGraph.m b/matlab/reports/@report/addGraph.m
index 6311eb53e4..9e0e691e88 100644
--- a/matlab/reports/@report/addGraph.m
+++ b/matlab/reports/@report/addGraph.m
@@ -29,6 +29,6 @@ function o = addGraph(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-o.pages{end}.sections(end) = ...
- o.pages{end}.sections(end).addGraph(varargin{:});
+o.pages{end}.sections{end} = ...
+ o.pages{end}.sections{end}.addGraph(varargin{:});
end
diff --git a/matlab/reports/@report/addSeries.m b/matlab/reports/@report/addSeries.m
index 27db253e0e..a72470a187 100644
--- a/matlab/reports/@report/addSeries.m
+++ b/matlab/reports/@report/addSeries.m
@@ -29,10 +29,10 @@ function o = addSeries(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-assert(isa(o.pages{end}.sections(end).elements(end), 'graph') || ...
- isa(o.pages{end}.sections(end).elements(end), 'report_table'), ...
+assert(isa(o.pages{end}.sections{end}.elements(end), 'graph') || ...
+ isa(o.pages{end}.sections{end}.elements(end), 'report_table'), ...
'@report.addSeries: you can only add a series to a report_table or graph object');
-o.pages{end}.sections(end).elements(end) = ...
- o.pages{end}.sections(end).elements(end).addSeries(varargin{:});
+o.pages{end}.sections{end}.elements(end) = ...
+ o.pages{end}.sections{end}.elements(end).addSeries(varargin{:});
end
diff --git a/matlab/reports/@report/addTable.m b/matlab/reports/@report/addTable.m
index 16e9b539da..4b1f8c0d4d 100644
--- a/matlab/reports/@report/addTable.m
+++ b/matlab/reports/@report/addTable.m
@@ -29,6 +29,6 @@ function o = addTable(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-o.pages{end}.sections(end) = ...
- o.pages{end}.sections(end).addTable(varargin{:});
+o.pages{end}.sections{end} = ...
+ o.pages{end}.sections{end}.addTable(varargin{:});
end
diff --git a/matlab/reports/@report/addVspace.m b/matlab/reports/@report/addVspace.m
index 04c95c15fc..f4ca186d6c 100644
--- a/matlab/reports/@report/addVspace.m
+++ b/matlab/reports/@report/addVspace.m
@@ -29,6 +29,6 @@ function o = addVspace(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-o.pages{end}.sections(end) = ...
- o.pages{end}.sections(end).addVspace(varargin{:});
+o.pages{end}.sections{end} = ...
+ o.pages{end}.sections{end}.addVspace(varargin{:});
end
diff --git a/matlab/reports/@section/subsasgn.m b/matlab/reports/@section/subsasgn.m
index a0a7a1164e..a26dc612b9 100644
--- a/matlab/reports/@section/subsasgn.m
+++ b/matlab/reports/@section/subsasgn.m
@@ -1,7 +1,7 @@
function B = subsasgn(A, S, V)
% function B = subsasgn(A, S, V)
-% Copyright (C) 2013 Dynare Team
+% Copyright (C) 2013-2014 Dynare Team
%
% This file is part of Dynare.
%
@@ -33,6 +33,10 @@ switch S.type
index = S.subs{:};
assert(isnumeric(index));
B.elements(index) = V;
+ case '{}'
+ index = S.subs{:};
+ assert(isnumeric(index));
+ B{index} = V;
case '.'
switch S.subs
case fieldnames(A)
diff --git a/matlab/reports/@sections/addSection.m b/matlab/reports/@sections/addSection.m
deleted file mode 100644
index bdf1c1e0d8..0000000000
--- a/matlab/reports/@sections/addSection.m
+++ /dev/null
@@ -1,23 +0,0 @@
-function o = addSection(o, varargin)
-% function o = addSection(o, varargin)
-
-% Copyright (C) 2013-2014 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-
-fprintf(1, '/');
-o.objArray = o.objArray.addObj(section(varargin{:}));
-end
\ No newline at end of file
diff --git a/matlab/reports/@sections/display.m b/matlab/reports/@sections/display.m
deleted file mode 100644
index 0e344d0000..0000000000
--- a/matlab/reports/@sections/display.m
+++ /dev/null
@@ -1,32 +0,0 @@
-function display(o)
-%function display(o)
-% Display a Sections object
-%
-% INPUTS
-% o [sections] sections object
-%
-% OUTPUTS
-% none
-%
-% SPECIAL REQUIREMENTS
-% none
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-
-reporting_object_display(o);
-end
\ No newline at end of file
diff --git a/matlab/reports/@sections/end.m b/matlab/reports/@sections/end.m
deleted file mode 100644
index c9fc0cd92e..0000000000
--- a/matlab/reports/@sections/end.m
+++ /dev/null
@@ -1,35 +0,0 @@
-function lastIndex = end(o, k, n)
-% function lastIndex = end(o, k, n)
-% End keyword
-%
-% INPUTS
-% o [sections] sections object
-% k [integer] index where end appears
-% n [integer] number of indices
-%
-% OUTPUTS
-% lastIndex [integer] last sections index
-%
-% SPECIAL REQUIREMENTS
-% none
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-
-assert(k==1 && n==1, '@sections/end: sections only has one dimension');
-lastIndex = numSections(o);
-end
\ No newline at end of file
diff --git a/matlab/reports/@sections/getSections.m b/matlab/reports/@sections/getSections.m
deleted file mode 100644
index e60f2270d2..0000000000
--- a/matlab/reports/@sections/getSections.m
+++ /dev/null
@@ -1,22 +0,0 @@
-function e = getSections(ss, varargin)
-% function e = getSections(ss, varargin)
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-
-e = ss.objArray.getObjs(varargin{:});
-end
\ No newline at end of file
diff --git a/matlab/reports/@sections/numSections.m b/matlab/reports/@sections/numSections.m
deleted file mode 100644
index 2eb2700773..0000000000
--- a/matlab/reports/@sections/numSections.m
+++ /dev/null
@@ -1,22 +0,0 @@
-function n = numSections(o)
-% function n = numSections(o)
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-
-n = o.objArray.numObjArray();
-end
\ No newline at end of file
diff --git a/matlab/reports/@sections/sections.m b/matlab/reports/@sections/sections.m
deleted file mode 100644
index 00110fb640..0000000000
--- a/matlab/reports/@sections/sections.m
+++ /dev/null
@@ -1,43 +0,0 @@
-function s = sections(varargin)
-%function s = sections(varargin)
-% Sections Class Constructor
-%
-% INPUTS
-% varargin 0 args : empty sections object
-% 1 arg : must be sections object (return a copy of arg)
-%
-% OUTPUTS
-% ps [sections] sections object
-%
-% SPECIAL REQUIREMENTS
-% none
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-
-switch nargin
- case 0
- s = class(struct, 'sections', objArray());
- case 1
- assert(isa(varargin{1}, 'sections'), ['@sections.sections: the ' ...
- 'only valid arguments are sections objects']);
- s = varargin{1};
- otherwise
- error('@sections.sections: invalid number of arguments');
-end
-end
-
diff --git a/matlab/reports/@sections/subsasgn.m b/matlab/reports/@sections/subsasgn.m
deleted file mode 100644
index 2782f7e1c7..0000000000
--- a/matlab/reports/@sections/subsasgn.m
+++ /dev/null
@@ -1,39 +0,0 @@
-function B = subsasgn(A, S, V)
-% function B = subsasgn(A, S, V)
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-
-B = A;
-if length(S) > 1
- for i=1:(length(S)-1)
- B = subsref(B, S(i));
- end
- B = subsasgn(B, S(end), V);
- B = subsasgn(A, S(1:(end-1)), B);
- return
-end
-
-switch S.type
- case '()'
- index = S.subs{:};
- assert(isnumeric(index));
- B.objArray(index) = V;
- otherwise
- error('@sections.subsasgn: syntax error')
-end
-end
\ No newline at end of file
diff --git a/matlab/reports/@sections/subsref.m b/matlab/reports/@sections/subsref.m
deleted file mode 100644
index 92e0c262a9..0000000000
--- a/matlab/reports/@sections/subsref.m
+++ /dev/null
@@ -1,48 +0,0 @@
-function A = subsref(A, S)
-%function A = subsref(A, S)
-
-% Copyright (C) 2013-2014 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-
-switch S(1).type
- case '.'
- switch S(1).subs
- case fieldnames(A)
- A = A.(S(1).subs);
- case methods(A)
- if areParensNext(S)
- A = feval(S(1).subs, A, S(2).subs{:});
- S = shiftS(S,1);
- else
- A = feval(S(1).subs, A);
- end
- otherwise
- error(['@sections.subsref unknown field or method: ' S(1).subs]);
- end
- case '()'
- A = getSections(A, S(1).subs{:});
- case '{}'
- error(['@sections.subsref ' S(1).type ' indexing not supported.']);
- otherwise
- error('@sections.subsref subsref.m impossible case')
-end
-
-S = shiftS(S,1);
-if length(S) >= 1
- A = subsref(A, S);
-end
-end
diff --git a/matlab/reports/@sections/write.m b/matlab/reports/@sections/write.m
deleted file mode 100644
index 6c87a43eaa..0000000000
--- a/matlab/reports/@sections/write.m
+++ /dev/null
@@ -1,39 +0,0 @@
-function o = write(o, fid)
-%function o = write(o, fid)
-% Write Sections object
-%
-% INPUTS
-% o [sections] sections object
-% fid [integer] file id
-%
-% OUTPUTS
-% o [sections] sections object
-%
-% SPECIAL REQUIREMENTS
-% none
-
-% Copyright (C) 2013-2014 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
-
-assert(fid ~= -1);
-fprintf(fid, '\n%% Sections Object\n');
-nps = numSections(o);
-for i=1:nps
- o.objArray(i).write(fid);
-end
-fprintf(fid, '%% End Sections Object\n\n');
-end
\ No newline at end of file
--
GitLab