geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [1/3] geode-native git commit: GEODE-2408: Removed non-standard timeval type methods.
Date Mon, 13 Feb 2017 21:51:10 GMT
Repository: geode-native
Updated Branches:
  refs/heads/develop 24cbfd324 -> e1f99a67b


GEODE-2408: Removed non-standard timeval type methods.


Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/e1f99a67
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/e1f99a67
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/e1f99a67

Branch: refs/heads/develop
Commit: e1f99a67b77658178f2d5e3b025ed5f1369060ca
Parents: bc1a8fa
Author: Jacob Barrett <jbarrett@pivotal.io>
Authored: Tue Jan 31 22:34:44 2017 -0800
Committer: Jacob Barrett <jbarrett@pivotal.io>
Committed: Mon Feb 13 13:41:41 2017 -0800

----------------------------------------------------------------------
 src/cppcache/include/gfcpp/CacheableDate.hpp | 149 +++++++---------------
 src/cppcache/src/CacheableDate.cpp           |  47 +++----
 2 files changed, 62 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode-native/blob/e1f99a67/src/cppcache/include/gfcpp/CacheableDate.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/gfcpp/CacheableDate.hpp b/src/cppcache/include/gfcpp/CacheableDate.hpp
index 5b465ee..a9e462b 100644
--- a/src/cppcache/include/gfcpp/CacheableDate.hpp
+++ b/src/cppcache/include/gfcpp/CacheableDate.hpp
@@ -29,12 +29,7 @@
 
 #include <string>
 #include <chrono>
-#include <time.h>
-#ifdef _WIN32
-#include <WinSock2.h> // timeval
-#else
-#include <sys/time.h> // timeval
-#endif
+#include <ctime>
 
 /** @file
 */
