Panda3D
 All Classes Functions Variables Enumerations
buttonEventList.h
00001 // Filename: buttonEventList.h
00002 // Created by:  drose (12Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef BUTTONEVENTLIST_H
00016 #define BUTTONEVENTLIST_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "buttonEvent.h"
00021 #include "typedReferenceCount.h"
00022 #include "eventParameter.h"
00023 #include "pvector.h"
00024 
00025 class ModifierButtons;
00026 class Datagram;
00027 class DatagramIterator;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : ButtonEventList
00031 // Description : Records a set of button events that happened
00032 //               recently.  This class is usually used only in the
00033 //               data graph, to transmit the recent button presses,
00034 //               but it may be used anywhere a list of ButtonEvents
00035 //               is desired.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_PANDA_EVENT ButtonEventList : public EventStoreValueBase {
00038 public:
00039   INLINE ButtonEventList();
00040   INLINE ButtonEventList(const ButtonEventList &copy);
00041   INLINE void operator = (const ButtonEventList &copy);
00042 
00043   INLINE void add_event(ButtonEvent event);
00044   INLINE int get_num_events() const;
00045   INLINE const ButtonEvent &get_event(int n) const;
00046   INLINE void clear();
00047 
00048   void add_events(const ButtonEventList &other);
00049   void update_mods(ModifierButtons &mods) const;
00050 
00051   virtual void output(ostream &out) const;
00052   void write(ostream &out, int indent_level = 0) const;
00053 
00054 private:
00055   typedef pvector<ButtonEvent> Events;
00056   Events _events;
00057 
00058 public:
00059   static void register_with_read_factory();
00060   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00061 
00062 protected:
00063   static TypedWritable *make_from_bam(const FactoryParams &params);
00064 
00065 public:
00066   void fillin(DatagramIterator &scan, BamReader *manager);
00067   
00068 public:
00069   static TypeHandle get_class_type() {
00070     return _type_handle;
00071   }
00072   static void init_type() {
00073     EventStoreValueBase::init_type();
00074     register_type(_type_handle, "ButtonEventList",
00075                   EventStoreValueBase::get_class_type());
00076   }
00077   virtual TypeHandle get_type() const {
00078     return get_class_type();
00079   }
00080   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00081 
00082 private:
00083   static TypeHandle _type_handle;
00084 };
00085 
00086 INLINE ostream &operator << (ostream &out, const ButtonEventList &buttonlist) {
00087   buttonlist.output(out);
00088   return out;
00089 }
00090 
00091 #include "buttonEventList.I"
00092 
00093 #endif
00094 
 All Classes Functions Variables Enumerations