Author: Diego Barrios Romero <[email protected]>
Date: Tue Mar 13 01:38:09 2012 +0100
File loading taken out of job struct
---
synfig-core/src/tool/Makefile.am | 1 -
synfig-core/src/tool/job.cpp | 99 --------------------------------------
synfig-core/src/tool/job.h | 31 ++++++++----
synfig-core/src/tool/main.cpp | 50 +++++++++++++------
4 files changed, 55 insertions(+), 126 deletions(-)
diff --git a/synfig-core/src/tool/Makefile.am b/synfig-core/src/tool/Makefile.am
index ff64f2a..67f64e8 100644
--- a/synfig-core/src/tool/Makefile.am
+++ b/synfig-core/src/tool/Makefile.am
@@ -19,7 +19,6 @@ synfig_SOURCES = \
progress.h \
renderprogress.h \
job.h \
- job.cpp \
printing_functions.h \
printing_functions.cpp \
main.cpp
diff --git a/synfig-core/src/tool/job.cpp b/synfig-core/src/tool/job.cpp
deleted file mode 100644
index 9125e59..0000000
--- a/synfig-core/src/tool/job.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*! \file tool/job.cpp
-** \brief Job class methods
-**
-** $Id$
-**
-** \legal
-** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007, 2008 Chris Moore
-** Copyright (c) 2009-2012 Diego Barrios Romero
-**
-** This package 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 2 of
-** the License, or (at your option) any later version.
-**
-** This package 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.
-** \endlegal
-*/
-/* ========================================================================= */
-
-#ifdef USING_PCH
-# include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <iostream>
-#include <string>
-#include <synfig/loadcanvas.h>
-#include <synfig/canvas.h>
-#include <synfig/target.h>
-#include "definitions.h"
-#include "job.h"
-#endif
-
-using namespace std;
-using namespace synfig;
-
-Job::Job()
-{
- canvas_info = canvas_info_all = canvas_info_time_start =
- canvas_info_time_end = canvas_info_frame_rate =
- canvas_info_frame_start = canvas_info_frame_end =
- canvas_info_w = canvas_info_h = canvas_info_image_aspect =
- canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect =
- canvas_info_tl = canvas_info_br = canvas_info_physical_w =
- canvas_info_physical_h = canvas_info_x_res = canvas_info_y_res =
- canvas_info_span = canvas_info_interlaced =
- canvas_info_antialias = canvas_info_clamp = canvas_info_flags =
- canvas_info_focus = canvas_info_bg_color = canvas_info_metadata
- = false;
-
- quality = DEFAULT_QUALITY;
- sifout = false;
-}
-
-int Job::load_file (string filename)
-{
- _filename = filename;
- // Open the composition
- string errors, warnings;
- try
- {
- _root = open_canvas(_filename, errors, warnings);
- }
- catch(runtime_error x)
- {
- _root = 0;
- }
-
- // By default, the canvas to render is the root canvas
- // This can be changed through --canvas option
- canvas = _root;
-
- if(!canvas)
- {
- cerr << _("Unable to load '") << filename << "'."
- << endl;
-
- return SYNFIGTOOL_FILENOTFOUND;
- }
-
- return SYNFIGTOOL_OK;
-}
-
-string Job::filename () const
-{
- return _filename;
-}
-
-Canvas::Handle Job::root () const
-{
- return _root;
-}
diff --git a/synfig-core/src/tool/job.h b/synfig-core/src/tool/job.h
index 2c9149e..f35698f 100644
--- a/synfig-core/src/tool/job.h
+++ b/synfig-core/src/tool/job.h
@@ -1,6 +1,6 @@
/* === S Y N F I G ========================================================= */
/*! \file tool/job.h
-** \brief Job class
+** \brief Job struct
**
** $Id$
**
@@ -25,16 +25,14 @@
#ifndef __SYNFIG_JOB_H
#define __SYNFIG_JOB_H
-class Job
+struct Job
{
- std::string _filename;
- synfig::Canvas::Handle _root;
-
-public:
+ std::string filename;
std::string outfilename;
synfig::RendDesc desc;
+ synfig::Canvas::Handle root;
synfig::Canvas::Handle canvas;
synfig::Target::Handle target;
@@ -54,13 +52,24 @@ public:
canvas_info_focus, canvas_info_bg_color,
canvas_info_metadata;
- Job();
-
- int load_file (std::string filename);
+ Job()
+ {
+ canvas_info = canvas_info_all = canvas_info_time_start =
+ canvas_info_time_end = canvas_info_frame_rate =
+ canvas_info_frame_start = canvas_info_frame_end =
+ canvas_info_w = canvas_info_h = canvas_info_image_aspect =
+ canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect =
+ canvas_info_tl = canvas_info_br = canvas_info_physical_w =
+ canvas_info_physical_h = canvas_info_x_res =
canvas_info_y_res =
+ canvas_info_span = canvas_info_interlaced =
+ canvas_info_antialias = canvas_info_clamp =
canvas_info_flags =
+ canvas_info_focus = canvas_info_bg_color =
canvas_info_metadata
+ = false;
- std::string filename() const;
+ quality = DEFAULT_QUALITY;
+ sifout = false;
+ }
- synfig::Canvas::Handle root() const;
};
#endif
diff --git a/synfig-core/src/tool/main.cpp b/synfig-core/src/tool/main.cpp
index 35cee1d..ab1c8e8 100644
--- a/synfig-core/src/tool/main.cpp
+++ b/synfig-core/src/tool/main.cpp
@@ -663,13 +663,33 @@ int main(int ac, char* av[])
if (vm.count("input-file"))
{
Job job;
- int ret;
- ret = job.load_file(vm["input-file"].as<string>());
- if (ret != SYNFIGTOOL_OK)
- return ret;
+ job.filename = vm["input-file"].as<string>();
- job.root()->set_time(0);
+ // Open the composition
+ string errors, warnings;
+ try
+ {
+ job.root = open_canvas(job.filename, errors,
warnings);
+ }
+ catch(runtime_error x)
+ {
+ job.root = 0;
+ }
+
+ // By default, the canvas to render is the root canvas
+ // This can be changed through --canvas option
+ job.canvas = job.root;
+
+ if(!job.canvas)
+ {
+ cerr << _("Unable to load '") << job.filename
<< "'."
+ << endl;
+
+ return SYNFIGTOOL_FILENOTFOUND;
+ }
+
+ job.root->set_time(0);
job_list.push_front(job);
}
@@ -711,12 +731,12 @@ int main(int ac, char* av[])
{
string warnings;
job_list.front().canvas =
-
job_list.front().root()->find_canvas(canvasid, warnings);
+
job_list.front().root->find_canvas(canvasid, warnings);
}
catch(Exception::IDNotFound)
{
cerr << _("Unable to find canvas with ID \"")
- << canvasid << _("\" in ") <<
job_list.front().filename()
+ << canvasid << _("\" in ") <<
job_list.front().filename
<< "." << endl;
cerr << _("Throwing out job...") << endl;
job_list.pop_front();
@@ -724,7 +744,7 @@ int main(int ac, char* av[])
catch(Exception::BadLinkName)
{
cerr << _("Invalid canvas name \"") << canvasid
- << _("\" in ") <<
job_list.front().filename() << "."
+ << _("\" in ") <<
job_list.front().filename << "."
<< endl;
cerr << _("Throwing out job...") << endl;
job_list.pop_front();
@@ -764,8 +784,8 @@ int main(int ac, char* av[])
if (vm.count("list-canvases"))
{
- print_child_canvases(job_list.front().filename() + "#",
-
job_list.front().root());
+ print_child_canvases(job_list.front().filename + "#",
+
job_list.front().root);
cerr << endl;
@@ -838,7 +858,7 @@ int main(int ac, char* av[])
if(job_list.front().outfilename.empty())
{
job_list.front().outfilename =
-
filename_sans_extension(job_list.front().filename()) + '.';
+
filename_sans_extension(job_list.front().filename) + '.';
if(Target::book().count(target_name))
job_list.front().outfilename +=
@@ -873,7 +893,7 @@ int main(int ac, char* av[])
{
if(!job_list.front().target)
{
- cerr << _("Unknown target for ") <<
job_list.front().filename()
+ cerr << _("Unknown target for ") <<
job_list.front().filename
<< ": " << target_name << endl;
cerr << _("Throwing out job...") << endl;
job_list.pop_front();
@@ -907,7 +927,7 @@ int main(int ac, char* av[])
for(; job_list.size(); job_list.pop_front())
{
- VERBOSE_OUT(3) << job_list.front().filename() << " -- "
<< endl;
+ VERBOSE_OUT(3) << job_list.front().filename << " -- "
<< endl;
VERBOSE_OUT(3) << '\t'
<<
strprintf("w:%d, h:%d, a:%d, pxaspect:%f,
imaspect:%f, span:%f",
@@ -933,7 +953,7 @@ int main(int ac, char* av[])
<< endl;
RenderProgress p;
- p.task(job_list.front().filename() + " ==> " +
+ p.task(job_list.front().filename + " ==> " +
job_list.front().outfilename);
if(job_list.front().sifout)
{
@@ -958,7 +978,7 @@ int main(int ac, char* av[])
}
if(print_benchmarks)
- cout << job_list.front().filename()
+ cout << job_list.front().filename
<< _(": Rendered in ") <<
timer()
<< _(" seconds.") << endl;
}
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl