##

ViewFactory.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _VIEWERFACTORY_HH_
#define _VIEWERFACTORY_HH_
#include <string>
#include <map>
#include <vector>
#include "gazebo/gui/GuiTypes.hh"
#include "gazebo/util/system.hh"
class QWidget;
namespace gazebo
{
namespace gui
{
typedef TopicView* (*ViewFactoryFn) (QWidget *_parent);
class GZ_GUI_VISIBLE ViewFactory
{
public: static void RegisterAll();
public: static void RegisterView(const std::string &_className,
ViewFactoryFn _factoryfn);
public: static TopicView *NewView(const std::string &_msgType,
const std::string &_topicName,
QWidget *_parent = NULL);
public: static void GetViewTypes(std::vector<std::string> &_types);
private: static std::map<std::string, ViewFactoryFn> viewMap;
};
#define GZ_REGISTER_STATIC_VIEWER(msgtype, classname) \
GZ_GUI_VISIBLE TopicView *New##classname(QWidget *_parent) \
{ \
return new gazebo::gui::classname(_parent); \
} \
GZ_GUI_VISIBLE \
void Register##classname() \
{\
ViewFactory::RegisterView(msgtype, New##classname);\
}
}
}
#endif
gazebo::gui::ViewFactoryFn
TopicView *(* ViewFactoryFn)(QWidget *_parent)
Definition: ViewFactory.hh:36
gazebo::gui::ViewFactory::NewView
static TopicView * NewView(const std::string &_msgType, const std::string &_topicName, QWidget *_parent=NULL)
Create a new instance of a view.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
NULL
#define NULL
Definition: CommonTypes.hh:31
system.hh
gazebo::gui::ViewFactory::RegisterView
static void RegisterView(const std::string &_className, ViewFactoryFn _factoryfn)
Register a view class (called by view registration function).
gazebo::gui::ViewFactory::RegisterAll
static void RegisterAll()
Register all known views.
gazebo::gui::ViewFactory::GetViewTypes
static void GetViewTypes(std::vector< std::string > &_types)
Get all the view types.
gazebo::gui::ViewFactory
The view factory creates GUI widgets to visualize data on a topic.
Definition: ViewFactory.hh:43
GuiTypes.hh
default namespace for gazebo
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::TopicView
Base class for widgets that display topic data.
Definition: TopicView.hh:78