Changeset 2956
- Timestamp:
- 04/27/06 17:10:41 (3 years ago)
- Files:
-
- hydranode/hnbase/fwd.h (modified) (1 diff)
- hydranode/hnbase/object.cpp (modified) (5 diffs)
- hydranode/hnbase/object.h (modified) (4 diffs)
- hydranode/hncore/ed2k/serverlist.cpp (modified) (2 diffs)
- hydranode/hncore/hydranode.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
hydranode/hnbase/fwd.h
r2942 r2956 91 91 }; 92 92 93 /** 94 * Object events, propangated up the object hierarchy, and passed to event 95 * handler 96 */ 97 enum ObjectEvent { 98 OBJ_MODIFIED = 0x01, //!< This object's data has been modified 99 OBJ_ADDED, //!< An object has been added to this container 100 OBJ_REMOVED, //!< An object has been removed from this container 101 OBJ_DESTROY //!< This object has been destroyed 102 }; 103 93 104 #endif hydranode/hnbase/object.cpp
r2942 r2956 67 67 // have parent remove us. 68 68 Object::~Object() { 69 notify( m_id, OBJ_DESTROY);69 notify(this, OBJ_DESTROY); 70 70 if (m_parent) { 71 71 m_parent->delChild(this); … … 191 191 ); 192 192 } 193 notify(child ->m_id, OBJ_ADDED);193 notify(child, OBJ_ADDED); 194 194 // Virtual function call 195 195 onChildAdded(child->m_id); … … 218 218 m_children = 0; 219 219 } 220 notify(child ->m_id, OBJ_REMOVED);220 notify(child, OBJ_REMOVED); 221 221 // Virtual function call 222 222 onChildRemoved(child->m_id); … … 224 224 225 225 // Notifications 226 void Object::notify(ObjectId source, ObjectEvent event) { 226 void Object::notify(Object* source, ObjectEvent event) { 227 if (s_notify) { 228 objectNotify(source, event); 229 } 227 230 if (m_parent && s_notify) { 228 231 m_parent->notify(source, event); … … 231 234 232 235 void Object::notify(ObjectEvent event) { 233 notify( getId(), event);236 notify(this, event); 234 237 } 235 238 hydranode/hnbase/object.h
r2942 r2956 114 114 #include <hnbase/osdep.h> 115 115 #include <hnbase/event.h> 116 #include <hnbase/fwd.h> 116 117 #include <map> 117 118 #include <string> … … 119 120 #include <stdexcept> 120 121 #include <boost/noncopyable.hpp> 122 #include <boost/signals.hpp> 121 123 122 124 //! Object identifiers are 32-bit unsigned integers 123 125 typedef uint32_t ObjectId; 124 125 //! Object events, propangated up the object hierarchy, and passed to event126 //! handler127 enum ObjectEvent {128 OBJ_MODIFIED = 0x01, //!< This object's data has been modified129 OBJ_ADDED, //!< An object has been added to this container130 OBJ_REMOVED, //!< An object has been removed from this container131 OBJ_DESTROY //!< This object has been destroyed132 };133 126 134 127 /** … … 217 210 //@} 218 211 212 /** 213 * This signal is emitted whenever this object, or any object beneath 214 * it is changed, added or removed. The name for this signal has been 215 * chosen to avoid collisions with (possible) derived object variables, 216 * since this is public. 217 */ 218 boost::signal<void (Object*, ObjectEvent)> objectNotify; 219 219 220 //! Static accessors for locating an object with a specific identifier 220 221 //! from the entire hierarchy. May return null if the object could not … … 374 375 * parent objects. 375 376 * 376 * @param source Event source object identifier377 * @param source Event source object 377 378 * @param event Event type 378 379 */ 379 void notify(Object Idsource, ObjectEvent event);380 void notify(Object *source, ObjectEvent event); 380 381 381 382 /** 382 383 * More convenient function for derived classes - no need to pass 383 * source id, and event type has convenient default value.384 * source, and event type has convenient default value. 384 385 */ 385 386 void notify(ObjectEvent event = OBJ_MODIFIED); hydranode/hncore/ed2k/serverlist.cpp
r2948 r2956 906 906 } 907 907 908 Object::disableNotify(); // optimization 908 909 // prevent's ping-time showing enormously large pings 909 910 if (!(*it)->pingInProgress()) { … … 924 925 (*it)->setLowIdUsers(packet.getLowIdUsers()); 925 926 (*it)->setFailedCount(0); 927 Object::enableNotify(); 928 (*it)->notify(); 926 929 927 930 boost::format fmt( hydranode/hncore/hydranode.cpp
r2888 r2956 82 82 83 83 logMsg("Initializing Hydranode Core..."); 84 Object::disableNotify(); 84 85 85 86 logMsg(" * Initializing Configuration..."); … … 117 118 Utils::timedCallback(this, &Hydranode::saveSettings, SAVE_INTERVAL); 118 119 m_running = true; 120 Object::enableNotify(); 119 121 logMsg("Hydranode Core is up and running."); 120 122 } … … 135 137 int Hydranode::cleanUp() { 136 138 logMsg("Exiting Hydranode Core..."); 139 Object::disableNotify(); 137 140 138 141 ModManager::instance().onExit();
