cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
svlQtObjectFactory.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Balazs P. Vagvolgyi
7  Created on: 2011-06-15
8 
9  (C) Copyright 2011 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 #ifndef _svlQtObjectFactory_h
23 #define _svlQtObjectFactory_h
24 
26 #include <QApplication>
27 #include <QObject>
28 
29 // Always include last!
31 
32 
33 #undef SETUP_QT_ENVIRONMENT
34 #define SETUP_QT_ENVIRONMENT(F) \
35  int (*_cisst_qt_main_funct_)(int argc, char** argv); \
36  int _cisst_qt_main_funct_argc_; \
37  char** _cisst_qt_main_funct_argv_; \
38  void* _cisst_qt_main_thread_proc_() { \
39  _cisst_qt_main_funct_(_cisst_qt_main_funct_argc_, _cisst_qt_main_funct_argv_); \
40  QApplication::instance()->exit(0); \
41  return 0; \
42  } \
43  int main(int argc, char** argv) \
44  { \
45  QApplication app(argc, argv); \
46  app.setQuitOnLastWindowClosed(false); \
47  svlQtObjectFactory::Init(); \
48  _cisst_qt_main_funct_ = F; \
49  _cisst_qt_main_funct_argc_ = argc; \
50  _cisst_qt_main_funct_argv_ = argv; \
51  osaThread thread; \
52  thread.Create(_cisst_qt_main_thread_proc_); \
53  app.exec(); \
54  return 0; \
55  }
56 
57 
58 // Forward declarations
59 class cmnGenericObject;
60 class osaCriticalSection;
61 
63 {
64  Q_OBJECT
65 
66 public:
67  static void Init();
68  static cmnGenericObject* Create(const std::string & classname);
69  static void Delete(cmnGenericObject* obj);
70 
71 private slots:
72  void QSlotCreate();
73  void QSlotDelete();
74 
75 private:
76  static svlQtObjectFactory* GetInstance();
79 
81 
82  std::string ClassName;
83  cmnGenericObject* Object;
84 };
85 
86 #endif // _svlQtObjectFactory_h
87 
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: svlQtObjectFactory.h:62
Definition: osaCriticalSection.h:36
Base class for high level objects.
Definition: cmnGenericObject.h:51
Declaration of osaThread.
Macros to export the symbols of cisstStereoVisionQt (in a Dll).