1 /* === S Y N F I G ========================================================= */
2 /*!	\file tool/optionsprocessor.h
3 **	\brief Synfig Tool Options Processor Class
4 **
5 **	$Id$
6 **
7 **	\legal
8 **	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **	Copyright (c) 2007, 2008 Chris Moore
10 **	Copyright (c) 2009-2014 Diego Barrios Romero
11 **
12 **	This package is free software; you can redistribute it and/or
13 **	modify it under the terms of the GNU General Public License as
14 **	published by the Free Software Foundation; either version 2 of
15 **	the License, or (at your option) any later version.
16 **
17 **	This package is distributed in the hope that it will be useful,
18 **	but WITHOUT ANY WARRANTY; without even the implied warranty of
19 **	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 **	General Public License for more details.
21 **	\endlegal
22 */
23 /* ========================================================================= */
24 
25 #ifndef __SYNFIG_OPTIONSPROCESSOR_H
26 #define __SYNFIG_OPTIONSPROCESSOR_H
27 
28 #include <string>
29 #include <vector>
30 #include <synfig/canvas.h>
31 #include <boost/filesystem.hpp>
32 #include <boost/program_options.hpp>
33 
34 // TODO rename to CommandLineHandler and move the options creation inside.
35 /// Class to process all the command line options
36 class OptionsProcessor
37 {
38 public:
39 	OptionsProcessor(boost::program_options::variables_map& vm,
40 					 const boost::program_options::options_description& po_visible);
41 
42 #ifdef _DEBUG
43 	void process_debug_options() throw (SynfigToolException&);
44 #endif
45 
46 	/// Settings options
47 	/// verbose, quiet, threads, benchmarks
48 	void process_settings_options();
49 
50 	/// Information options
51 	/// Options that will only display information
52 	void process_info_options();
53 
54 	/// Extract the necessary options to create a job
55 	/// After this, it is necessary to overwrite the necessary RendDesc options
56 	/// and set the target parameters, if provided. Then can be processed
57 	Job extract_job();
58 
59 	/// Overwrite the input RendDesc object with the options given in the command line
60 	synfig::RendDesc extract_renddesc(const synfig::RendDesc& renddesc);
61 
62 	/// Extract the target parameters from the options given in the command line
63 	/// video-codec, bitrate, sequence-separator
64 	synfig::TargetParam extract_targetparam();
65 
66 	void print_target_video_codecs_help() const;
67 
68 private:
69 	/// Determine which parameters to show in the canvas info
70 	/// canvas-info
71 	void extract_canvas_info(Job& job);
72 
73 	boost::program_options::variables_map _vm;
74 	boost::program_options::options_description _po_visible;
75 
76 	struct VideoCodec
77 	{
VideoCodecVideoCodec78 		VideoCodec(const std::string& name_, const std::string& description_)
79 			: name(name_), description(description_)
80 		{ }
81 
82 		std::string name, description;
83 	};
84 	/*! \warning These codecs are linked to the filename extensions for
85 	 *  mod_ffmpeg. If you change this you must change the others accordingly.
86 	 */
87 	std::vector<VideoCodec> _allowed_video_codecs;
88 };
89 
90 #endif // __SYNFIG_OPTIONSPROCESSOR_H
91