39 #include "UniquePointer.h"
42 #include "Validator.h"
43 #include "IObserver.h"
53 namespace ArgusSamples
56 #if (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
60 static const char builderString[] =
62 #include "cameraBuilder.h"
65 #endif // (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
76 #ifdef GALLERY_SUPPORTED
80 #ifdef GALLERY_SUPPORTED
90 static const ValidatorEnum<Modules>::ValueStringPair s_modules[] =
95 #ifdef GALLERY_SUPPORTED
97 { MODULE_GALLERY,
"Gallery" }
113 virtual bool start();
124 virtual bool onKey(
const Key &key);
144 , m_module(new ValidatorEnum<
Modules>(
145 s_modules, sizeof(s_modules) / sizeof(s_modules[0])),
149 , m_iGuiMenuBar(NULL)
150 , m_iGuiContainerConfig(NULL)
163 const char *description =
164 "Press 'm' to toggle between modules (still capture, video recording, multi exposure, \n"
166 #ifdef GALLERY_SUPPORTED
167 "Press 'g' to switch to gallery and back. Use left and right arrow keys to move to next\n"
168 "and previous image or video.\n"
170 "Press 'space' to execute the module action (capture an image, start and stop recording,\n"
171 "start and stop video playback.\n";
172 PROPAGATE_ERROR(
m_options.addDescription(description));
175 createValueOption(
"module", 0,
"MODULE",
"switch to module MODULE.",
m_module)));
177 #if (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
178 Window::IGuiBuilder *builder = NULL;
179 PROPAGATE_ERROR(Window::IGuiBuilder::create(builderString, &builder));
181 UniquePointer<Window::IGuiBuilder> createdBuilder(builder);
182 UniquePointer<Window::IGuiElement> createdWindow(createdBuilder->createElement(
"window"));
183 UniquePointer<Window::IGuiElement> createdView(createdBuilder->createElement(
"view"));
186 static_cast<Window::IGuiMenuBar*
>(createdBuilder->createElement(
"menuBar"));
188 static_cast<Window::IGuiContainer*
>(createdBuilder->createElement(
"config"));
191 PROPAGATE_ERROR(Window::getInstance().setWindowGui(createdBuilder.get(), createdWindow.get(),
194 createdView.release();
195 createdWindow.release();
196 createdBuilder.release();
197 #endif // (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
202 UniquePointer<IAppModule> module;
205 ORIGINATE_ERROR(
"Out of memory");
210 ORIGINATE_ERROR(
"Out of memory");
215 ORIGINATE_ERROR(
"Out of memory");
220 ORIGINATE_ERROR(
"Out of memory");
223 #ifdef GALLERY_SUPPORTED
226 ORIGINATE_ERROR(
"Out of memory");
227 m_modules[MODULE_GALLERY] = module.release();
234 for (std::vector<IAppModule*>::iterator it =
m_modules.begin(); it !=
m_modules.end(); ++it)
235 PROPAGATE_ERROR((*it)->initialize(
m_options));
243 for (std::vector<IAppModule*>::iterator it =
m_modules.begin(); it !=
m_modules.end(); ++it)
245 PROPAGATE_ERROR((*it)->shutdown());
253 m_iGuiContainerConfig = NULL;
268 UniquePointer<Window::IGuiElement> element;
270 assert(
sizeof(
Modules) ==
sizeof(Window::IGuiElement::ValueTypeEnum));
271 PROPAGATE_ERROR(Window::IGuiElement::createValue(
272 reinterpret_cast<Value<Window::IGuiElement::ValueTypeEnum>*
>(&
m_module), &element));
281 PROPAGATE_ERROR(
m_module.registerObserver(
this,
294 #ifdef GALLERY_SUPPORTED
302 curModule =
static_cast<Modules>(curModule + 1);
303 #ifdef GALLERY_SUPPORTED
305 while (curModule == MODULE_GALLERY);
310 #ifdef GALLERY_SUPPORTED
311 else if (key == Key(
"g"))
316 if (curModule == MODULE_GALLERY)
323 curModule = MODULE_GALLERY;
337 assert(
static_cast<const Value<Modules>&
>(source).
get() ==
m_module);
351 int main(
int argc,
char **argv)
353 printf(
"Executing Argus Sample Application (%s)\n", basename(argv[0]));
357 if (!cameraApp.
run(argc, argv))