Changeset 4841 for branches/erijo-dev
- Timestamp:
- 01/28/07 00:59:02 (23 months ago)
- Location:
- branches/erijo-dev/licq
- Files:
-
- 8 modified
-
licq/interface/event.h (modified) (2 diffs)
-
licq/interface/eventqueue.h (modified) (3 diffs)
-
src/event.cpp (modified) (1 diff)
-
src/event.h (modified) (1 diff)
-
src/logfile.cpp (modified) (3 diffs)
-
src/logfile.h (modified) (2 diffs)
-
src/tests/eventtest.cpp (modified) (1 diff)
-
src/tests/logfiletest.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/erijo-dev/licq/licq/interface/event.h
r4839 r4841 42 42 \brief Represents an event in the system. 43 43 44 An event has a name, a sender id and any number of properties .44 An event has a name, a sender id and any number of properties (key, value pairs). 45 45 */ 46 46 class IEvent : private boost::noncopyable … … 101 101 template<typename ValueType> 102 102 bool getProperty(const std::string& key, ValueType* value) const; 103 104 /** \brief Get all property keys. 105 106 \param[out] keys All property keys will be copied to this parameter. 107 */ 108 virtual void getPropertyKeys(TStringList* keys) const = 0; 103 109 }; 104 110 -
branches/erijo-dev/licq/licq/interface/eventqueue.h
r4839 r4841 53 53 /** \brief Add a event to the back of the event queue. 54 54 55 - Precondition:\code event.use_count() == 1 && event.get() != NULL \endcode56 - Postcondition:\code event.use_count() == 0 && event.get() == NULL \endcode55 \pre \code event.use_count() == 1 && event.get() != NULL \endcode 56 \post \code event.use_count() == 0 && event.get() == NULL \endcode 57 57 58 58 \param event Event to add. Ownership of the pointer is transfered to the queue … … 63 63 /** \brief Retrive the event at the front of the queue. 64 64 65 - Precondition:\code empty() != true \endcode65 \pre \code empty() != true \endcode 66 66 67 67 \return The next event. … … 71 71 /** \brief Retrive all pending events from the queue. 72 72 73 - Postcondition:\code empty() == true \endcode73 \post \code empty() == true \endcode 74 74 75 75 \param[out] list List to add all events to. -
branches/erijo-dev/licq/src/event.cpp
r4829 r4841 65 65 Properties[key] = value; 66 66 } 67 68 void Licq::TEvent::getPropertyKeys(TStringList* keys) const 69 { 70 TProperties::const_iterator it = Properties.begin(); 71 for (; it != Properties.end(); ++it) 72 keys->push_back(it->first); 73 } -
branches/erijo-dev/licq/src/event.h
r4839 r4841 58 58 bool hasProperty(const std::string& key) const; 59 59 void setProperty(const std::string& key, const boost::any& value); 60 void getPropertyKeys(TStringList* keys) const; 60 61 }; 61 62 -
branches/erijo-dev/licq/src/logfile.cpp
r4836 r4841 22 22 #include <cstring> 23 23 24 static const char* INFO_STR = "INF";25 static const char* WARNING_STR = "WRN";26 static const char* ERROR_STR = "ERR";27 static const char* FATAL_STR = "FAT";28 static const char* DEBUG_STR = "DBG";29 static const char* PACKET_STR = "PKT";30 static const char* UNKNOWN_STR = "???";24 static const char* const INFO_STR = "INF"; 25 static const char* const WARNING_STR = "WRN"; 26 static const char* const ERROR_STR = "ERR"; 27 static const char* const FATAL_STR = "FAT"; 28 static const char* const DEBUG_STR = "DBG"; 29 static const char* const PACKET_STR = "PKT"; 30 static const char* const UNKNOWN_STR = "???"; 31 31 32 32 Licq::TLogFile::TLogFile(FILE* file) … … 38 38 void Licq::TLogFile::log(LogType type, const char* format, va_list ap) 39 39 { 40 const size_t len = strlen(format);40 const size_t len = ::strlen(format); 41 41 if (len == 0) 42 42 return; … … 65 65 } 66 66 67 fprintf(File, "[%s] ", prefix);68 vfprintf(File, format, ap);67 ::fprintf(File, "[%s] ", prefix); 68 ::vfprintf(File, format, ap); 69 69 70 70 if (format[len - 1] != '\n') 71 fprintf(File, "\n");71 ::fprintf(File, "\n"); 72 72 } -
branches/erijo-dev/licq/src/logfile.h
r4839 r4841 29 29 /** \class TLogFile 30 30 \ingroup internal 31 \brief An implementation of ILog that logs all message to file.31 \brief An implementation of ILog that logs all messages to file. 32 32 */ 33 33 class TLogFile : public ILog … … 45 45 46 46 // From ILog 47 /** \copydoc ILog::log(LogType,const char*,va_list) 48 Prefixes all messages with "[XXX] ", where XXX depends on the value of \a type. 49 */ 47 50 void log(LogType type, const char* format, va_list ap); 48 51 }; -
branches/erijo-dev/licq/src/tests/eventtest.cpp
r4832 r4841 45 45 data->setProperty("a string", "a const char* string"); 46 46 47 // Check that has Key works47 // Check that hasProperty works 48 48 BOOST_CHECK_EQUAL(data->hasProperty("a key"), true); 49 49 BOOST_CHECK_EQUAL(data->hasProperty("a string"), true); 50 50 BOOST_CHECK_EQUAL(data->hasProperty("missing key"), false); 51 52 // Check that getPropertyKeys works 53 Licq::TStringList keys; 54 data->getPropertyKeys(&keys); 55 BOOST_CHECK_EQUAL(keys.size(), 2u); 56 BOOST_CHECK_EQUAL(keys.front(), "a key"); 57 BOOST_CHECK_EQUAL(keys.back(), "a string"); 51 58 52 59 // Check that getting a value only works when using the correct type -
branches/erijo-dev/licq/src/tests/logfiletest.cpp
r4836 r4841 30 30 31 31 // Log to temporary file 32 FILE* temp = tmpfile();32 FILE* temp = ::tmpfile(); 33 33 BOOST_REQUIRE(temp != NULL); 34 34 … … 42 42 43 43 // Done logging, read it all in 44 const long pos = ftell(temp);45 rewind(temp);44 const long pos = ::ftell(temp); 45 ::rewind(temp); 46 46 47 47 char* str = new char[pos + 1]; 48 bzero(str, pos + 1);48 ::bzero(str, pos + 1); 49 49 50 const long count = fread(str, sizeof(char), pos, temp);50 const long count = ::fread(str, sizeof(char), pos, temp); 51 51 BOOST_REQUIRE_EQUAL(count, pos); 52 52 … … 63 63 64 64 // The stream should not be closed by ~TLogFile 65 BOOST_CHECK( fileno(temp) != -1);65 BOOST_CHECK(::fileno(temp) != -1); 66 66 67 BOOST_CHECK_EQUAL( fclose(temp), 0);68 BOOST_CHECK_EQUAL( fileno(temp), -1);67 BOOST_CHECK_EQUAL(::fclose(temp), 0); 68 BOOST_CHECK_EQUAL(::fileno(temp), -1); 69 69 }
