cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsQtWidgetFactory.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): Praneeth Sadda, Anton Deguet
7  Created on: 2011-11-11
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 _mtsQtWidgetFactory_h
23 #define _mtsQtWidgetFactory_h
24 
25 #include <typeinfo>
26 #include <map>
27 
28 // Always include last
30 
31 // Qt forward declarations
32 class QWidget;
33 
34 // mts Qt forward declaration
37 
38 
40 {
41 public:
42  inline bool operator()(const std::type_info* a, const std::type_info* b) const {
43  // Visual Studio (some versions) have "int before()"
44  return (a->before(*b)) == 0 ? false : true;
45  }
46 };
47 
49 {
50  typedef mtsQtWidgetGenericObjectRead * (*WidgetReadCreatorFunction)(void);
51  typedef mtsQtWidgetGenericObjectWrite * (*WidgetWriteCreatorFunction)(void);
52 
53  friend class WidgetReadCreator;
54  friend class WidgetWriteCreator;
55 
56  public:
58  {
59  private:
60  WidgetReadCreator(void);
61  public:
62  WidgetReadCreator(const std::type_info * type, WidgetReadCreatorFunction function);
63  };
64 
66  {
67  private:
68  WidgetWriteCreator(void);
69  public:
70  WidgetWriteCreator(const std::type_info * type, WidgetWriteCreatorFunction function);
71  };
72 
73  typedef std::map<const std::type_info *, WidgetReadCreatorFunction, mtsQtTypeInfoComparator> WidgetReadCreatorMap;
74  typedef std::map<const std::type_info *, WidgetWriteCreatorFunction, mtsQtTypeInfoComparator> WidgetWriteCreatorMap;
75 
76  static mtsQtWidgetGenericObjectRead * CreateWidgetRead(const std::type_info * type);
77  static mtsQtWidgetGenericObjectWrite * CreateWidgetWrite(const std::type_info * type);
78 
79 
80  protected:
81  static WidgetReadCreatorMap & GetWidgetReadCreators(void);
82  static WidgetWriteCreatorMap & GetWidgetWriteCreators(void);
83 };
84 
85 #endif // _mtsQtWidgetFactory_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: mtsQtWidgetFactory.h:48
Definition: mtsQtWidgetFactory.h:65
bool operator()(const std::type_info *a, const std::type_info *b) const
Definition: mtsQtWidgetFactory.h:42
std::map< const std::type_info *, WidgetWriteCreatorFunction, mtsQtTypeInfoComparator > WidgetWriteCreatorMap
Definition: mtsQtWidgetFactory.h:74
Definition: mtsQtWidgetGenericObject.h:35
Definition: mtsQtWidgetFactory.h:39
Definition: mtsQtWidgetGenericObject.h:48
std::map< const std::type_info *, WidgetReadCreatorFunction, mtsQtTypeInfoComparator > WidgetReadCreatorMap
Definition: mtsQtWidgetFactory.h:73
Rules of exporting.
Definition: mtsQtWidgetFactory.h:57