39 #include "UniquePointer.h"
42 #include "Validator.h"
43 #include "IObserver.h"
52 namespace ArgusSamples
55 #if (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
59 static const char builderString[] =
61 #include "cameraBuilder.h"
64 #endif // (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
74 #ifdef GALLERY_SUPPORTED
78 #ifdef GALLERY_SUPPORTED
88 static const ValidatorEnum<Modules>::ValueStringPair s_modules[] =
92 #ifdef GALLERY_SUPPORTED
94 { MODULE_GALLERY,
"Gallery" }
110 virtual bool start();
121 virtual bool onKey(
const Key &key);
141 , m_module(new ValidatorEnum<
Modules>(
142 s_modules, sizeof(s_modules) / sizeof(s_modules[0])),
146 , m_iGuiMenuBar(NULL)
147 , m_iGuiContainerConfig(NULL)
160 const char *description =
161 "Press 'm' to toggle between modules (still capture, video recording, multi exposure, \n"
163 #ifdef GALLERY_SUPPORTED
164 "Press 'g' to switch to gallery and back. Use left and right arrow keys to move to next\n"
165 "and previous image or video.\n"
167 "Press 'space' to execute the module action (capture an image, start and stop recording,\n"
168 "start and stop video playback.\n";
169 PROPAGATE_ERROR(
m_options.addDescription(description));
172 createValueOption(
"module", 0,
"MODULE",
"switch to module MODULE.",
m_module)));
174 #if (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
175 Window::IGuiBuilder *builder = NULL;
176 PROPAGATE_ERROR(Window::IGuiBuilder::create(builderString, &builder));
178 UniquePointer<Window::IGuiBuilder> createdBuilder(builder);
179 UniquePointer<Window::IGuiElement> createdWindow(createdBuilder->createElement(
"window"));
180 UniquePointer<Window::IGuiElement> createdView(createdBuilder->createElement(
"view"));
183 static_cast<Window::IGuiMenuBar*
>(createdBuilder->createElement(
"menuBar"));
185 static_cast<Window::IGuiContainer*
>(createdBuilder->createElement(
"config"));
188 PROPAGATE_ERROR(Window::getInstance().setWindowGui(createdBuilder.get(), createdWindow.get(),
191 createdView.release();
192 createdWindow.release();
193 createdBuilder.release();
194 #endif // (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
199 UniquePointer<IAppModule> module;
202 ORIGINATE_ERROR(
"Out of memory");
207 ORIGINATE_ERROR(
"Out of memory");
212 ORIGINATE_ERROR(
"Out of memory");
215 #ifdef GALLERY_SUPPORTED
218 ORIGINATE_ERROR(
"Out of memory");
219 m_modules[MODULE_GALLERY] = module.release();
226 for (std::vector<IAppModule*>::iterator it =
m_modules.begin(); it !=
m_modules.end(); ++it)
227 PROPAGATE_ERROR((*it)->initialize(
m_options));
235 for (std::vector<IAppModule*>::iterator it =
m_modules.begin(); it !=
m_modules.end(); ++it)
237 PROPAGATE_ERROR((*it)->shutdown());
245 m_iGuiContainerConfig = NULL;
260 UniquePointer<Window::IGuiElement> element;
262 assert(
sizeof(
Modules) ==
sizeof(Window::IGuiElement::ValueTypeEnum));
263 PROPAGATE_ERROR(Window::IGuiElement::createValue(
264 reinterpret_cast<Value<Window::IGuiElement::ValueTypeEnum>*
>(&
m_module), &element));
273 PROPAGATE_ERROR(
m_module.registerObserver(
this,
286 #ifdef GALLERY_SUPPORTED
294 curModule =
static_cast<Modules>(curModule + 1);
295 #ifdef GALLERY_SUPPORTED
297 while (curModule == MODULE_GALLERY);
302 #ifdef GALLERY_SUPPORTED
303 else if (key == Key(
"g"))
308 if (curModule == MODULE_GALLERY)
315 curModule = MODULE_GALLERY;
329 assert(
static_cast<const Value<Modules>&
>(source).
get() ==
m_module);
343 int main(
int argc,
char **argv)
345 printf(
"Executing Argus Sample Application (%s)\n", basename(argv[0]));
349 if (!cameraApp.
run(argc, argv))