##

KeyEventHandler.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 _GAZEBO_GUI_KEYEVENTHANDLER_HH_
#define _GAZEBO_GUI_KEYEVENTHANDLER_HH_
#include <list>
#include <memory>
#include <string>
#include <boost/function.hpp>
#include "gazebo/common/SingletonT.hh"
#include "gazebo/util/system.hh"
GZ_SINGLETON_DECLARE(GZ_GUI_VISIBLE, gazebo, gui, KeyEventHandler)
namespace gazebo
{
namespace common
{
class KeyEvent;
}
namespace gui
{
class KeyEventHandlerPrivate;
class GZ_GUI_VISIBLE KeyEventHandler : public SingletonT<KeyEventHandler>
{
public: typedef boost::function<bool (const common::KeyEvent &_event)>
KeyEventFilter;
public: class Filter
{
public: Filter(const std::string &_name,
KeyEventFilter _func)
: name(_name), func(_func) {}
public: bool operator==(const Filter &_f) const
{
return this->name == _f.name;
}
public: bool operator==(const std::string &_f) const
{
return this->name == _f;
}
public: std::string name;
public: KeyEventFilter func;
};
private: KeyEventHandler();
private: virtual ~KeyEventHandler();
public: void AddPressFilter(const std::string &_name,
KeyEventFilter _filter);
public: void AddReleaseFilter(const std::string &_name,
KeyEventFilter _filter);
public: void RemovePressFilter(const std::string &_name);
public: void RemoveReleaseFilter(const std::string &_name);
public: bool HandlePress(const common::KeyEvent &_event);
public: bool HandleRelease(const common::KeyEvent &_event);
public: bool AutoRepeat() const;
public: void SetAutoRepeat(const bool _autorepeat);
private: void Add(const std::string &_name, KeyEventFilter _filter,
std::list<Filter> &_list);
private: void Remove(const std::string &_name, std::list<Filter> &_list);
private: bool Handle(const common::KeyEvent &_event,
std::list<Filter> &_list);
private: friend class SingletonT<KeyEventHandler>;
private: std::unique_ptr<KeyEventHandlerPrivate> dataPtr;
};
}
}
#endif
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
SingletonT
Singleton template class.
Definition: SingletonT.hh:33
common
common
Definition: FuelModelDatabase.hh:37
system.hh
gazebo
gazebo
Definition: KeyEventHandler.hh:29
gui
gui
Definition: KeyEventHandler.hh:29
GZ_SINGLETON_DECLARE
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61
SingletonT.hh