Panda3D

event.cxx

00001 // Filename: event.cxx
00002 // Created by:  drose (08Feb99)
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 #include "event.h"
00016 #include "config_event.h"
00017 
00018 TypeHandle Event::_type_handle;
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: Event::Constructor
00022 //       Access: Public
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 Event::
00026 Event(const string &event_name, EventReceiver *receiver) :
00027   _name(event_name)
00028 {
00029   _receiver = receiver;
00030 }
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: Event::Copy constructor
00034 //       Access: Public
00035 //  Description:
00036 ////////////////////////////////////////////////////////////////////
00037 Event::
00038 Event(const Event &copy) :
00039   _parameters(copy._parameters),
00040   _receiver(copy._receiver),
00041   _name(copy._name)
00042 {
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: Event::Copy Assignment Operator
00047 //       Access: Public
00048 //  Description:
00049 ////////////////////////////////////////////////////////////////////
00050 void Event::
00051 operator = (const Event &copy) {
00052   _parameters = copy._parameters;
00053   _receiver = copy._receiver;
00054   _name = copy._name;
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: Event::Destructor
00059 //       Access: Public
00060 //  Description:
00061 ////////////////////////////////////////////////////////////////////
00062 Event::
00063 ~Event() {
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: Event::add_parameter
00068 //       Access: Public
00069 //  Description:
00070 ////////////////////////////////////////////////////////////////////
00071 void Event::
00072 add_parameter(const EventParameter &obj) {
00073   _parameters.push_back(obj);
00074 }
00075 
00076 
00077 ////////////////////////////////////////////////////////////////////
00078 //     Function: Event::get_num_parameters
00079 //       Access: Public
00080 //  Description:
00081 ////////////////////////////////////////////////////////////////////
00082 int Event::
00083 get_num_parameters() const {
00084   return _parameters.size();
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: Event::get_parameter
00089 //       Access: Public
00090 //  Description:
00091 ////////////////////////////////////////////////////////////////////
00092 EventParameter Event::
00093 get_parameter(int n) const {
00094   nassertr(n >= 0 && n < (int)_parameters.size(), EventParameter(0));
00095   return _parameters[n];
00096 }
00097 
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 //     Function: Event::has_receiver
00101 //       Access: Public
00102 //  Description:
00103 ////////////////////////////////////////////////////////////////////
00104 bool Event::
00105 has_receiver() const {
00106   return _receiver != (EventReceiver *)NULL;
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: Event::get_receiver
00111 //       Access: Public
00112 //  Description:
00113 ////////////////////////////////////////////////////////////////////
00114 EventReceiver *Event::
00115 get_receiver() const {
00116   return _receiver;
00117 }
00118 
00119 ////////////////////////////////////////////////////////////////////
00120 //     Function: Event::set_receiver
00121 //       Access: Public
00122 //  Description:
00123 ////////////////////////////////////////////////////////////////////
00124 void Event::
00125 set_receiver(EventReceiver *receiver) {
00126   _receiver = receiver;
00127 }
00128 
00129 ////////////////////////////////////////////////////////////////////
00130 //     Function: Event::clear_receiver
00131 //       Access: Public
00132 //  Description:
00133 ////////////////////////////////////////////////////////////////////
00134 void Event::
00135 clear_receiver() {
00136   _receiver = (EventReceiver *)NULL;
00137 }
00138 
00139 ////////////////////////////////////////////////////////////////////
00140 //     Function: Event::output
00141 //       Access: Public
00142 //  Description:
00143 ////////////////////////////////////////////////////////////////////
00144 void Event::
00145 output(ostream &out) const {
00146   out << get_name();
00147 
00148   out << "(";
00149   for (ParameterList::const_iterator pi = _parameters.begin(); pi != _parameters.end(); ++pi) {
00150     if (pi != _parameters.begin()) {
00151       out << ", ";
00152     }
00153     out << (*pi);
00154   }
00155   out << ")";
00156 }
 All Classes Functions Variables Enumerations