Author: Diego Barrios Romero <eldr...@eldruin.com> Date: Mon Feb 13 19:54:45 2012 +0100
Filename and root canvas handle privatized preventing inconsistencies Since the inclusion of the load_file method, it would be inconsisent if the file for the job, and its opened root canvas pointer were externally changed. Hence privatized and const accesor methods were implemented. --- synfig-core/src/tool/job.cpp | 20 +++++++++++++++----- synfig-core/src/tool/job.h | 12 +++++++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/synfig-core/src/tool/job.cpp b/synfig-core/src/tool/job.cpp index ccc14be..9125e59 100644 --- a/synfig-core/src/tool/job.cpp +++ b/synfig-core/src/tool/job.cpp @@ -59,23 +59,23 @@ Job::Job() sifout = false; } -int Job::load_file (string _filename) +int Job::load_file (string filename) { - filename = _filename; + _filename = filename; // Open the composition string errors, warnings; try { - root=open_canvas(filename, errors, warnings); + _root = open_canvas(_filename, errors, warnings); } catch(runtime_error x) { - root = 0; + _root = 0; } // By default, the canvas to render is the root canvas // This can be changed through --canvas option - canvas = root; + canvas = _root; if(!canvas) { @@ -87,3 +87,13 @@ int Job::load_file (string _filename) 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 cb2ae49..2c9149e 100644 --- a/synfig-core/src/tool/job.h +++ b/synfig-core/src/tool/job.h @@ -25,14 +25,16 @@ #ifndef __SYNFIG_JOB_H #define __SYNFIG_JOB_H -struct Job +class Job { - std::string filename; + std::string _filename; + synfig::Canvas::Handle _root; + +public: std::string outfilename; synfig::RendDesc desc; - synfig::Canvas::Handle root; synfig::Canvas::Handle canvas; synfig::Target::Handle target; @@ -55,6 +57,10 @@ struct Job Job(); int load_file (std::string filename); + + std::string filename() const; + + synfig::Canvas::Handle root() const; }; #endif ------------------------------------------------------------------------------ Try before you buy = See our experts in action! 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-dev2 _______________________________________________ Synfig-devl mailing list Synfig-devl@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synfig-devl