@@ -43,60 +38,57 @@ namespace geode {
 namespace client {
 
 /**
- * Implement a date object based on epoch of January 1, 1970 00:00:00 GMT that can serve
as a
- * distributable key object for caching as well as being a date value.
+ * Implement a date object based on epoch of January 1, 1970 00:00:00 GMT that
+ * can serve as a distributable key object for caching as well as being a date
+ * value.
  */
-class CPPCACHE_EXPORT CacheableDate
-  : public CacheableKey
-{
-  private:
-
-    /**
-     * Milliseconds since January 1, 1970, 00:00:00 GMT to be consistent with Java Date.
-     */
-    int64_t m_timevalue;
+class CPPCACHE_EXPORT CacheableDate : public CacheableKey {
+ private:
+  /**
+   * Milliseconds since January 1, 1970, 00:00:00 GMT to be consistent with Java
+   * Date.
+   */
+  int64_t m_timevalue;
 
-  public:
-    typedef std::chrono::system_clock clock;
-    typedef std::chrono::time_point<clock> time_point;
-    typedef std::chrono::milliseconds duration;
+ public:
+  typedef std::chrono::system_clock clock;
+  typedef std::chrono::time_point<clock> time_point;
+  typedef std::chrono::milliseconds duration;
 
   /**
    * @brief serialize this object
    **/
-  virtual void toData( DataOutput& output ) const;
+  virtual void toData(DataOutput& output) const;
 
   /**
    * @brief deserialize this object
    **/
-  virtual Serializable* fromData( DataInput& input );
+  virtual Serializable* fromData(DataInput& input);
 
   /**
    * @brief creation function for dates.
    */
-  static Serializable* createDeserializable( );
+  static Serializable* createDeserializable();
 
   /**
    * @brief Return the classId of the instance being serialized.
    * This is used by deserialization to determine what instance
    * type to create and deserialize into.
    */
-  virtual int32_t classId( ) const;
+  virtual int32_t classId() const;
 
   /**
    *@brief return the typeId byte of the instance being serialized.
    * This is used by deserialization to determine what instance
    * type to create and deserialize into.
    */
-  virtual int8_t typeId( ) const;
+  virtual int8_t typeId() const;
 
   /** @return the size of the object in bytes */
-  virtual uint32_t objectSize() const {
-    return sizeof(CacheableDate);
-  }
+  virtual uint32_t objectSize() const { return sizeof(CacheableDate); }
 
   /** @return true if this key matches other. */
-  virtual bool operator==( const CacheableKey& other ) const;
+  virtual bool operator==(const CacheableKey& other) const;
 
   /**
    * @return day of the month.
@@ -124,122 +116,71 @@ class CPPCACHE_EXPORT CacheableDate
 
   /**
    * Returns a hash code value for this object. The result is the exclusive OR
-   * of the two halves of the primitive long value returned by the milliseconds()
-   * method.
+   * of the two halves of the primitive long value returned by the
+   * milliseconds() method.
    *
    * @return the hashcode for this object. */
   virtual uint32_t hashcode() const;
 
   operator time_t() const { return m_timevalue / 1000; }
-  operator time_point() const { return clock::from_time_t(0) + duration(m_timevalue); }
+  operator time_point() const {
+    return clock::from_time_t(0) + duration(m_timevalue);
+  }
   operator duration() const { return duration(m_timevalue); }
 
   /**
    * Factory method for creating an instance of CacheableDate
    */
-  static CacheableDatePtr create( )
-  {
+  static CacheableDatePtr create() {
     return CacheableDatePtr(new CacheableDate());
   }
 
-  static CacheableDatePtr create( const time_t& value )
-  {
+  static CacheableDatePtr create(const time_t& value) {
     return CacheableDatePtr(new CacheableDate(value));
   }
 
-  static CacheableDatePtr create( const time_point& value )
-  {
+  static CacheableDatePtr create(const time_point& value) {
     return CacheableDatePtr(new CacheableDate(value));
   }
 
-  static CacheableDatePtr create( const duration& value )
-  {
+  static CacheableDatePtr create(const duration& value) {
     return CacheableDatePtr(new CacheableDate(value));
   }
 
-  /**
-   * @deprecated Use other standard time types.
-   */
-  __DEPRECATED__("Use other standard time types.")
-  static CacheableDatePtr create( const timeval& value )
-  {
-    return CacheableDatePtr(new CacheableDate(toDuration(value)));
-  }
-
-  virtual CacheableStringPtr toString( ) const;
+  virtual CacheableStringPtr toString() const;
 
   /** Destructor */
-  virtual ~CacheableDate( );
+  virtual ~CacheableDate();
 
   /** used to render as a string for logging. */
-  virtual int32_t logString( char* buffer, int32_t maxLength ) const;
-
-  protected:
-
-  /** Constructor, given a timeval value.
-   *
-   * @deprecated Use other constructors.
-   */
-  __DEPRECATED__("Use other standard time types.")
-  CacheableDate( const timeval& value );
-
+  virtual int32_t logString(char* buffer, int32_t maxLength) const;
 
+ protected:
   /** Constructor, used for deserialization. */
-  CacheableDate( const time_t value = 0 );
+  CacheableDate(const time_t value = 0);
 
   /**
    * Construct from std::chrono::time_point<std::chrono::system_clock>.
    */
-  CacheableDate( const time_point& value );
+  CacheableDate(const time_point& value);
 
   /**
    * Construct from std::chrono::seconds since POSIX epoch.
    */
-  CacheableDate( const duration& value );
-
-  private:
+  CacheableDate(const duration& value);
 
+ private:
   // never implemented.
-  void operator=( const CacheableDate& other );
-  CacheableDate( const CacheableDate& other );
-
-  static duration toDuration(const timeval& value) {
-    return std::chrono::duration_cast<CacheableDate::duration>(
-        std::chrono::seconds(value.tv_sec) +
-        std::chrono::microseconds(value.tv_usec));
-  }
-
-  public:
-  friend CacheableKeyPtr createKey( const timeval& value );
-  friend CacheablePtr createValue( const timeval& value );
+  void operator=(const CacheableDate& other);
+  CacheableDate(const CacheableDate& other);
 };
 
-/**
- * @deprecated Use other standard time types.
- */
-__DEPRECATED__("Use other standard time types.")
-inline CacheableKeyPtr createKey( const timeval& value )
-{
-  return CacheableKeyPtr( CacheableDate::create( CacheableDate::toDuration(value) ) );
-}
-
-/**
- * @deprecated Use other standard time types.
- */
-__DEPRECATED__("Use other standard time types.")
-inline CacheablePtr createValue( const timeval& value )
-{
-  return CacheablePtr( CacheableDate::create( CacheableDate::toDuration(value) ) );
-}
-
-inline CacheableKeyPtr createKey( const CacheableDate::time_point& value )
-{
-  return CacheableKeyPtr( CacheableDate::create( value ) );
+inline CacheableKeyPtr createKey(const CacheableDate::time_point& value) {
+  return CacheableKeyPtr(CacheableDate::create(value));
 }
 
-inline CacheablePtr createValue( const CacheableDate::time_point& value )
-{
-  return CacheablePtr( CacheableDate::create( value ) );
+inline CacheablePtr createValue(const CacheableDate::time_point& value) {
+  return CacheablePtr(CacheableDate::create(value));
 }
 
 }  // namespace client

http://git-wip-us.apache.org/repos/asf/geode-native/blob/e1f99a67/src/cppcache/src/CacheableDate.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/src/CacheableDate.cpp b/src/cppcache/src/CacheableDate.cpp
index 02963cf..cbddfbc 100644
--- a/src/cppcache/src/CacheableDate.cpp
+++ b/src/cppcache/src/CacheableDate.cpp
@@ -27,12 +27,7 @@
 #include <ace/OS.h>
 
 #include <chrono>
-#include <time.h>
-#ifdef _WIN32
-#include <WinSock2.h>  // timeval
-#else
-#include <sys/time.h>  // timeval
-#endif
+#include <ctime>
 
 namespace apache {
 namespace geode {
@@ -89,23 +84,14 @@ int CacheableDate::year() const {
   return date.tm_year + 1900;
 }
 
-int64_t CacheableDate::milliseconds() const
-{
-  return m_timevalue;
-}
-
-uint32_t CacheableDate::hashcode( ) const
-{
-  return (int) m_timevalue ^ (int) (m_timevalue >> 32);
-}
+int64_t CacheableDate::milliseconds() const { return m_timevalue; }
 
-CacheableDate::CacheableDate(const timeval& value) {
-  m_timevalue = (((int64_t)value.tv_sec) * 1000) + (value.tv_usec / 1000);
+uint32_t CacheableDate::hashcode() const {
+  return static_cast<int>(m_timevalue) ^ static_cast<int>(m_timevalue >>
32);
 }
 
-CacheableDate::CacheableDate( const time_t value )
-{
-  m_timevalue = ((int64_t) value) * 1000;
+CacheableDate::CacheableDate(const time_t value) {
+  m_timevalue = (static_cast<int64_t>(value)) * 1000;
 }
 
 CacheableDate::CacheableDate(const CacheableDate::time_point& value) {
@@ -120,25 +106,26 @@ CacheableDate::CacheableDate(const CacheableDate::duration& value)
{
   m_timevalue = value.count();
 }
 
-CacheableDate::~CacheableDate( )
-{
-}
+CacheableDate::~CacheableDate() {}
 
 CacheableStringPtr CacheableDate::toString() const {
   char buffer[25];
-  struct tm date = { 0 };
+  struct tm date = {0};
   time_t sec = m_timevalue / 1000;
   ACE_OS::localtime_r(&sec, &date);
-  ACE_OS::snprintf(buffer, 24, "%d/%d/%d %d:%d:%d", date.tm_mon+1, date.tm_mday, date.tm_year+1900,
date.tm_hour, date.tm_min, date.tm_sec);
-  return CacheableString::create( buffer );
+  ACE_OS::snprintf(buffer, 24, "%d/%d/%d %d:%d:%d", date.tm_mon + 1,
+                   date.tm_mday, date.tm_year + 1900, date.tm_hour, date.tm_min,
+                   date.tm_sec);
+  return CacheableString::create(buffer);
 }
 
-int32_t CacheableDate::logString( char* buffer, int32_t maxLength ) const
-{
-  struct tm date = { 0 };
+int32_t CacheableDate::logString(char* buffer, int32_t maxLength) const {
+  struct tm date = {0};
   time_t sec = m_timevalue / 1000;
   ACE_OS::localtime_r(&sec, &date);
-  return ACE_OS::snprintf( buffer, maxLength, "CacheableDate (mm/dd/yyyy) ( %d/%d/%d )",
date.tm_mon+1, date.tm_mday, date.tm_year+1900 );
+  return ACE_OS::snprintf(buffer, maxLength,
+                          "CacheableDate (mm/dd/yyyy) ( %d/%d/%d )",
+                          date.tm_mon + 1, date.tm_mday, date.tm_year + 1900);
 }
 
 }  // namespace client


Mime
View raw message