Changeset 4841 for branches/erijo-dev

Show
Ignore:
Timestamp:
01/28/07 00:59:02 (23 months ago)
Author:
erijo
Message:

Added IEvent::getPropertyKeys + misc fixes

Location:
branches/erijo-dev/licq
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • branches/erijo-dev/licq/licq/interface/event.h

    r4839 r4841  
    4242    \brief Represents an event in the system. 
    4343 
    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). 
    4545*/ 
    4646class IEvent : private boost::noncopyable 
     
    101101  template<typename ValueType> 
    102102  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; 
    103109}; 
    104110 
  • branches/erijo-dev/licq/licq/interface/eventqueue.h

    r4839 r4841  
    5353  /** \brief Add a event to the back of the event queue. 
    5454 
    55       - Precondition:  \code event.use_count() == 1 && event.get() != NULL \endcode 
    56       - Postcondition: \code event.use_count() == 0 && event.get() == NULL \endcode 
     55      \pre  \code event.use_count() == 1 && event.get() != NULL \endcode 
     56      \post \code event.use_count() == 0 && event.get() == NULL \endcode 
    5757 
    5858      \param event Event to add. Ownership of the pointer is transfered to the queue 
     
    6363  /** \brief Retrive the event at the front of the queue. 
    6464 
    65       - Precondition: \code empty() != true \endcode 
     65      \pre \code empty() != true \endcode 
    6666 
    6767      \return The next event. 
     
    7171  /** \brief Retrive all pending events from the queue. 
    7272 
    73       - Postcondition: \code empty() == true \endcode 
     73      \post \code empty() == true \endcode 
    7474 
    7575      \param[out] list List to add all events to. 
  • branches/erijo-dev/licq/src/event.cpp

    r4829 r4841  
    6565  Properties[key] = value; 
    6666} 
     67 
     68void 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  
    5858  bool hasProperty(const std::string& key) const; 
    5959  void setProperty(const std::string& key, const boost::any& value); 
     60  void getPropertyKeys(TStringList* keys) const; 
    6061}; 
    6162 
  • branches/erijo-dev/licq/src/logfile.cpp

    r4836 r4841  
    2222#include <cstring> 
    2323 
    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 = "???"; 
     24static const char* const INFO_STR    = "INF"; 
     25static const char* const WARNING_STR = "WRN"; 
     26static const char* const ERROR_STR   = "ERR"; 
     27static const char* const FATAL_STR   = "FAT"; 
     28static const char* const DEBUG_STR   = "DBG"; 
     29static const char* const PACKET_STR  = "PKT"; 
     30static const char* const UNKNOWN_STR = "???"; 
    3131 
    3232Licq::TLogFile::TLogFile(FILE* file) 
     
    3838void Licq::TLogFile::log(LogType type, const char* format, va_list ap) 
    3939{ 
    40   const size_t len = strlen(format); 
     40  const size_t len = ::strlen(format); 
    4141  if (len == 0) 
    4242    return; 
     
    6565  } 
    6666 
    67   fprintf(File, "[%s] ", prefix); 
    68   vfprintf(File, format, ap); 
     67  ::fprintf(File, "[%s] ", prefix); 
     68  ::vfprintf(File, format, ap); 
    6969 
    7070  if (format[len - 1] != '\n') 
    71     fprintf(File, "\n"); 
     71    ::fprintf(File, "\n"); 
    7272} 
  • branches/erijo-dev/licq/src/logfile.h

    r4839 r4841  
    2929/** \class TLogFile 
    3030    \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. 
    3232*/ 
    3333class TLogFile : public ILog 
     
    4545 
    4646  // 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  */ 
    4750  void log(LogType type, const char* format, va_list ap); 
    4851}; 
  • branches/erijo-dev/licq/src/tests/eventtest.cpp

    r4832 r4841  
    4545  data->setProperty("a string", "a const char* string"); 
    4646 
    47   // Check that hasKey works 
     47  // Check that hasProperty works 
    4848  BOOST_CHECK_EQUAL(data->hasProperty("a key"), true); 
    4949  BOOST_CHECK_EQUAL(data->hasProperty("a string"), true); 
    5050  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"); 
    5158 
    5259  // Check that getting a value only works when using the correct type 
  • branches/erijo-dev/licq/src/tests/logfiletest.cpp

    r4836 r4841  
    3030 
    3131  // Log to temporary file 
    32   FILE* temp = tmpfile(); 
     32  FILE* temp = ::tmpfile(); 
    3333  BOOST_REQUIRE(temp != NULL); 
    3434 
     
    4242 
    4343    // Done logging, read it all in 
    44     const long pos = ftell(temp); 
    45     rewind(temp); 
     44    const long pos = ::ftell(temp); 
     45    ::rewind(temp); 
    4646 
    4747    char* str = new char[pos + 1]; 
    48     bzero(str, pos + 1); 
     48    ::bzero(str, pos + 1); 
    4949 
    50     const long count = fread(str, sizeof(char), pos, temp); 
     50    const long count = ::fread(str, sizeof(char), pos, temp); 
    5151    BOOST_REQUIRE_EQUAL(count, pos); 
    5252 
     
    6363 
    6464  // The stream should not be closed by ~TLogFile 
    65   BOOST_CHECK(fileno(temp) != -1); 
     65  BOOST_CHECK(::fileno(temp) != -1); 
    6666 
    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); 
    6969}