ViewFactory.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef _VIEWERFACTORY_HH_
19 #define _VIEWERFACTORY_HH_
20 
21 #include <string>
22 #include <map>
23 #include <vector>
24 
25 #include "gazebo/gui/GuiTypes.hh"
26 #include "gazebo/util/system.hh"
27 
28 class QWidget;
29 
30 namespace gazebo
31 {
32  namespace gui
33  {
36  typedef TopicView* (*ViewFactoryFn) (QWidget *_parent);
37 
43  class GZ_GUI_VISIBLE ViewFactory
44  {
46  public: static void RegisterAll();
47 
52  public: static void RegisterView(const std::string &_className,
53  ViewFactoryFn _factoryfn);
54 
60  public: static TopicView *NewView(const std::string &_msgType,
61  const std::string &_topicName,
62  QWidget *_parent = NULL);
63 
66  public: static void GetViewTypes(std::vector<std::string> &_types);
67 
69  private: static std::map<std::string, ViewFactoryFn> viewMap;
70  };
71 
72 
78  #define GZ_REGISTER_STATIC_VIEWER(msgtype, classname) \
79  GZ_GUI_VISIBLE TopicView *New##classname(QWidget *_parent) \
80  { \
81  return new gazebo::gui::classname(_parent); \
82  } \
83  GZ_GUI_VISIBLE \
84  void Register##classname() \
85  {\
86  ViewFactory::RegisterView(msgtype, New##classname);\
87  }
88  }
90 }
91 
92 #endif
TopicView *(* ViewFactoryFn)(QWidget *_parent)
Definition: ViewFactory.hh:36
Forward declarations for the common classes.
Definition: Animation.hh:33
The view factory creates GUI widgets to visualize data on a topic.
Definition: ViewFactory.hh:43
Base class for widgets that display topic data.
Definition: TopicView.hh:78
#define NULL
Definition: CommonTypes.hh:31
default namespace for gazebo