Lumiera  0.pre.03
»edit your freedom«
option.cpp
Go to the documentation of this file.
1 /*
2  Option - handle cmdline for starting the Lumiera application
3 
4  Copyright (C)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
14 
21 #include "lib/error.hpp"
22 #include "lib/util.hpp"
23 #include "common/option.hpp"
24 
25 
26 
27 typedef boost::program_options::options_description Syntax;
28 typedef boost::program_options::variables_map VarMap;
29 
30 namespace op = boost::program_options;
31 
32 using lib::VectS;
33 
34 
35 namespace lumiera {
36 
49  : syntax("Lumiera, the non linear video editor.\nSupported parameters"),
50  parameters()
51  {
52  syntax.add_options()
53  ("help,h", "produce help message")
54  ("session,f", op::value<string>(),
55  "session file to load (UNIMPLEMENTED)")
56  ("script,s", op::value<VectS>(),
57  "execute the given script (UNIMPLEMENTED)")
58  ("headless", op::bool_switch(),
59  "start without GUI")
60  ("port,p", op::value<int>(),
61  "open renderfarm node at given port (UNIMPLEMENTED)")
62  ("define,def,D",op::value<VectS>(),
63  "enter definition into config system (UNIMPLEMENTED)")
64  ;
65 
66  // the name of an session file to open...
67  op::positional_options_description posopt;
68  posopt.add("session", 1); // ... can be given as 1st positional parameter
69 
70  op::parsed_options parsed =
71  op::command_line_parser (cmdline)
72  .options (syntax)
73  .positional(posopt)
74  .allow_unregistered()
75  .run();
76 
77  op::store (parsed, parameters);
78  op::notify(parameters);
79 
80  // remove all recognised options from original cmdline vector
81  cmdline = op::collect_unrecognized(parsed.options, op::include_positional);
82 
83  if (isHelp())
84  {
85  cerr << *this;
86  exit(-1);
87  }
88  if (isConfigDefs())
89  {
90  UNIMPLEMENTED ("feed definitions from commandline to Config system");
91  }
92  }
93 
94 
95 
97  bool Option::isHelp () { return (parameters.count("help")); }
98 
100  bool Option::isOpenSession () { return (parameters.count ("session")); }
101 
103  bool Option::isConfigDefs () { return (parameters.count ("define")); }
104 
105 
107  const string
109  {
110  ASSERT (parameters.count ("session"));
111  return parameters["session"].as<string>();
112  }
113 
116  const VectS
118  {
119  return parameters["script"].as<VectS>();
120  }
121 
124  const VectS
126  {
127  return parameters["define"].as<VectS>();
128  }
129 
131  bool
133  {
134  return parameters["headless"].as<bool>();
135  }
136 
139  int
141  {
142  if (parameters.count ("port"))
143  return parameters["port"].as<int>();
144  else
145  return 0;
146  }
147 
148 
149 
150  ostream&
151  operator<< (ostream& os, const Option& ops)
152  {
153  return os << ops.syntax;
154  }
155 
156 
157 
158 } // namespace lumiera
const VectS getConfigDefs()
Definition: option.cpp:125
bool isOpenSession()
should an existing session file be loaded?
Definition: option.cpp:100
Option(lib::Cmdline &cmdline)
set up an options parser to use the application commandline.
Definition: option.cpp:48
Frontend for handling the Lumiera application commandline arguments.
Definition: option.hpp:68
bool isHeadless()
Definition: option.cpp:132
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
friend ostream & operator<<(ostream &, const Option &)
for outputting the help messages.
Definition: option.cpp:151
front-end for handling the commandline arguments.
bool isHelp()
syntax help requested?
Definition: option.cpp:97
bool isConfigDefs()
additional Config defs to fed to config system?
Definition: option.cpp:103
Lumiera error handling (C++ interface).
const string getSessName()
Definition: option.cpp:108
Lumiera public interface.
Definition: advice.cpp:104
Abstraction of the usual int argc, int** argv-Commandline, to be able to treat it as a vector of stri...
Definition: cmdline.hpp:48
const VectS getScripts()
Definition: option.cpp:117