Changeset 4882 for branches/erijo-dev
- Timestamp:
- 04/01/07 22:33:24 (20 months ago)
- Location:
- branches/erijo-dev/licq
- Files:
-
- 7 modified
-
licq/interface/event.h (modified) (1 diff)
-
licq/types.h (modified) (1 diff)
-
src/daemon.cpp (modified) (2 diffs)
-
src/event.cpp (modified) (3 diffs)
-
src/event.h (modified) (3 diffs)
-
src/tests/eventqueuetest.cpp (modified) (3 diffs)
-
src/tests/eventtest.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/erijo-dev/licq/licq/interface/event.h
r4871 r4882 75 75 76 76 /** \return Event name passed to create(). */ 77 virtual const std::string& getEventName() const = 0; 77 virtual const std::string& getName() const = 0; 78 79 /** \return Globally unique id. */ 80 virtual TEventId getId() const = 0; 78 81 79 82 /** \return True if the event has a property \a key; otherwise false. */ -
branches/erijo-dev/licq/licq/types.h
r4839 r4882 37 37 typedef unsigned long TPluginId; 38 38 39 /** \brief All events get an unique id of type TEventId when they are sent to the daemon.39 /** \brief All events get an unique id of type TEventId when they are created. 40 40 \ingroup public 41 41 */ -
branches/erijo-dev/licq/src/daemon.cpp
r4881 r4882 25 25 void Licq::TDaemon::onEvent(const IEventPtr& event) 26 26 { 27 Log.info("TDaemon::onEvent(%s )", event->getEventName().c_str());28 TEventHandlers::iterator handler = EventHandlers.find(event->get EventName());27 Log.info("TDaemon::onEvent(%s [%lu])", event->getName().c_str(), event->getId()); 28 TEventHandlers::iterator handler = EventHandlers.find(event->getName()); 29 29 if (handler != EventHandlers.end()) 30 30 { 31 Log.debug("Calling handler for %s", event->get EventName().c_str());31 Log.debug("Calling handler for %s", event->getName().c_str()); 32 32 (this->*(handler->second))(event); 33 33 } … … 62 62 } 63 63 64 if (count == 5)64 if (count >= 5) 65 65 Pipe.write("TESTING", sizeof("TESTING") - 1); 66 67 if (count >= 6) 68 EventLoop.removeFileDescriptor(Pipe.getFileDescriptor()); 69 70 if (count == 7) 71 EventLoop.removeTimer(1); 66 72 } 67 73 -
branches/erijo-dev/licq/src/event.cpp
r4841 r4882 25 25 } 26 26 27 Licq::TEventId Licq::TEvent::NextEventId = 1; 28 Licq::TMutex Licq::TEvent::Mutex; 29 27 30 Licq::TEvent::TEvent(Licq::TPluginId sender, const std::string& eventName) 28 : Sender(sender), EventName(eventName)31 : Sender(sender), Name(eventName) 29 32 { 30 // Empty 33 Mutex.lock(); 34 Id = NextEventId++; 35 Mutex.unlock(); 31 36 } 32 37 … … 36 41 } 37 42 38 bool Licq::TEvent::getProperty(const std::string& key, const boost::any** value) const 43 bool Licq::TEvent::getProperty(const std::string& key, 44 const boost::any** value) const 39 45 { 40 46 TProperties::const_iterator it = Properties.find(key); … … 51 57 } 52 58 53 const std::string& Licq::TEvent::get EventName() const59 const std::string& Licq::TEvent::getName() const 54 60 { 55 return EventName; 61 return Name; 62 } 63 64 Licq::TEventId Licq::TEvent::getId() const 65 { 66 return Id; 56 67 } 57 68 -
branches/erijo-dev/licq/src/event.h
r4841 r4882 23 23 #include "licq/interface/event.h" 24 24 #include "utils/misc.h" 25 #include "utils/mutex.h" 25 26 26 27 #include <map> … … 43 44 44 45 TPluginId Sender; 45 const std::string EventName; 46 const std::string Name; 47 unsigned long Id; 46 48 47 49 typedef std::map<std::string, boost::any> TProperties; 48 50 TProperties Properties; 51 52 static TMutex Mutex; 53 static TEventId NextEventId; 49 54 50 55 protected: … … 55 60 // From IEvent 56 61 TPluginId getSenderId() const; 57 const std::string& getEventName() const; 62 const std::string& getName() const; 63 TEventId getId() const; 58 64 bool hasProperty(const std::string& key) const; 59 65 void setProperty(const std::string& key, const boost::any& value); -
branches/erijo-dev/licq/src/tests/eventqueuetest.cpp
r4839 r4882 59 59 60 60 BOOST_CHECK_EQUAL(ret1->getSenderId(), (Licq::TPluginId) 1); 61 BOOST_CHECK_EQUAL(ret1->get EventName(), "event-1");61 BOOST_CHECK_EQUAL(ret1->getName(), "event-1"); 62 62 63 63 int answer; … … 72 72 73 73 BOOST_CHECK_EQUAL(ret2->getSenderId(), (Licq::TPluginId) 17); 74 BOOST_CHECK_EQUAL(ret2->get EventName(), "event-2");74 BOOST_CHECK_EQUAL(ret2->getName(), "event-2"); 75 75 76 76 std::string question; … … 93 93 BOOST_CHECK_EQUAL(queue.empty(), true); 94 94 95 BOOST_CHECK_EQUAL(list.front()->get EventName(), "event-2");96 BOOST_CHECK_EQUAL(list.back()->get EventName(), "event-1");95 BOOST_CHECK_EQUAL(list.front()->getName(), "event-2"); 96 BOOST_CHECK_EQUAL(list.back()->getName(), "event-1"); 97 97 list.clear(); 98 98 } -
branches/erijo-dev/licq/src/tests/eventtest.cpp
r4841 r4882 39 39 Licq::IEventPtr data = Licq::IEvent::create(1, "test-event"); 40 40 BOOST_CHECK_EQUAL(data->getSenderId(), Licq::TPluginId(1)); 41 BOOST_CHECK_EQUAL(data->get EventName(), "test-event");41 BOOST_CHECK_EQUAL(data->getName(), "test-event"); 42 42 43 43 // Set some data
