Device 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSGGA_EVENTSOURCE
  14. #define OSGGA_EVENTSOURCE 1
  15. #include <osgGA/EventQueue>
  16. namespace osgGA {
  17. /**
  18. * Device base class from abstracting away from devices/windows that can generate events.
  19. */
  20. class OSGGA_EXPORT Device : public osg::Object
  21. {
  22. public:
  23. enum Capabilities
  24. {
  25. UNKNOWN = 0,
  26. RECEIVE_EVENTS = 1,
  27. SEND_EVENTS = 2
  28. };
  29. Device();
  30. Device(const Device& es, const osg::CopyOp& copyop);
  31. META_Object(osgGA,Device);
  32. int getCapabilities() const { return _capabilities; }
  33. virtual bool checkEvents() { return _eventQueue.valid() ? !(getEventQueue()->empty()) : false; }
  34. virtual void sendEvent(const Event& ea);
  35. virtual void sendEvents(const EventQueue::Events& events);
  36. void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; }
  37. osgGA::EventQueue* getEventQueue() { return _eventQueue.get(); }
  38. const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); }
  39. protected:
  40. void setCapabilities(int capabilities) { _capabilities = capabilities; }
  41. virtual ~Device();
  42. /** Prevent unwanted copy operator.*/
  43. Device& operator = (const Device&) { return *this; }
  44. osg::ref_ptr<osgGA::EventQueue> _eventQueue;
  45. private:
  46. int _capabilities;
  47. };
  48. }
  49. #endif