34 #include "UniquePointer.h"
37 #include "Validator.h"
38 #include "IObserver.h"
48 namespace ArgusSamples
51 #if (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
55 static const char builderString[] =
57 #include "cameraBuilder.h"
60 #endif // (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
80 static const ValidatorEnum<Modules>::ValueStringPair s_modules[] =
104 static bool module(
void *userPtr,
const char *optArg);
115 virtual bool onKey(
const Key &key);
135 , m_module(new ValidatorEnum<
Modules>(
136 s_modules, sizeof(s_modules) / sizeof(s_modules[0])),
140 , m_iGuiMenuBar(NULL)
141 , m_iGuiContainerConfig(NULL)
153 PROPAGATE_ERROR(cameraApp->
m_module.setFromString(optArg));
161 const char *description =
162 "Press 'm' to toggle between modules (still capture, video recording, multi exposure, \n"
168 "Press 'g' to switch to gallery and back. Use left and right arrow keys to move to next\n"
169 "and previous image or video.\n"
171 "Press 'space' to execute the module action (capture an image, start and stop recording,\n"
172 "start and stop video playback.\n";
179 #if (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
180 Window::IGuiBuilder *builder = NULL;
181 PROPAGATE_ERROR(Window::IGuiBuilder::create(builderString, &builder));
183 UniquePointer<Window::IGuiBuilder> createdBuilder(builder);
184 UniquePointer<Window::IGuiElement> createdWindow(createdBuilder->createElement(
"window"));
185 UniquePointer<Window::IGuiElement> createdView(createdBuilder->createElement(
"view"));
188 static_cast<Window::IGuiMenuBar*
>(createdBuilder->createElement(
"menuBar"));
190 static_cast<Window::IGuiContainer*
>(createdBuilder->createElement(
"config"));
193 PROPAGATE_ERROR(Window::getInstance().setWindowGui(createdBuilder.get(), createdWindow.get(),
196 createdView.release();
197 createdWindow.release();
198 createdBuilder.release();
199 #endif // (WINDOW_GUI_SUPPORT == WINDOW_GUI_GTK)
204 UniquePointer<IAppModule>
module;
207 ORIGINATE_ERROR(
"Out of memory");
212 ORIGINATE_ERROR(
"Out of memory");
217 ORIGINATE_ERROR(
"Out of memory");
222 ORIGINATE_ERROR(
"Out of memory");
227 ORIGINATE_ERROR(
"Out of memory");
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_CONTINUE(
m_module.registerObserver(
this,
300 curModule =
static_cast<Modules>(curModule + 1);
310 else if (key == Key(
"g"))
336 assert(
static_cast<const Value<Modules>&
>(source).
get() ==
m_module);
350 int main(
int argc,
char **argv)
354 if (!cameraApp.
run(argc, argv))