Panda3D
eventParameter.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 eventParameter.h
10  * @author drose
11  * @date 1999-02-08
12  */
13 
14 #ifndef EVENTPARAMETER_H
15 #define EVENTPARAMETER_H
16 
17 #include "pandabase.h"
18 
19 #include "typedef.h"
20 #include "typedObject.h"
22 #include "pointerTo.h"
23 #include "bamReader.h"
24 #include "bamWriter.h"
25 #include "paramValue.h"
26 
27 /**
28  * An optional parameter associated with an event. Each event may have zero
29  * or more of these. Each parameter stores a pointer to a
30  * TypedWritableReferenceCount object, which of course could be pretty much
31  * anything. To store a simple value like a double or a string, the
32  * EventParameter constructors transparently use the ParamValue template class
33  * from paramValue.h.
34  */
35 class EXPCL_PANDA_EVENT EventParameter {
36 PUBLISHED:
37  INLINE EventParameter() = default;
38  INLINE EventParameter(std::nullptr_t) {};
40  INLINE EventParameter(const TypedReferenceCount *ptr);
41  INLINE EventParameter(int value);
42  INLINE EventParameter(double value);
43  INLINE EventParameter(const std::string &value);
44  INLINE EventParameter(const std::wstring &value);
45 
46  INLINE EventParameter(const EventParameter &copy);
47  INLINE EventParameter &operator = (const EventParameter &copy);
48  INLINE ~EventParameter();
49 
50  // These functions are conveniences to easily determine if the
51  // EventParameter is one of the predefined parameter types, and retrieve the
52  // corresponding value. Of course, it is possible that the EventParameter
53  // is some user-defined type, and is none of these.
54  INLINE bool is_empty() const;
55  INLINE bool is_int() const;
56  INLINE int get_int_value() const;
57  INLINE bool is_double() const;
58  INLINE double get_double_value() const;
59  INLINE bool is_string() const;
60  INLINE std::string get_string_value() const;
61  INLINE bool is_wstring() const;
62  INLINE std::wstring get_wstring_value() const;
63 
64  INLINE bool is_typed_ref_count() const;
65  INLINE TypedReferenceCount *get_typed_ref_count_value() const;
66 
67  INLINE TypedWritableReferenceCount *get_ptr() const;
68 
69  void output(std::ostream &out) const;
70 
71 private:
73 };
74 
75 INLINE std::ostream &operator << (std::ostream &out, const EventParameter &param);
76 
78 
79 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, ParamValue<int>);
80 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, ParamValue<double>);
81 
86 
87 #include "eventParameter.I"
88 
89 #endif
An optional parameter associated with an event.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class object for storing specifically objects of type TypedReferenceCount, which is different than ...
Definition: paramValue.h:62
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
Definition: paramValue.h:103
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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 base class for things which need to inherit from both TypedWritable and from ReferenceCount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.