Panda3D
buttonEventList.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file buttonEventList.h
10  * @author drose
11  * @date 2002-03-12
12  */
13 
14 #ifndef BUTTONEVENTLIST_H
15 #define BUTTONEVENTLIST_H
16 
17 #include "pandabase.h"
18 
19 #include "buttonEvent.h"
20 #include "typedReferenceCount.h"
21 #include "eventParameter.h"
22 #include "pvector.h"
23 
24 class ModifierButtons;
25 class Datagram;
26 class DatagramIterator;
27 
28 /**
29  * Records a set of button events that happened recently. This class is
30  * usually used only in the data graph, to transmit the recent button presses,
31  * but it may be used anywhere a list of ButtonEvents is desired.
32  */
33 class EXPCL_PANDA_EVENT ButtonEventList : public ParamValueBase {
34 PUBLISHED:
35  INLINE ButtonEventList();
36  INLINE ButtonEventList(const ButtonEventList &copy);
37  INLINE void operator = (const ButtonEventList &copy);
38 
39  INLINE void add_event(ButtonEvent event);
40  INLINE int get_num_events() const;
41  INLINE const ButtonEvent &get_event(int n) const;
42  INLINE void clear();
43 
44  void add_events(const ButtonEventList &other);
45  void update_mods(ModifierButtons &mods) const;
46 
47  virtual void output(std::ostream &out) const;
48  void write(std::ostream &out, int indent_level = 0) const;
49 
50 private:
52  Events _events;
53 
54 public:
55  static void register_with_read_factory();
56  virtual void write_datagram(BamWriter *manager, Datagram &dg);
57 
58 protected:
59  static TypedWritable *make_from_bam(const FactoryParams &params);
60 
61 public:
62  void fillin(DatagramIterator &scan, BamReader *manager);
63 
64 public:
65  static TypeHandle get_class_type() {
66  return _type_handle;
67  }
68  static void init_type() {
69  ParamValueBase::init_type();
70  register_type(_type_handle, "ButtonEventList",
71  ParamValueBase::get_class_type());
72  }
73  virtual TypeHandle get_type() const {
74  return get_class_type();
75  }
76  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
77 
78 private:
79  static TypeHandle _type_handle;
80 };
81 
82 INLINE std::ostream &operator << (std::ostream &out, const ButtonEventList &buttonlist) {
83  buttonlist.output(out);
84  return out;
85 }
86 
87 #include "buttonEventList.I"
88 
89 #endif
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:110
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
Records a button event of some kind.
Definition: buttonEvent.h:46
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'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:31
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.