reporting: simplify code (remove sections object)
parent
0a0c3af3bc
commit
4c5419893e
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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 ' ...
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue