Panda3D
buttonEventList.h
1 // Filename: buttonEventList.h
2 // Created by: drose (12Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef BUTTONEVENTLIST_H
16 #define BUTTONEVENTLIST_H
17 
18 #include "pandabase.h"
19 
20 #include "buttonEvent.h"
21 #include "typedReferenceCount.h"
22 #include "eventParameter.h"
23 #include "pvector.h"
24 
25 class ModifierButtons;
26 class Datagram;
27 class DatagramIterator;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : ButtonEventList
31 // Description : Records a set of button events that happened
32 // recently. This class is usually used only in the
33 // data graph, to transmit the recent button presses,
34 // but it may be used anywhere a list of ButtonEvents
35 // is desired.
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_PANDA_EVENT ButtonEventList : public ParamValueBase {
38 public:
39  INLINE ButtonEventList();
40  INLINE ButtonEventList(const ButtonEventList &copy);
41  INLINE void operator = (const ButtonEventList &copy);
42 
43  INLINE void add_event(ButtonEvent event);
44  INLINE int get_num_events() const;
45  INLINE const ButtonEvent &get_event(int n) const;
46  INLINE void clear();
47 
48  void add_events(const ButtonEventList &other);
49  void update_mods(ModifierButtons &mods) const;
50 
51  virtual void output(ostream &out) const;
52  void write(ostream &out, int indent_level = 0) const;
53 
54 private:
56  Events _events;
57 
58 public:
59  static void register_with_read_factory();
60  virtual void write_datagram(BamWriter *manager, Datagram &dg);
61 
62 protected:
63  static TypedWritable *make_from_bam(const FactoryParams &params);
64 
65 public:
66  void fillin(DatagramIterator &scan, BamReader *manager);
67 
68 public:
69  static TypeHandle get_class_type() {
70  return _type_handle;
71  }
72  static void init_type() {
73  ParamValueBase::init_type();
74  register_type(_type_handle, "ButtonEventList",
75  ParamValueBase::get_class_type());
76  }
77  virtual TypeHandle get_type() const {
78  return get_class_type();
79  }
80  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
81 
82 private:
83  static TypeHandle _type_handle;
84 };
85 
86 INLINE ostream &operator << (ostream &out, const ButtonEventList &buttonlist) {
87  buttonlist.output(out);
88  return out;
89 }
90 
91 #include "buttonEventList.I"
92 
93 #endif
94 
This class monitors the state of a number of individual buttons and tracks whether each button is kno...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
Records a button event of some kind.
Definition: buttonEvent.h:53
Records a set of button events that happened recently.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class&#39;s make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A non-template base class of ParamValue (below), which serves mainly to define the placeholder for th...
Definition: paramValue.h:34
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43