VMware GemFire Native Client Cache Reference  9.0.6
CacheableDate.hpp
Go to the documentation of this file.
1 #ifndef _GEMFIRE_CACHEABLEDATE_HPP_
2 #define _GEMFIRE_CACHEABLEDATE_HPP_
3 /*=========================================================================
4  * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
5  * This product is protected by U.S. and international copyright
6  * and intellectual property laws. Pivotal products are covered by
7  * more patents listed at http://www.pivotal.io/patents.
8  *=========================================================================
9  */
10 #include "gfcpp_globals.hpp"
11 #include "gf_types.hpp"
12 #include "CacheableKey.hpp"
13 #include "CacheableString.hpp"
14 #include "GemfireTypeIds.hpp"
15 #include "ExceptionTypes.hpp"
16 #include <time.h>
17 #ifdef _WIN32
18 #include <WinSock2.h> //for struct timeval
19 #define GF_LOCALTIME(X,Y) localtime_s(Y,X)
20 #else
21 #include <sys/time.h>
22 #if defined(_LINUX) || defined(_SOLARIS) || defined(_MACOSX)
23 #define GF_LOCALTIME(X,Y) localtime_r(X,Y)
24 #endif
25 #endif
26 
29 namespace gemfire {
30 
31 
37  : public CacheableKey
38 {
39  private:
40 
41  struct timeval m_timevalue;
42  uint32_t m_hash;
43 
44  public:
45 
49  virtual void toData( DataOutput& output ) const;
50 
54  virtual Serializable* fromData( DataInput& input );
55 
59  static Serializable* createDeserializable( );
60 
66  virtual int32_t classId( ) const;
67 
73  virtual int8_t typeId( ) const;
74 
76  virtual uint32_t objectSize() const {
77  return sizeof(CacheableDate);
78  }
79 
81  virtual bool operator==( const CacheableKey& other ) const;
82 
84  virtual int day() const;
85 
87  virtual int month() const;
88 
90  virtual int year() const;
91 
93  virtual int64_t milliseconds() const;
94 
96  virtual uint32_t hashcode( ) const;
97 
102  {
103  return CacheableDatePtr(new CacheableDate());
104  }
105 
106  static CacheableDatePtr create( const time_t& value )
107  {
108  return CacheableDatePtr(new CacheableDate(value));
109  }
110 
111  static CacheableDatePtr create( const timeval& value )
112  {
113  return CacheableDatePtr(new CacheableDate(value));
114  }
115 
116  virtual CacheableStringPtr toString( ) const;
117 
119  virtual ~CacheableDate( );
120 
122  virtual int32_t logString( char* buffer, int32_t maxLength ) const;
123 
124  protected:
125 
127  CacheableDate( const timeval& value );
128 
130  CacheableDate( const time_t value = 0 );
131 
132  private:
133 
134  // never implemented.
135  void operator=( const CacheableDate& other );
136  CacheableDate( const CacheableDate& other );
137 
138 };
139 
140 inline CacheableKeyPtr createKey( const timeval& value )
141 {
142  return CacheableKeyPtr( CacheableDate::create( value ) );
143 }
144 
145 inline CacheablePtr createValue( const timeval& value )
146 {
147  return CacheablePtr( CacheableDate::create( value ) );
148 }
149 
150 }
151 
152 #endif
153 
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:62
Represents a cacheable key.
Definition: CacheableKey.hpp:23
This namespace contains all the GemFire C++ API classes, enumerations and globals.
Definition: Assert.hpp:19
Implement a date object based on system epoch that can serve as a distributable key object for cachin...
Definition: CacheableDate.hpp:36
This abstract base class is the superclass of all user objects in the cache that can be serialized...
Definition: Serializable.hpp:39
Provide operations for reading primitive data values, byte arrays, strings, Serializable objects from...
Definition: DataInput.hpp:44
#define CPPCACHE_EXPORT
Defines a GemFire CPPCACHE export.
Definition: gf_base.hpp:51
static CacheableDatePtr create()
Factory method for creating an instance of CacheableDate.
Definition: CacheableDate.hpp:101
Defines a reference counted shared pointer.
Definition: SharedPtr.hpp:35
virtual uint32_t objectSize() const
Definition: CacheableDate.hpp:76

GemFire C++ Cache API Documentation