Package list
lintian-fixes/upstream

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 /* * Dillo Widget * * Copyright 2005-2007 Sebastian Geerken * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "signal.hh" namespace lout { namespace signal { using namespace container::typed; // ------------ // Emitter // ------------ Emitter::Emitter () { receivers = new List (false); } Emitter::~Emitter () { for (Iterator it = receivers->iterator (); it.hasNext (); ) { Receiver *receiver = it.getNext (); receiver->unconnectFrom (this); } delete receivers; } void Emitter::intoStringBuffer(misc::StringBuffer *sb) { sb->append ("intoStringBuffer (sb); sb->append (">"); } void Emitter::unconnect (Receiver *receiver) { receivers->removeRef (receiver); } /** * \brief Connect a receiver to the emitter. * * This is protected, a sub class should define a wrapper, with the respective * receiver as an argument, to gain type safety. */ void Emitter::connect (Receiver *receiver) { receivers->append (receiver); receiver->connectTo (this); } /** * \brief Emit a void signal. * * This method should be called by a wrapper (return value void), which * \em folds the signal, and delegates the emission to here. */ void Emitter::emitVoid (int signalNo, int argc, Object **argv) { for (Iterator it = receivers->iterator (); it.hasNext (); ) { Receiver *receiver = it.getNext(); emitToReceiver (receiver, signalNo, argc, argv); } } /** * \brief Emit a boolean signal. * * This method should be called by a wrapper, which \em folds the signal, * delegates the emission to here, and returns the same boolean value. */ bool Emitter::emitBool (int signalNo, int argc, Object **argv) { bool b = false, bt; for (Iterator it = receivers->iterator (); it.hasNext (); ) { Receiver *receiver = it.getNext(); // Note: All receivers are called, even if one returns true. // Therefore, something like // b = b || emitToReceiver (receiver, signalNo, argc, argv); // does not work. bt = emitToReceiver (receiver, signalNo, argc, argv); b = b || bt; } return b; } // -------------- // Receiver // -------------- Receiver::Receiver() { emitters = new List (false); } Receiver::~Receiver() { for (Iterator it = emitters->iterator(); it.hasNext(); ) { Emitter *emitter = it.getNext(); emitter->unconnect (this); } delete emitters; } void Receiver::intoStringBuffer(misc::StringBuffer *sb) { // emitters are not listed, to prevent recursion sb->append (""); } void Receiver::connectTo(Emitter *emitter) { emitters->append (emitter); } void Receiver::unconnectFrom(Emitter *emitter) { emitters->removeRef (emitter); } // ------------------------ // ObservedObject // ------------------------ bool ObservedObject::DeletionEmitter::emitToReceiver (Receiver *receiver, int signalNo, int argc, Object **argv) { object::TypedPointer *p = (object::TypedPointer*)argv[0]; ((DeletionReceiver*)receiver)->deleted (p->getTypedValue ()); return false; } void ObservedObject::DeletionEmitter::emitDeletion (ObservedObject *obj) { object::TypedPointer p(obj); object::Object *argv[1] = { &p }; emitVoid (0, 1, argv); } ObservedObject::~ObservedObject() { deletionEmitter.emitDeletion (this); } } // namespace signal } // namespace lout