[4744] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[7779] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[3955] | 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
[1853] | 17 | |
---|
[7779] | 18 | #include "signal_connector.h" |
---|
[1853] | 19 | |
---|
[7779] | 20 | namespace OrxGui |
---|
[3365] | 21 | { |
---|
[4320] | 22 | |
---|
[8035] | 23 | /** |
---|
| 24 | * @brief creates a clean SignalConnector |
---|
| 25 | */ |
---|
[7855] | 26 | SignalConnector::SignalConnector( ) |
---|
| 27 | { |
---|
| 28 | this->object = NULL; |
---|
| 29 | this->exec = NULL; |
---|
| 30 | } |
---|
| 31 | |
---|
[8035] | 32 | /** |
---|
| 33 | * @brief Creates a SignalConnector out of an ObjectPointer, and an Executor. |
---|
| 34 | * @param object the Object the Executor will apply to. |
---|
| 35 | * @param executor the Executor that will be executed. |
---|
| 36 | * @return a new SignalConnector. |
---|
| 37 | */ |
---|
[7779] | 38 | SignalConnector::SignalConnector(BaseObject* object, const Executor* executor) |
---|
[7855] | 39 | { |
---|
| 40 | this->object = object; |
---|
| 41 | this->exec = executor; |
---|
| 42 | }; |
---|
| 43 | |
---|
[8035] | 44 | /** |
---|
| 45 | * @brief Creates a SignalConnector as a copy of another one. |
---|
| 46 | * @param signalConnector The SignalConnector to copy. |
---|
| 47 | */ |
---|
[7855] | 48 | SignalConnector::SignalConnector(const SignalConnector& signalConnector) |
---|
| 49 | { |
---|
| 50 | this->object = signalConnector.object; |
---|
| 51 | this->exec = (signalConnector.exec == NULL) ? NULL : signalConnector.exec->clone(); |
---|
| 52 | } |
---|
| 53 | |
---|
[8035] | 54 | /** |
---|
| 55 | * @brief deletes a SignalConnector. |
---|
| 56 | * |
---|
| 57 | * frees the stored executor |
---|
| 58 | */ |
---|
[7855] | 59 | SignalConnector::~SignalConnector() |
---|
| 60 | { |
---|
| 61 | delete exec; |
---|
| 62 | } |
---|
| 63 | |
---|
[8035] | 64 | /** |
---|
| 65 | * @brief assignes a SignalConnector to the current one |
---|
| 66 | * @param signalConnector the SignalConnector to assign to this one |
---|
| 67 | * @return A Reference to this SignalConnector. |
---|
| 68 | */ |
---|
[7855] | 69 | SignalConnector& SignalConnector::operator=(const SignalConnector& signalConnector) |
---|
| 70 | { |
---|
| 71 | delete this->exec; |
---|
| 72 | this->object = signalConnector.object; |
---|
| 73 | this->exec = (signalConnector.exec == NULL) ? NULL : signalConnector.exec->clone(); |
---|
| 74 | } |
---|
| 75 | |
---|
[8035] | 76 | |
---|
| 77 | /** |
---|
| 78 | * @brief compares two SignalConnectors. |
---|
| 79 | * @param signalConnector the SignalConnector to compare against this one. |
---|
| 80 | * @return true if the Connectors are the same. |
---|
| 81 | */ |
---|
| 82 | bool SignalConnector::operator==(const SignalConnector& signalConnector) const |
---|
[7855] | 83 | { |
---|
[8035] | 84 | return (this->object == signalConnector.object /* && this->exec == signalConnector.exec */ ); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | /** |
---|
| 89 | * @brief Executes the SignalConnector. |
---|
| 90 | */ |
---|
| 91 | void SignalConnector::operator()() const |
---|
| 92 | { |
---|
| 93 | if (this->isValid()) |
---|
| 94 | (*this->exec)(this->object, 0, NULL); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | /** |
---|
| 98 | * @brief Executes the SignalConnector. |
---|
| 99 | * @param value0 First Value. |
---|
| 100 | */ |
---|
| 101 | void SignalConnector::operator()(const MultiType& value0) const |
---|
| 102 | { |
---|
[7855] | 103 | if (exec != NULL && object != NULL) |
---|
[8035] | 104 | (*this->exec)(this->object, 1, &value0); |
---|
[7855] | 105 | } |
---|
| 106 | |
---|
[8035] | 107 | /** |
---|
| 108 | * @brief Executes the SignalConnector. |
---|
| 109 | * @param value0 First Value |
---|
| 110 | * @param value1 Second Value |
---|
| 111 | */ |
---|
| 112 | void SignalConnector::operator()(const MultiType& value0, const MultiType& value1) const |
---|
| 113 | { |
---|
| 114 | if (exec != NULL && object != NULL) |
---|
| 115 | { |
---|
| 116 | MultiType mt[] = { value0, value1 }; |
---|
| 117 | (*this->exec)(this->object, 2, mt); |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | /** |
---|
| 122 | * @brief Executes the SignalConnector. |
---|
| 123 | * @param value0 First Value |
---|
| 124 | * @param value1 Second Value |
---|
| 125 | * @param value2 Third Value |
---|
| 126 | */ |
---|
| 127 | void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2) const |
---|
| 128 | { |
---|
| 129 | if (exec != NULL && object != NULL) |
---|
| 130 | { |
---|
| 131 | MultiType mt[] = { value0, value1, value2 }; |
---|
| 132 | (*this->exec)(this->object, 3, mt); |
---|
| 133 | } |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | /** |
---|
| 137 | * @brief Executes the SignalConnector. |
---|
| 138 | * @param value0 First Value |
---|
| 139 | * @param value1 Second Value |
---|
| 140 | * @param value2 Third Value |
---|
| 141 | * @param value3 Fourth Value |
---|
| 142 | */ |
---|
| 143 | void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3) const |
---|
| 144 | { |
---|
| 145 | if (exec != NULL && object != NULL) |
---|
| 146 | { |
---|
| 147 | MultiType mt[] = { value0, value1, value2, value3 }; |
---|
| 148 | (*this->exec)(this->object, 4, mt); |
---|
| 149 | } |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | /** |
---|
| 153 | * @brief Executes the SignalConnector. |
---|
| 154 | * @param value0 First Value |
---|
| 155 | * @param value1 Second Value |
---|
| 156 | * @param value2 Third Value |
---|
| 157 | * @param value3 Fourth Value |
---|
| 158 | * @param value3 Fifth Value |
---|
| 159 | */ |
---|
| 160 | void SignalConnector::operator()(const MultiType& value0, const MultiType& value1, const MultiType& value2, const MultiType& value3, const MultiType& value4) const |
---|
| 161 | { |
---|
| 162 | if (exec != NULL && object != NULL) |
---|
| 163 | { |
---|
| 164 | MultiType mt[] = { value0, value1, value2, value3, value4 }; |
---|
| 165 | (*this->exec)(this->object, 5, mt); |
---|
| 166 | } |
---|
| 167 | } |
---|
[3365] | 168 | } |
---|