Changeset 4839 for branches/erijo-dev
- Timestamp:
- 01/27/07 21:08:39 (23 months ago)
- Location:
- branches/erijo-dev/licq
- Files:
-
- 5 added
- 12 modified
-
licq/interface/event.h (modified) (1 diff)
-
licq/interface/eventqueue.h (added)
-
licq/interface/log.h (modified) (2 diffs)
-
licq/licq.h (added)
-
licq/types.h (modified) (1 diff)
-
src/CMakeLists.txt (modified) (1 diff)
-
src/event.h (modified) (1 diff)
-
src/eventqueue.cpp (added)
-
src/eventqueue.h (added)
-
src/logfile.h (modified) (1 diff)
-
src/logserializer.h (modified) (1 diff)
-
src/tests/CMakeLists.txt (modified) (1 diff)
-
src/tests/eventqueuetest.cpp (added)
-
src/utils/dynamiclibrary.h (modified) (3 diffs)
-
src/utils/misc.h (modified) (1 diff)
-
src/utils/mutex.h (modified) (2 diffs)
-
src/utils/mutexlocker.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/erijo-dev/licq/licq/interface/event.h
r4832 r4839 32 32 33 33 class IEvent; 34 35 /** \brief A smart pointer to an IEvent instance. 36 \ingroup public 37 */ 34 38 typedef boost::shared_ptr<IEvent> IEventPtr; 35 39 40 /** \interface IEvent 41 \ingroup public 42 \brief Represents an event in the system. 43 44 An event has a name, a sender id and any number of properties. 45 */ 36 46 class IEvent : private boost::noncopyable 37 47 { 38 48 protected: 49 /// Destroy the event. 39 50 virtual ~IEvent(); 51 52 /** \brief Internal function for retriving a pointer to the property. 53 54 \param[in] key The property to get. 55 \param[out] value Pointer set to the value if property is found. 56 57 \return True if property exists; otherwise false. 58 */ 40 59 virtual bool getProperty(const std::string& key, const boost::any** value) const = 0; 41 60 42 61 public: 62 /** \brief Create a new event. 63 64 \param[in] sender The sender's (or creator's) plugin id. 65 \param[in] eventName Name of the event. 66 67 \return The created event. 68 */ 43 69 static IEventPtr create(TPluginId sender, const std::string& eventName); 44 70 71 /** \return Sender id passed to create(). */ 45 72 virtual TPluginId getSenderId() const = 0; 73 74 /** \return Event name passed to create(). */ 46 75 virtual const std::string& getEventName() const = 0; 47 76 77 /** \return True if the event has a property \a key; otherwise false. */ 48 78 virtual bool hasProperty(const std::string& key) const = 0; 49 79 80 /** \brief Set the value of a property. 81 82 Set the property \a key to \a value, overwriting any existing property 83 with the same name. 84 85 \param[in] key Property name. 86 \param[in] value Property value. 87 */ 50 88 virtual void setProperty(const std::string& key, const boost::any& value) = 0; 89 90 /// Calls setProperty(key, std::string(value)). 51 91 void setProperty(const std::string& key, const char* value); 52 92 93 /** \brief A type safe method for getting a property value. 94 95 \param[in] key Name of the property to get. 96 \param[out] value Set to the property's value if property exists. 97 98 \return True if the property was found and was of the correct type; 99 otherwise false. 100 */ 53 101 template<typename ValueType> 54 102 bool getProperty(const std::string& key, ValueType* value) const; -
branches/erijo-dev/licq/licq/interface/log.h
r4835 r4839 32 32 { 33 33 34 /** \interface ILog 35 \ingroup public 36 \brief A printf-styled logging facility. 37 */ 34 38 class ILog 35 39 { … … 37 41 enum LogType 38 42 { 43 /// Basic information about what's going on. 39 44 LogTypeInfo, 45 /// Warnings which are not critical but could be important. 40 46 LogTypeWarning, 47 /// Critical errors which should be brought to the attention of the user. 41 48 LogTypeError, 49 /// Fatal errors after which Licq is unable to continue running. 42 50 LogTypeFatal, 51 /// Debugging aid. 43 52 LogTypeDebug, 53 /// Packet dumps. 44 54 LogTypePacket 45 55 }; 46 56 57 /// Destroy the log. 47 58 virtual ~ILog(); 48 59 60 /** \brief Log a printf-styled message. 61 62 \param[in] type Type of log message. 63 \param[in] format A printf-styled format string. 64 \param[in] ap Varying number of arguments, matching \a format. 65 */ 49 66 virtual void log(LogType type, const char* format, va_list ap) = 0; 50 67 68 /** \brief Log a printf-styled message. 69 \see log(). 70 */ 51 71 void note(LogType type, const char* format, ...) CHECK_FORMAT(3, 4); 52 72 73 /// Equivalent to calling note(ILog::LogTypeInfo, \a format, \a ...). 53 74 void info(const char* format, ...) CHECK_FORMAT(2, 3); 75 76 /// Equivalent to calling note(ILog::LogTypeWarning, \a format, \a ...). 54 77 void warning(const char* format, ...) CHECK_FORMAT(2, 3); 78 79 /// Equivalent to calling note(ILog::LogTypeError, \a format, \a ...). 55 80 void error(const char* format, ...) CHECK_FORMAT(2, 3); 81 82 /// Equivalent to calling note(ILog::LogTypeFatal, \a format, \a ...). 56 83 void fatal(const char* format, ...) CHECK_FORMAT(2, 3); 84 85 /// Equivalent to calling note(ILog::LogTypeDebug, \a format, \a ...). 57 86 void debug(const char* format, ...) CHECK_FORMAT(2, 3); 87 88 /// Equivalent to calling note(ILog::LogTypePacket, \a format, \a ...). 58 89 void packet(const char* format, ...) CHECK_FORMAT(2, 3); 59 90 }; -
branches/erijo-dev/licq/licq/types.h
r4829 r4839 27 27 { 28 28 29 /** \brief A list of strings. 30 \ingroup public 31 */ 29 32 typedef std::list<std::string> TStringList; 33 34 /** \brief All plugins have an unique id of type TPluginId. 35 \ingroup public 36 */ 30 37 typedef unsigned long TPluginId; 38 39 /** \brief All events get an unique id of type TEventId when they are sent to the daemon. 40 \ingroup public 41 */ 31 42 typedef unsigned long TEventId; 32 43 -
branches/erijo-dev/licq/src/CMakeLists.txt
r4836 r4839 1 1 set(licqdaemon_SRCS 2 2 event.cpp 3 eventqueue.cpp 3 4 logfile.cpp 4 5 version.cpp -
branches/erijo-dev/licq/src/event.h
r4829 r4839 29 29 { 30 30 31 /** \class TEvent 32 \ingroup internal 33 \brief An implementation of IEvent. 34 */ 31 35 class TEvent : public IEvent 32 36 { -
branches/erijo-dev/licq/src/logfile.h
r4836 r4839 27 27 { 28 28 29 /** \class TLogFile 30 \ingroup internal 31 \brief An implementation of ILog that logs all message to file. 32 */ 29 33 class TLogFile : public ILog 30 34 { 31 35 private: 36 /// File to log to. 32 37 FILE* File; 33 38 34 39 public: 40 /** \brief Constructs a new TLogFile. 41 42 \param[in] file An open file stream to log to. 43 */ 35 44 TLogFile(FILE* file = stderr); 36 45 -
branches/erijo-dev/licq/src/logserializer.h
r4835 r4839 29 29 { 30 30 31 /** Serialize logging, so multiple threads can safely use the same log backend. */ 31 /** \class TLogSerializer 32 \ingroup internal 33 \brief An implementation of ILog that serialize logging for multiple threads. 34 35 By giving each thread a separate instance of TLogSerializer initialized with 36 the same log backend, multiple threads can log to the same log backend without 37 the backend having to be thread safe. 38 39 TLogSerializer implements the decorator design pattern. 40 \see http://en.wikipedia.org/wiki/Decorator_pattern 41 */ 32 42 class TLogSerializer : private boost::noncopyable, 33 43 public ILog 34 44 { 35 45 private: 46 /// Mutex to serialize access. 36 47 TMutex Mutex; 48 49 /// Log to log to. 37 50 ILog* Log; 38 51 39 52 public: 53 /// Creates a new TLogSerializer that logs to \a log. 40 54 TLogSerializer(ILog* log); 55 56 // From ILog 41 57 void log(LogType type, const char* format, va_list ap); 42 58 }; -
branches/erijo-dev/licq/src/tests/CMakeLists.txt
r4836 r4839 1 1 set(licqdaemontest_SRCS 2 eventqueuetest.cpp 2 3 eventtest.cpp 3 4 logfiletest.cpp -
branches/erijo-dev/licq/src/utils/dynamiclibrary.h
r4829 r4839 29 29 { 30 30 31 /** \class TDynamicLibrary 32 \ingroup internal 33 \brief Open dynamic libraries and load symbols. 34 */ 31 35 class TDynamicLibrary : private boost::noncopyable 32 36 { … … 39 43 40 44 public: 41 /** Closes the dynamic library. */ 45 /** \brief Close the dynamic library. 46 47 Before calling the destructor, make absolutely sure that no symbols residing 48 in this library is still in use. Otherwise prepare for a crash. 49 */ 42 50 ~TDynamicLibrary(); 43 51 44 /** Open a dynamic library.52 /** \brief Open a dynamic library. 45 53 46 \param log The log to log errors to. 47 \param filename Library to open. See dlopen(3) for how this name is resolved. 54 \param[in] log The log to log errors to. 55 \param[in] filename Library to open. See dlopen(3) on your system for how 56 this name is resolved. 48 57 49 58 \return NULL on error; otherwise a new instance of TDynamicLibrary. … … 52 61 static TDynamicLibrary* open(ILog* log, const std::string& filename); 53 62 54 /** Load a symbol from the library.63 /** \brief Load a symbol from the library. 55 64 56 65 \param name Name of symbol to load. -
branches/erijo-dev/licq/src/utils/misc.h
r4830 r4839 24 24 { 25 25 26 /** Utility to be used in standard algorithms. 26 /** \struct ObjectDeleter 27 \brief Functor for deleting objects. 28 \ingroup internal 29 30 A common usage scenario: 27 31 \code 28 32 std::list<TObject*> ptrList; 33 // Fill ptrList with a lot of objects. 29 34 std::for_each(ptrList.begin(), ptrList.end(), Licq::ObjectDeleter()); 35 ptrList.clear(); 30 36 \endcode 31 37 */ 32 38 struct ObjectDeleter 33 39 { 40 /// Delete \a ptr. 34 41 template<typename T> 35 42 void operator()(const T* ptr) const -
branches/erijo-dev/licq/src/utils/mutex.h
r4829 r4839 27 27 { 28 28 29 /** \class TMutex 30 \ingroup internal 31 \brief A mutual exclusive device. 32 33 TMutex is a wrapper around pthread's mutex facility. 34 */ 29 35 class TMutex : private boost::noncopyable 30 36 { … … 34 40 35 41 public: 36 / ** Creates a new unlocked mutex. */42 /// Create a new unlocked mutex. 37 43 TMutex(); 38 44 39 / ** Destroys the mutex, unlocking it if necessary. */45 /// Destroy the mutex, unlocking it if necessary. 40 46 ~TMutex(); 41 47 42 / ** Locks the mutex. Blocks until the mutex is locked. */48 /// Lock the mutex. Blocks until the mutex is locked. 43 49 void lock(); 44 50 45 / ** Unlocks the mutex. */51 /// Unlock the mutex. 46 52 void unlock(); 47 53 48 /** Tries to lock the mutex. 54 /** \brief Try to lock the mutex without blocking. 55 49 56 \return True if the mutex was locked; otherwise false. 50 57 */ 51 58 bool tryLock(); 52 59 53 /** Check if the mutex is locked.60 /** \brief Check if the mutex is locked. 54 61 55 Relying on the return value from this method is not recomended. Since, depending62 Relying on the return value from this method is not recomended. Depending 56 63 on how threads are scheduled, the return value may be invalid even before it 57 64 has made it back to the caller. Better use tryLock(). -
branches/erijo-dev/licq/src/utils/mutexlocker.h
r4829 r4839 28 28 { 29 29 30 /** A helper class that unlocks the mutex when it is destroyed. 30 /** \class TMutexLocker 31 \ingroup internal 32 \brief Unlocks a locked mutex in the destructor. 33 34 A helper class that unlocks the mutex when it is destroyed. 31 35 TMutexLocker is in itself not thread safe. Only use it as a convinient 32 way to have mutexes unlocked in case of e.g. exceptions. 36 way to have a mutex unlocked in case of e.g. an exception or multiple 37 return points. 38 39 \code 40 class TThreadSafeCounter 41 { 42 private: 43 TMutex Mutex; 44 int Counter; 45 public: 46 TThreadSafeCounter() : Counter(0) {} 47 int operator++(int) 48 { 49 TMutexLocker locker(&Mutex); 50 locker.lock(); 51 return Counter++; 52 } 53 }; 54 \endcode 33 55 */ 34 56 class TMutexLocker : private boost::noncopyable … … 39 61 40 62 public: 41 /** \param mutex Must be a mutex \b not locked by this thread. */ 63 /** \brief Create a new TMutexLocker. 64 65 Does \b not lock \a mutex. 66 67 \param[in] mutex Must be a mutex \b not locked by this thread. 68 */ 42 69 TMutexLocker(TMutex* mutex); 43 70 44 / ** Unlocks the mutex if it was previous locked by calling lock() or tryLock(). */71 /// Unlock the mutex if it was previous locked in lock() or tryLock(). 45 72 ~TMutexLocker(); 46 73 47 / ** Locks the mutex. Blocks until the mutex is locked. */74 /// Lock the mutex. Blocks until the mutex is locked. 48 75 void lock(); 49 76 50 / ** Unlocks the mutex. */77 /// Unlock the mutex. 51 78 void unlock(); 52 79 53 /** Tries to lock the mutex. 80 /** \brief Try to lock the mutex without blocking. 81 54 82 \return True if the mutex was locked; otherwise false. 55 83 */ 56 84 bool tryLock(); 57 85 58 /** Release the mutex. After this call, all operations will fail and the 59 destructor will not unlock the mutex. 86 /** \brief Release the mutex. 87 88 After this call, all operations will fail and the destructor will 89 not unlock the mutex. 60 90 */ 61 91 TMutex* releaseMutex();
