geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [25/31] geode-native git commit: GEODE-2476: Replace gfcpp with geode.
Date Tue, 21 Feb 2017 17:40:38 GMT
http://git-wip-us.apache.org/repos/asf/geode-native/blob/fd58b100/src/cppcache/include/geode/Log.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/Log.hpp b/src/cppcache/include/geode/Log.hpp
new file mode 100644
index 0000000..9a9a4d1
--- /dev/null
+++ b/src/cppcache/include/geode/Log.hpp
@@ -0,0 +1,674 @@
+#pragma once
+
+#ifndef GEODE_LOG_H_
+#define GEODE_LOG_H_
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * The interface of the Log class
+ *
+ *
+ */
+
+#include "geode_globals.hpp"
+#include <stdio.h>
+#include <stdarg.h>
+
+/******************************************************************************/
+
+#ifndef GEODE_HIGHEST_LOG_LEVEL
+#define GEODE_HIGHEST_LOG_LEVEL All
+#endif
+
+#ifndef GEODE_MAX_LOG_FILE_LIMIT
+#define GEODE_MAX_LOG_FILE_LIMIT (1024 * 1024 * 1024)
+#endif
+
+#ifndef GEODE_MAX_LOG_DISK_LIMIT
+#define GEODE_MAX_LOG_DISK_LIMIT (1024ll * 1024ll * 1024ll * 1024ll)
+#endif
+
+#define _GF_MSG_LIMIT 8192
+
+/******************************************************************************/
+
+/** @file
+*/
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class Exception;
+
+/******************************************************************************/
+/******************************************************************************/
+
+/* Logs the message if the given level is less than or equal to the current
+ * logging level. */
+#define GF_LOG(level, expr)                             \
+  if (level > apache::geode::client::Log::logLevel()) { \
+  } else                                                \
+    apache::geode::client::Log::log(level, expr)
+
+/** Defines methods available to clients that want to write a log message
+  * to their Geode system's shared log file.
+  * <p>
+  * This class must be initialized prior to its use:
+  * @ref Log::init
+  * <p>
+  * For any logged message the log file will contain:
+  * <ul>
+  * <li> The message's level.
+  * <li> The time the message was logged.
+  * <li> The id of the connection and thread that logged the message.
+  * <li> The message itself which can be a const char* (perhaps with
+  * an exception including the exception's stack trace.
+  * </ul>
+  * <p>
+  * A message always has a level.
+  * Logging levels are ordered. Enabling logging at a given level also
+  * enables logging at higher levels. The higher the level the more
+  * important and urgent the message.
+  * <p>
+  * The levels, in descending order of severity, are:
+  * <ul>
+  *
+  * <li> <code>error</code> (highest severity) is a message level
+  * indicating a serious failure.  In general <code>error</code>
+  * messages should describe events that are of considerable
+  * importance and which will prevent normal program execution. They
+  * should be reasonably intelligible to end users and to system
+  * administrators.
+  *
+  * <li> <code>warning</code> is a message level indicating a
+  * potential problem.  In general <code>warning</code> messages
+  * should describe events that will be of interest to end users or
+  * system managers, or which indicate potential problems.
+  *
+  * <li> <code>info</code> is a message level for informational
+  * messages.  Typically <code>info</code> messages should be
+  * reasonably significant and should make sense to end users and
+  * system administrators.
+  *
+  * <li> <code>config</code> is a message level for static
+  * configuration messages.  <code>config</code> messages are intended
+  * to provide a variety of static configuration information, to
+  * assist in debugging problems that may be associated with
+  * particular configurations.
+  *
+  * <li> <code>fine</code> is a message level providing tracing
+  * information.  In general the <code>fine</code> level should be
+  * used for information that will be broadly interesting to
+  * developers. This level is for the lowest volume, and most
+  * important, tracing messages.
+  *
+  * <li> <code>finer</code> indicates a moderately detailed tracing
+  * message.  This is an intermediate level between <code>fine</code>
+  * and <code>finest</code>.
+  *
+  * <li> <code>finest</code> indicates a very detailed tracing
+  * message.  Logging calls for entering, returning, or throwing an
+  * exception are traced at the <code>finest</code> level.
+  *
+  * <li> <code>debug</code> (lowest severity) indicates a highly
+  * detailed tracing message.  In general the <code>debug</code> level
+  * should be used for the most voluminous detailed tracing messages.
+  * </ul>
+  *
+  * <p>
+  * For each level methods exist that will request a message, at that
+  * level, to be logged. These methods are all named after their level.
+  * <p>
+  * For each level a method exists that indicates if messages at that
+  * level will currently be logged. The names of these methods are of
+  * the form: <em>level</em><code>Enabled</code>.
+  *
+  *
+  */
+
+class CPPCACHE_EXPORT Log {
+ public:
+  /******/
+
+  enum LogLevel {
+
+    // NOTE: if you change this enum declaration at all, be sure to
+    // change levelToChars and charsToLevel functions!
+
+    None,
+
+    Error,
+    Warning,
+    Info,
+
+    Default,
+
+    Config,
+
+    Fine,
+    Finer,
+    Finest,
+
+    Debug,
+
+    All
+
+  };
+
+  /******/
+
+  /**
+   * Returns the current log level.
+   */
+  static LogLevel logLevel() { return s_logLevel; }
+
+  /**
+   * Set the current log level.
+   */
+  static void setLogLevel(LogLevel level) { s_logLevel = level; }
+
+  /**
+   * @return the name of the current log file.
+   * NOTE: This function is for debugging only, as it is not completely
+   * thread-safe!
+   */
+  static const char* logFileName();
+
+  /**
+   * Initializes logging facility with given level and filenames.
+   * This method is called automatically within @ref DistributedSystem::connect
+   * with the log-file, log-level, and log-file-size system properties used as
+   * arguments
+   */
+  static void init
+      // 0 => use maximum value (currently 1G)
+      (LogLevel level, const char* logFileName, int32 logFileLimit = 0,
+       int64 logDiskSpaceLimit = 0);
+
+  /**
+   * closes logging facility (until next init).
+   */
+  static void close();
+
+  /**
+   * returns character string for given log level. The string will be
+   * identical to the enum declaration above, except it will be all
+   * lower case. Out of range values will throw
+   * IllegalArgumentException.
+   */
+  static const char* levelToChars(Log::LogLevel level);
+
+  /**
+   * returns log level specified by "chars", or throws
+   * IllegalArgumentException.  Allowed values are identical to the
+   * enum declaration above for LogLevel, but with character case ignored.
+   */
+  static LogLevel charsToLevel(const char* chars);
+
+  /**
+   * Fills the provided buffer with formatted log-line given the level
+   * and returns the buffer. This assumes that the buffer has large
+   * enough space left to hold the formatted log-line (around 70 chars).
+   *
+   * This is provided so that applications wishing to use the same format
+   * as Geode log-lines can do so easily. A log-line starts with the prefix
+   * given below which is filled in by this method:
+   * [<level> <date> <time> <timezone> <host>:<process ID> <thread ID>]
+   *
+   * This method is not thread-safe for the first invocation.
+   * When invoking from outside either <init> should have been invoked,
+   * or at least the first invocation should be single-threaded.
+   */
+  static char* formatLogLine(char* buf, LogLevel level);
+
+  /******/
+
+  /**
+   * Returns whether log messages at given level are enabled.
+   */
+  static bool enabled(LogLevel level) {
+    return (((s_doingDebug && level == Debug) ||
+             GEODE_HIGHEST_LOG_LEVEL >= level) &&
+            s_logLevel >= level);
+  }
+
+  /**
+   * Logs a message at given level.
+   */
+  static void log(LogLevel level, const char* msg) {
+    if (enabled(level)) put(level, msg);
+  }
+
+  /**
+   * Logs both a message and thrown exception.
+   */
+  static void logThrow(LogLevel level, const char* msg, const Exception& ex) {
+    if (enabled(level)) putThrow(level, msg, ex);
+  }
+
+  /**
+   * Logs both a message and caught exception.
+   */
+  static void logCatch(LogLevel level, const char* msg, const Exception& ex) {
+    if (enabled(level)) putCatch(level, msg, ex);
+  }
+
+  /******/
+
+  /**
+   * Returns whether "error" log messages are enabled.
+   */
+  static bool errorEnabled() {
+    return GEODE_HIGHEST_LOG_LEVEL >= Error && s_logLevel >= Error;
+  }
+
+  /**
+   * Logs a message.
+   * The message level is "error".
+   */
+  static void error(const char* msg) {
+    if (errorEnabled()) put(Error, msg);
+  }
+
+  /**
+   * Logs both a message and thrown exception.
+   * The message level is "error".
+   */
+  static void errorThrow(const char* msg, const Exception& ex) {
+    if (errorEnabled()) putThrow(Error, msg, ex);
+  }
+
+  /**
+   * Writes both a message and caught exception.
+   * The message level is "error".
+   */
+  static void errorCatch(const char* msg, const Exception& ex) {
+    if (errorEnabled()) putCatch(Error, msg, ex);
+  }
+
+  /******/
+
+  /**
+   * Returns whether "warning" log messages are enabled.
+   */
+  static bool warningEnabled() {
+    return GEODE_HIGHEST_LOG_LEVEL >= Warning && s_logLevel >= Warning;
+  }
+
+  /**
+   * Logs a message.
+   * The message level is "warning".
+   */
+  static void warning(const char* msg) {
+    if (warningEnabled()) put(Warning, msg);
+  }
+
+  /**
+   * Logs both a message and thrown exception.
+   * The message level is "warning".
+   */
+  static void warningThrow(const char* msg, const Exception& ex) {
+    if (warningEnabled()) putThrow(Warning, msg, ex);
+  }
+
+  /**
+   * Writes both a message and caught exception.
+   * The message level is "warning".
+   */
+  static void warningCatch(const char* msg, const Exception& ex) {
+    if (warningEnabled()) putCatch(Warning, msg, ex);
+  }
+
+  /******/
+
+  /**
+   * Returns whether "info" log messages are enabled.
+   */
+  static bool infoEnabled() {
+    return GEODE_HIGHEST_LOG_LEVEL >= Info && s_logLevel >= Info;
+  }
+
+  /**
+   * Logs a message.
+   * The message level is "info".
+   */
+  static void info(const char* msg) {
+    if (infoEnabled()) put(Info, msg);
+  }
+
+  /**
+   * Logs both a message and thrown exception.
+   * The message level is "info".
+   */
+  static void infoThrow(const char* msg, const Exception& ex) {
+    if (infoEnabled()) putThrow(Info, msg, ex);
+  }
+
+  /**
+   * Writes both a message and caught exception.
+   * The message level is "info".
+   */
+  static void infoCatch(const char* msg, const Exception& ex) {
+    if (infoEnabled()) putCatch(Info, msg, ex);
+  }
+
+  /******/
+
+  /**
+   * Returns whether "config" log messages are enabled.
+   */
+  static bool configEnabled() {
+    return GEODE_HIGHEST_LOG_LEVEL >= Config && s_logLevel >= Config;
+  }
+
+  /**
+   * Logs a message.
+   * The message level is "config".
+   */
+  static void config(const char* msg) {
+    if (configEnabled()) put(Config, msg);
+  }
+
+  /**
+   * Logs both a message and thrown exception.
+   * The message level is "config".
+   */
+  static void configThrow(const char* msg, const Exception& ex) {
+    if (configEnabled()) putThrow(Config, msg, ex);
+  }
+
+  /**
+   * Writes both a message and caught exception.
+   * The message level is "config".
+   */
+  static void configCatch(const char* msg, const Exception& ex) {
+    if (configEnabled()) putCatch(Config, msg, ex);
+  }
+
+  /******/
+
+  /**
+   * Returns whether "fine" log messages are enabled.
+   */
+  static bool fineEnabled() {
+    return GEODE_HIGHEST_LOG_LEVEL >= Fine && s_logLevel >= Fine;
+  }
+
+  /**
+   * Logs a message.
+   * The message level is "fine".
+   */
+  static void fine(const char* msg) {
+    if (fineEnabled()) put(Fine, msg);
+  }
+
+  /**
+   * Logs both a message and thrown exception.
+   * The message level is "fine".
+   */
+  static void fineThrow(const char* msg, const Exception& ex) {
+    if (fineEnabled()) putThrow(Fine, msg, ex);
+  }
+
+  /**
+   * Writes both a message and caught exception.
+   * The message level is "fine".
+   */
+  static void fineCatch(const char* msg, const Exception& ex) {
+    if (fineEnabled()) putCatch(Fine, msg, ex);
+  }
+
+  /******/
+
+  /**
+   * Returns whether "finer" log messages are enabled.
+   */
+  static bool finerEnabled() {
+    return GEODE_HIGHEST_LOG_LEVEL >= Finer && s_logLevel >= Finer;
+  }
+
+  /**
+   * Logs a message.
+   * The message level is "finer".
+   */
+  static void finer(const char* msg) {
+    if (finerEnabled()) put(Finer, msg);
+  }
+
+  /**
+   * Logs both a message and thrown exception.
+   * The message level is "finer".
+   */
+  static void finerThrow(const char* msg, const Exception& ex) {
+    if (finerEnabled()) putThrow(Finer, msg, ex);
+  }
+
+  /**
+   * Writes both a message and caught exception.
+   * The message level is "finer".
+   */
+  static void finerCatch(const char* msg, const Exception& ex) {
+    if (finerEnabled()) putCatch(Finer, msg, ex);
+  }
+
+  /******/
+
+  /**
+   * Returns whether "finest" log messages are enabled.
+   */
+  static bool finestEnabled() {
+    return GEODE_HIGHEST_LOG_LEVEL >= Finest && s_logLevel >= Finest;
+  }
+
+  /**
+   * Logs a message.
+   * The message level is "finest".
+   */
+  static void finest(const char* msg) {
+    if (finestEnabled()) put(Finest, msg);
+  }
+
+  /**
+   * Logs both a message and thrown exception.
+   * The message level is "finest".
+   */
+  static void finestThrow(const char* msg, const Exception& ex) {
+    if (finestEnabled()) putThrow(Finest, msg, ex);
+  }
+
+  /**
+   * Writes both a message and caught exception.
+   * The message level is "finest".
+   */
+  static void finestCatch(const char* msg, const Exception& ex) {
+    if (finestEnabled()) putCatch(Finest, msg, ex);
+  }
+
+  /******/
+
+  /**
+   * Returns whether "debug" log messages are enabled.
+   */
+  static bool debugEnabled() {
+    return (s_doingDebug || GEODE_HIGHEST_LOG_LEVEL >= Debug) &&
+           s_logLevel >= Debug;
+  }
+
+  /**
+   * Logs a message.
+   * The message level is "debug".
+   */
+  static void debug(const char* msg) {
+    if (debugEnabled()) put(Debug, msg);
+  }
+
+  /**
+   * Logs both a message and thrown exception.
+   * The message level is "debug".
+   */
+  static void debugThrow(const char* msg, const Exception& ex) {
+    if (debugEnabled()) putThrow(Debug, msg, ex);
+  }
+
+  /**
+   * Writes both a message and caught exception.
+   * The message level is "debug".
+   */
+  static void debugCatch(const char* msg, const Exception& ex) {
+    if (debugEnabled()) putCatch(Debug, msg, ex);
+  }
+
+  /******/
+
+  static void enterFn(LogLevel level, const char* functionName);
+
+  static void exitFn(LogLevel level, const char* functionName);
+
+  /******/
+
+ private:
+  static LogLevel s_logLevel;
+
+/******/
+
+#ifdef DEBUG
+  enum { s_doingDebug = 1 };
+#else
+  enum { s_doingDebug = 0 };
+#endif
+
+  /******/
+
+  static void writeBanner();
+
+  /******/
+ public:
+  static void put(LogLevel level, const char* msg);
+
+  static void putThrow(LogLevel level, const char* msg, const Exception& ex);
+
+  static void putCatch(LogLevel level, const char* msg, const Exception& ex);
+};
+
+/******************************************************************************/
+/******************************************************************************/
+
+class LogFn {
+  const char* m_functionName;
+  Log::LogLevel m_level;
+
+ public:
+  LogFn(const char* functionName, Log::LogLevel level = Log::Finest)
+      : m_functionName(functionName), m_level(level) {
+    if (Log::enabled(m_level)) Log::enterFn(m_level, m_functionName);
+  }
+
+  ~LogFn() {
+    if (Log::enabled(m_level)) Log::exitFn(m_level, m_functionName);
+  }
+
+ private:
+  LogFn(const LogFn& rhs);           // never defined
+  void operator=(const LogFn& rhs);  // never defined
+};
+
+/******************************************************************************/
+/******************************************************************************/
+
+/**
+ * These functions are added to facilitate logging in printf format.
+ */
+
+class CPPCACHE_EXPORT LogVarargs {
+ public:
+  static void debug(const char* fmt, ...);
+  static void error(const char* fmt, ...);
+  static void warn(const char* fmt, ...);
+  static void info(const char* fmt, ...);
+  static void config(const char* fmt, ...);
+  static void fine(const char* fmt, ...);
+  static void finer(const char* fmt, ...);
+  static void finest(const char* fmt, ...);
+};
+}  // namespace client
+}  // namespace geode
+}  // namespace apache
+
+/************************ LOGDEBUG ***********************************/
+
+#define LOGDEBUG                              \
+  if (apache::geode::client::Log::Debug <=    \
+      apache::geode::client::Log::logLevel()) \
+  apache::geode::client::LogVarargs::debug
+
+/************************ LOGERROR ***********************************/
+
+#define LOGERROR                              \
+  if (apache::geode::client::Log::Error <=    \
+      apache::geode::client::Log::logLevel()) \
+  apache::geode::client::LogVarargs::error
+
+/************************ LOGWARN ***********************************/
+
+#define LOGWARN                               \
+  if (apache::geode::client::Log::Warning <=  \
+      apache::geode::client::Log::logLevel()) \
+  apache::geode::client::LogVarargs::warn
+
+/************************ LOGINFO ***********************************/
+
+#define LOGINFO                               \
+  if (apache::geode::client::Log::Info <=     \
+      apache::geode::client::Log::logLevel()) \
+  apache::geode::client::LogVarargs::info
+
+/************************ LOGCONFIG ***********************************/
+
+#define LOGCONFIG                             \
+  if (apache::geode::client::Log::Config <=   \
+      apache::geode::client::Log::logLevel()) \
+  apache::geode::client::LogVarargs::config
+
+/************************ LOGFINE ***********************************/
+
+#define LOGFINE                               \
+  if (apache::geode::client::Log::Fine <=     \
+      apache::geode::client::Log::logLevel()) \
+  apache::geode::client::LogVarargs::fine
+
+/************************ LOGFINER ***********************************/
+
+#define LOGFINER                              \
+  if (apache::geode::client::Log::Finer <=    \
+      apache::geode::client::Log::logLevel()) \
+  apache::geode::client::LogVarargs::finer
+
+/************************ LOGFINEST ***********************************/
+
+#define LOGFINEST                             \
+  if (apache::geode::client::Log::Finest <=   \
+      apache::geode::client::Log::logLevel()) \
+  apache::geode::client::LogVarargs::finest
+
+/******************************************************************************/
+
+/******************************************************************************/
+
+#endif  // GEODE_LOG_H_

http://git-wip-us.apache.org/repos/asf/geode-native/blob/fd58b100/src/cppcache/include/geode/PartitionResolver.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/PartitionResolver.hpp b/src/cppcache/include/geode/PartitionResolver.hpp
new file mode 100644
index 0000000..48d3c7c
--- /dev/null
+++ b/src/cppcache/include/geode/PartitionResolver.hpp
@@ -0,0 +1,111 @@
+#pragma once
+
+#ifndef GEODE_PARTITIONRESOLVER_H_
+#define GEODE_PARTITIONRESOLVER_H_
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SharedPtr.hpp"
+#include "Cacheable.hpp"
+#include <string>
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class EntryEvent;
+
+/**
+* Implementers of interface <code>PartitionResolver</code> enable custom
+* partitioning on the <code>PartitionedRegion</code>.
+* 1. The Key class or callback arg can implement PartitionResolver interface to
+* enable custom partitioning OR
+* 2. Configure your own PartitionResolver class in partition attributes (For
+* instance when the Key is a primitive type or String) Implement the
+* appropriate equals - For all implementations, you need to be sure to code the
+* class equals method so it properly verifies equality for the
+* PartitionResolver implementation. This might mean verifying that class names
+* are the same or that the returned routing objects are the same etc.. When you
+* initiate the partitioned region on multiple nodes, Geode uses the equals
+* method to ensure you are using the same PartitionResolver implementation for
+* all of the nodes for the region.
+* Geode uses the routing object's hashCode to determine where the data is
+* being managed. Say, for example, you want to colocate all Trades by month and
+* year.The key is implemented by TradeKey class which also implements the
+* PartitionResolver interface.
+* public class TradeKey implements PartitionResolver {<br>
+* &nbsp &nbsp private String tradeID;<br>
+* &nbsp &nbsp private Month month ;<br>
+* &nbsp &nbsp private Year year ;<br>
+*
+* &nbsp &nbsp public TradingKey(){ } <br>
+* &nbsp &nbsp public TradingKey(Month month, Year year){<br>
+* &nbsp &nbsp &nbsp &nbsp this.month = month;<br>
+* &nbsp &nbsp &nbsp &nbsp this.year = year;<br>
+* &nbsp &nbsp } <br>
+* &nbsp &nbsp public Serializable getRoutingObject(EntryOperation
+* opDetails){<br>
+* &nbsp &nbsp &nbsp &nbsp return this.month + this.year;<br>
+* &nbsp &nbsp }<br> }<br>
+*
+* In the example above, all trade entries with the same month and year are
+* guaranteed to be colocated.
+*/
+class CPPCACHE_EXPORT PartitionResolver : public SharedBase {
+  /**
+  * @brief public methods
+  */
+
+ public:
+  /**
+  * @brief destructor
+  */
+  virtual ~PartitionResolver();
+
+  /**
+  * Returns the name of the PartitionResolver
+  * @return String name
+  */
+  virtual const char* getName();
+
+  /**
+  * @param opDetails the detail of the entry event
+  * @throws RuntimeException - any exception thrown will terminate the operation
+  * and the exception will be passed to the
+  * calling thread.
+  * @return object associated with entry event which allows the Partitioned
+  * Region to store associated data together
+  */
+  virtual CacheableKeyPtr getRoutingObject(const EntryEvent& opDetails) = 0;
+
+ protected:
+  /**
+  * @brief constructors
+  */
+  PartitionResolver();
+
+ private:
+  // never implemented.
+  PartitionResolver(const PartitionResolver& other);
+  void operator=(const PartitionResolver& other);
+};
+}  // namespace client
+}  // namespace geode
+}  // namespace apache
+
+#endif  // GEODE_PARTITIONRESOLVER_H_

http://git-wip-us.apache.org/repos/asf/geode-native/blob/fd58b100/src/cppcache/include/geode/PdxAutoSerializer.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/PdxAutoSerializer.hpp b/src/cppcache/include/geode/PdxAutoSerializer.hpp
new file mode 100644
index 0000000..e4b7af4
--- /dev/null
+++ b/src/cppcache/include/geode/PdxAutoSerializer.hpp
@@ -0,0 +1,529 @@
+#pragma once
+
+#ifndef GEODE_PDXAUTOSERIALIZER_H_
+#define GEODE_PDXAUTOSERIALIZER_H_
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "geode_globals.hpp"
+#include "PdxWriter.hpp"
+#include "PdxReader.hpp"
+#include "VectorT.hpp"
+#include "HashMapT.hpp"
+#include "HashSetT.hpp"
+#include "GeodeTypeIds.hpp"
+#include "TypeHelper.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+namespace PdxAutoSerializable {
+// Read and write methods for various types
+// uint8_t
+//------------------------------------------------------------------------------------------------
+#ifdef _SOLARIS
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, int8_t value) {
+  pw->writeByte(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, int8_t& value) {
+  value = pr->readByte(fieldName);
+}
+#else
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, char value) {
+  pw->writeChar(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, char& value) {
+  value = pr->readChar(fieldName);
+}
+#endif
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, wchar_t value) {
+  pw->writeWideChar(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, wchar_t& value) {
+  value = pr->readWideChar(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, bool value) {
+  pw->writeBoolean(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, bool& value) {
+  value = pr->readBoolean(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, signed char value) {
+  pw->writeByte(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, signed char& value) {
+  value = pr->readByte(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, int16_t value) {
+  pw->writeShort(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, int16_t& value) {
+  value = pr->readShort(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, int32_t value) {
+  pw->writeInt(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, int32_t& value) {
+  value = pr->readInt(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, int64_t value) {
+  pw->writeLong(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, int64_t& value) {
+  value = pr->readLong(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, float value) {
+  pw->writeFloat(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, float& value) {
+  value = pr->readFloat(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, double value) {
+  pw->writeDouble(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, double& value) {
+  value = pr->readDouble(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, CacheableDatePtr value) {
+  pw->writeDate(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, CacheableDatePtr& value) {
+  value = pr->readDate(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, const char* value) {
+  pw->writeString(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, char*& value) {
+  value = pr->readString(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, const wchar_t* value) {
+  pw->writeWideString(fieldName, value);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, wchar_t*& value) {
+  value = pr->readWideString(fieldName);
+}
+// ---- helper methods for bytearrayofarray -------
+#ifdef _SOLARIS
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, char** value,
+                           int32_t arraySize, int32_t* elemArraySize) {
+  pw->writeArrayOfByteArrays(fieldName, (char**)value, arraySize,
+                             elemArraySize);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, char**& value, int32_t& len,
+                          int32_t*& Lengtharr) {
+  GF_NEW(Lengtharr, int32_t[len]);
+  value = (char**)pr->readArrayOfByteArrays(fieldName, len, &Lengtharr);
+}
+#else
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, int8_t** value,
+                           int32_t arraySize, int32_t* elemArraySize) {
+  pw->writeArrayOfByteArrays(fieldName, value, arraySize, elemArraySize);
+}
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, int8_t**& value, int32_t& len,
+                          int32_t*& Lengtharr) {
+  GF_NEW(Lengtharr, int32_t[len]);
+  value = (signed char**)pr->readArrayOfByteArrays(fieldName, len, &Lengtharr);
+}
+#endif
+
+//------------------------------------------------------------------------------------------------
+// Base Serializable types
+template <typename TObj>
+inline void writePdxObject(
+    apache::geode::client::PdxWriterPtr& pw, const char* fieldName,
+    const apache::geode::client::SharedPtr<TObj>& value,
+    apache::geode::client::TypeHelper::yes_type isSerializable) {
+  pw->writeObject(fieldName, value);
+}
+
+template <typename TObj>
+inline void writePdxObject(
+    apache::geode::client::PdxWriterPtr& pw, const char* fieldName,
+    const apache::geode::client::SharedPtr<TObj>& value) {
+  writePdxObject(pw, fieldName, value, GF_TYPE_IS_SERIALIZABLE_TYPE(TObj));
+}
+
+template <typename TObj>
+inline void readPdxObject(
+    apache::geode::client::PdxReaderPtr& pr, const char* fieldName,
+    apache::geode::client::SharedPtr<TObj>& value,
+    apache::geode::client::TypeHelper::yes_type isSerializable) {
+  value = dynCast<apache::geode::client::SharedPtr<TObj> >(
+      pr->readObject(fieldName));
+}
+
+template <typename TObj>
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName,
+                          apache::geode::client::SharedPtr<TObj>& value) {
+  readPdxObject(pr, fieldName, value, GF_TYPE_IS_SERIALIZABLE_TYPE(TObj));
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, bool* value, int32_t len) {
+  pw->writeBooleanArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, bool*& value, int32_t& len) {
+  value = pr->readBooleanArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, wchar_t* value, int32_t len) {
+  pw->writeWideCharArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, wchar_t*& value,
+                          int32_t& len) {
+  value = pr->readWideCharArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+#ifdef _SOLARIS
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, int8_t* value, int32_t len) {
+  pw->writeByteArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, int8_t*& value, int32_t& len) {
+  value = (int8_t*)pr->readByteArray(fieldName, len);
+}
+#else
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, char* value, int32_t len) {
+  pw->writeCharArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, char*& value, int32_t& len) {
+  value = pr->readCharArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, signed char* value,
+                           int32_t len) {
+  pw->writeByteArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, signed char*& value,
+                          int32_t& len) {
+  value = (signed char*)pr->readByteArray(fieldName, len);
+}
+#endif
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, int16_t* value, int32_t len) {
+  pw->writeShortArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, int16_t*& value,
+                          int32_t& len) {
+  value = pr->readShortArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, int32_t* value, int32_t len) {
+  pw->writeIntArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, int32_t*& value,
+                          int32_t& len) {
+  value = pr->readIntArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, int64_t* value, int32_t len) {
+  pw->writeLongArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, int64_t*& value,
+                          int32_t& len) {
+  value = pr->readLongArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, float* value, int32_t len) {
+  pw->writeFloatArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, float*& value, int32_t& len) {
+  value = pr->readFloatArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, double* value, int32_t len) {
+  pw->writeDoubleArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, double*& value, int32_t& len) {
+  value = pr->readDoubleArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, char** value, int32_t len) {
+  pw->writeStringArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, char**& value, int32_t& len) {
+  value = pr->readStringArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName, wchar_t** value,
+                           int32_t len) {
+  pw->writeWideStringArray(fieldName, value, len);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName, wchar_t**& value,
+                          int32_t& len) {
+  value = pr->readWideStringArray(fieldName, len);
+}
+//------------------------------------------------------------------------------------------------
+inline void writePdxObject(apache::geode::client::PdxWriterPtr& pw,
+                           const char* fieldName,
+                           CacheableObjectArrayPtr value) {
+  pw->writeObjectArray(fieldName, value);
+}
+
+inline void readPdxObject(apache::geode::client::PdxReaderPtr& pr,
+                          const char* fieldName,
+                          CacheableObjectArrayPtr& value) {
+  value = pr->readObjectArray(fieldName);
+}
+//------------------------------------------------------------------------------------------------
+// For containers vector/hashmap/hashset
+// template <typename TObj>
+// inline void writePdxObject( apache::geode::client::PdxWriterPtr& pw,  const
+// char*
+// fieldName,
+//    const VectorT< TObj >& value )
+//{
+//  int32_t len = (int32_t)value.size();
+//  pw->writeArrayLen( len );
+//  for ( typename VectorT< TObj >::Iterator iter = value.begin( );
+//      iter != value.end( ); ++iter ) {
+//    writePdxObject( output, *iter );
+//  }
+//}
+
+// inline uint32_t objectSize( const _VectorOfCacheable& value )
+//{
+//  uint32_t objectSize = 0;
+//  for ( _VectorOfCacheable::Iterator iter = value.begin( );
+//      iter != value.end( ); ++iter ) {
+//    if (*iter != NULLPTR) {
+//      objectSize += (*iter)->objectSize( );
+//    }
+//  }
+//  objectSize += (sizeof(CacheablePtr) * (uint32_t)value.size());
+//  return objectSize;
+//}
+
+// template <typename TObj>
+// inline void readPdxObject( apache::geode::client::PdxReaderPtr& pr,  const
+// char* fieldName,
+//    VectorT< TObj >& value )
+//{
+//  int32_t len;
+//  pr->readArrayLen( &len );
+//  if ( len >= 0 ) {
+//    TObj obj;
+//    for ( int32_t index = 0; index < len; index++ ) {
+//      readPdxObject( input, obj );
+//      value.push_back( obj );
+//    }
+//  }
+//}
+
+// template <typename TKey, typename TValue>
+// inline void writePdxObject( apache::geode::client::PdxWriterPtr& pw,  const
+// char*
+// fieldName,
+//    const HashMapT< TKey, TValue >& value )
+//{
+//  int32_t len = (int32_t)value.size();
+//  pw->writeArrayLen( len );
+//  if ( len > 0 ) {
+//    for ( typename HashMapT< TKey, TValue >::Iterator iter = value.begin( );
+//        iter != value.end( ); ++iter ) {
+//      writePdxObject( output, iter.first( ) );
+//      writePdxObject( output, iter.second( ) );
+//    }
+//  }
+//}
+
+// inline uint32_t objectSize( const _HashMapOfCacheable& value )
+//{
+//  uint32_t objectSize = 0;
+//  for ( _HashMapOfCacheable::Iterator iter = value.begin( );
+//      iter != value.end( ); ++iter ) {
+//    objectSize += iter.first( )->objectSize( );
+//    if (iter.second( ) != NULLPTR) {
+//      objectSize += iter.second( )->objectSize( );
+//    }
+//  }
+//  objectSize += ( ( sizeof( CacheableKeyPtr ) + sizeof( CacheablePtr ) )
+//      * (uint32_t)value.size());
+//  return objectSize;
+//}
+
+// template <typename TKey, typename TValue>
+// inline void readPdxObject( apache::geode::client::PdxReaderPtr& pr,  const
+// char* fieldName,
+//    HashMapT< TKey, TValue >& value )
+//{
+//  int32_t len;
+//  pr->readArrayLen( &len );
+//  if ( len > 0 ) {
+//    TKey key;
+//    TValue val;
+//    for( int32_t index = 0; index < len; index++ ) {
+//      readPdxObject( input, key );
+//      readPdxObject( input, val );
+//      value.insert( key, val );
+//    }
+//  }
+//}
+
+// template <typename TKey>
+// inline void writePdxObject( apache::geode::client::PdxWriterPtr& pw,  const
+// char*
+// fieldName,
+//  const HashSetT< TKey >& value )
+//{
+//  int32_t len = (int32_t)value.size();
+//  pw->writeArrayLen( len );
+//  for ( typename HashSetT< TKey >::Iterator iter = value.begin( );
+//    iter != value.end( ); ++iter ) {
+//    writePdxObject( output, *iter );
+//  }
+//}
+
+// inline uint32_t objectSize( const _HashSetOfCacheableKey& value )
+//{
+//  uint32_t objectSize = 0;
+//  for ( _HashSetOfCacheableKey::Iterator iter = value.begin( );
+//    iter != value.end( ); ++iter ) {
+//    if (*iter != NULLPTR) {
+//      objectSize += (*iter)->objectSize( );
+//    }
+//  }
+//  objectSize += (sizeof(CacheableKeyPtr) * (uint32_t)value.size());
+//  return objectSize;
+//}
+
+// template <typename TKey>
+// inline void readPdxObject( apache::geode::client::PdxReaderPtr& pr,  const
+// char* fieldName,
+//    HashSetT< TKey >& value )
+//{
+//  int32_t len;
+//  pr->readArrayLen( &len );
+//  if ( len > 0 ) {
+//    TKey key;
+//    for( int32_t index = 0; index < len; index++ ) {
+//      readPdxObject( input, key );
+//      value.insert( key );
+//    }
+//  }
+//}
+
+//// Default value for builtin types
+
+// template <typename TObj>
+// inline TObj zeroObject( )
+//{
+//  return 0;
+//}
+
+// template <>
+// inline bool zeroObject<bool>( )
+//{
+//  return false;
+//}
+
+// template <>
+// inline double zeroObject<double>( )
+//{
+//  return 0.0;
+//}
+
+// template <>
+// inline float zeroObject<float>( )
+//{
+//  return 0.0F;
+//}
+
+}  // namespace PdxAutoSerializable
+}  // namespace client
+}  // namespace geode
+}  // namespace apache
+
+#endif  // GEODE_PDXAUTOSERIALIZER_H_

http://git-wip-us.apache.org/repos/asf/geode-native/blob/fd58b100/src/cppcache/include/geode/PdxFieldTypes.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/PdxFieldTypes.hpp b/src/cppcache/include/geode/PdxFieldTypes.hpp
new file mode 100644
index 0000000..b11dcae
--- /dev/null
+++ b/src/cppcache/include/geode/PdxFieldTypes.hpp
@@ -0,0 +1,58 @@
+#pragma once
+
+#ifndef GEODE_PDXFIELDTYPES_H_
+#define GEODE_PDXFIELDTYPES_H_
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace apache {
+namespace geode {
+namespace client {
+
+class CPPCACHE_EXPORT PdxFieldTypes {
+ public:
+  enum PdxFieldType {
+    BOOLEAN,
+    BYTE,
+    CHAR,
+    SHORT,
+    INT,
+    LONG,
+    FLOAT,
+    DOUBLE,
+    DATE,
+    STRING,
+    OBJECT,
+    BOOLEAN_ARRAY,
+    CHAR_ARRAY,
+    BYTE_ARRAY,
+    SHORT_ARRAY,
+    INT_ARRAY,
+    LONG_ARRAY,
+    FLOAT_ARRAY,
+    DOUBLE_ARRAY,
+    STRING_ARRAY,
+    OBJECT_ARRAY,
+    ARRAY_OF_BYTE_ARRAYS
+  };
+};
+}  // namespace client
+}  // namespace geode
+}  // namespace apache
+
+#endif  // GEODE_PDXFIELDTYPES_H_

http://git-wip-us.apache.org/repos/asf/geode-native/blob/fd58b100/src/cppcache/include/geode/PdxInstance.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/include/geode/PdxInstance.hpp b/src/cppcache/include/geode/PdxInstance.hpp
new file mode 100644
index 0000000..bb5722e
--- /dev/null
+++ b/src/cppcache/include/geode/PdxInstance.hpp
@@ -0,0 +1,618 @@
+#pragma once
+
+#ifndef GEODE_PDXINSTANCE_H_
+#define GEODE_PDXINSTANCE_H_
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "PdxSerializable.hpp"
+#include "CacheableBuiltins.hpp"
+#include "PdxFieldTypes.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+/**
+* PdxInstance provides run time access to the fields of a PDX without
+* deserializing the PDX. Preventing deserialization saves time
+* and memory.
+* The PdxInstance implementation
+* is a light weight wrapper that simply refers to the raw bytes of the PDX
+* that are kept in the cache.
+* Applications can choose to access PdxInstances instead of C++ objects by
+* configuring the Cache to prefer PDX instances during deserialization.
+* This can be done in <code>cache.xml</code> by setting the attribute
+* <code>read-serialized</code>
+* to true on the <code>pdx</code> element. Or it can be done programmatically
+* using
+* {@link CacheFactory#setPdxReadSerialized(boolean) setPdxReadSerialized}
+* method. Once this preference is configured, then any time deserialization of a
+* PDX is done it will deserialize into a PdxInstance.
+* PdxInstance are immutable. If you want to change one call {@link
+* #createWriter}.
+*/
+class CPPCACHE_EXPORT PdxInstance : public PdxSerializable {
+ public:
+  /**
+  * @brief destructor
+  */
+  virtual ~PdxInstance() {}
+
+  /**
+  * Deserializes and returns the domain object that this instance represents.
+  * For deserialization C++ Native Client requires the domain class to be
+  * registered.
+  * @return the deserialized domain object.
+  *
+  * @see Serializable::registerPdxType
+  */
+  virtual PdxSerializablePtr getObject() = 0;
+
+  /**
+  * Checks if the named field exists and returns the result.
+  * This can be useful when writing code that handles more than one version of
+  * a PDX class.
+  * @param fieldname the name of the field to check
+  * @return <code>true</code> if the named field exists; otherwise
+  * <code>false</code>
+  */
+  virtual bool hasField(const char* fieldname) = 0;
+
+  /**
+  * Reads the named field and set its value in CacheablePtr type out param.
+  * CacheablePtr type is corresponding to java object type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with CacheablePtr type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  * For deserialization C++ Native Client requires the domain class to be
+  * registered.
+  *
+  * @see Serializable::registerPdxType
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, CacheablePtr& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in bool type out param.
+  * bool type is corresponding to java boolean type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with bool type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, bool& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in signed char type out param.
+  * signed char type is corresponding to java byte type.
+  * For C++ on Windows and Linux, signed char type is corresponding to int8_t
+  * type.
+  * However C++ users on Solaris should always use this api after casting int8_t
+  * to signed char.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with signed char type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, signed char& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in unsigned char type out param.
+  * unsigned char type is corresponding to java byte type.
+  * For C++ on Windows and Linux, unsigned char type is corresponding to int8_t
+  * type.
+  * However C++ users on Solaris should always use this api after casting int8_t
+  * to unsigned char.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with unsigned char type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, unsigned char& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in int16_t type out param.
+  * int16_t type is corresponding to java short type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with int16_t type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, int16_t& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in int32_t type out param.
+  * int32_t type is corresponding to java int type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with int32_t type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  */
+  virtual void getField(const char* fieldname, int32_t& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in int64_t type out param.
+  * int64_t type is corresponding to java long type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with int64_t type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, int64_t& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in float type out param.
+  * float type is corresponding to java float type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with float type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, float& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in double type out param.
+  * double type is corresponding to java double type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with double type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, double& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in wchar_t type out param.
+  * wchar_t type is corresponding to java char type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with wchar_t type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldName, wchar_t& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in char type out param.
+  * char type is corresponding to java char type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with char type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldName, char& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in bool array type out param.
+  * bool* type is corresponding to java boolean[] type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with bool array type.
+  * @param length length is set with number of bool elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, bool** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in signed char array type out param.
+  * signed char* type is corresponding to java byte[] type.
+  * For C++ on Windows and Linux, signed char* type is corresponding to int8_t*
+  * type.
+  * However C++ users on Solaris should always use this api after casting
+  * int8_t* to signed char*.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with signed char array type.
+  * @param length length is set with number of signed char elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, signed char** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in unsigned char array type out
+  * param.
+  * unsigned char* type is corresponding to java byte[] type.
+  * For C++ on Windows and Linux, unsigned char* type is corresponding to
+  * int8_t* type.
+  * However C++ users on Solaris should always use this api after casting
+  * int8_t* to unsigned char*.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with unsigned char array type.
+  * @param length length is set with number of unsigned char elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, unsigned char** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in int16_t array type out param.
+  * int16_t* type is corresponding to java short[] type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with int16_t array type.
+  * @param length length is set with number of int16_t elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, int16_t** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in int32_t array type out param.
+  * int32_t* type is corresponding to java int[] type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with int32_t array type.
+  * @param length length is set with number of int32_t elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, int32_t** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in int64_t array type out param.
+  * int64_t* type is corresponding to java long[] type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with int64_t array type.
+  * @param length length is set with number of int64_t elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, int64_t** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in float array type out param.
+  * float* type is corresponding to java float[] type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with float array type.
+  * @param length length is set with number of float elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, float** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in double array type out param.
+  * double* type is corresponding to java double[] type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with double array type.
+  * @param length length is set with number of double elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, double** value,
+                        int32_t& length) const = 0;
+
+  // charArray
+  /**
+  * Reads the named field and set its value in wchar_t array type out param.
+  * wchar_t* type is corresponding to java String type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with wchar_t array type.
+  * @param length length is set with number of wchar_t* elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldName, wchar_t** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in char array type out param.
+  * char* type is corresponding to java String type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with char array type.
+  * @param length length is set with number of char* elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldName, char** value,
+                        int32_t& length) const = 0;
+
+  // String
+  /**
+  * Reads the named field and set its value in wchar_t* type out param.
+  * wchar_t* type is corresponding to java String type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with wchar_t type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, wchar_t** value) const = 0;
+
+  /**
+  * Reads the named field and set its value in char* type out param.
+  * char* type is corresponding to java String type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with char* type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, char** value) const = 0;
+
+  // StringArray
+  /**
+  * Reads the named field and set its value in wchar_t* array type out param.
+  * wchar_t** type is corresponding to java String[] type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with wchar_t* array type.
+  * @param length length is set with number of wchar_t** elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, wchar_t*** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in char* array type out param.
+  * char** type is corresponding to java String[] type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with char* array type.
+  * @param length length is set with number of char** elements.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname, char*** value,
+                        int32_t& length) const = 0;
+
+  /**
+  * Reads the named field and set its value in CacheableDatePtr type out param.
+  * CacheableDatePtr type is corresponding to java Java.util.date type.
+  * @param fieldname name of the field to read
+  * @param value value of the field to be set with CacheableDatePtr type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname,
+                        CacheableDatePtr& value) const = 0;
+
+  /**
+  * Reads the named field and set its value in array of byte arrays type out
+  * param.
+  * int8_t** type is corresponding to java byte[][] type.
+  * @param fieldname name of the field to read.
+  * @param value value of the field to be set with array of byte arrays type.
+  * @param arrayLength arrayLength is set to the number of byte arrays.
+  * @param elementLength elementLength is set to individual byte array lengths.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldName, int8_t*** value,
+                        int32_t& arrayLength,
+                        int32_t*& elementLength) const = 0;
+
+  /**
+  * Reads the named field and set its value in CacheableObjectArrayPtr type out
+  * param.
+  * For deserialization C++ Native Client requires the domain class to be
+  * registered.
+  * CacheableObjectArrayPtr type is corresponding to java Object[] type.
+  * @param fieldname name of the field to read.
+  * @param value value of the field to be set with CacheableObjectArrayPtr type.
+  * @throws IllegalStateException if PdxInstance doesn't has the named field.
+  *
+  * @see Serializable::registerPdxType
+  * @see PdxInstance#hasField
+  */
+  virtual void getField(const char* fieldname,
+                        CacheableObjectArrayPtr& value) const = 0;
+
+  /**
+  * Checks if the named field was {@link PdxWriter#markIdentityField}marked as
+  * an identity field.
+  * Note that if no fields have been marked then all the fields are used as
+  * identity fields even though
+  * this method will return <code>false</code> since none of them have been
+  * <em>marked</em>.
+  * @param fieldname the name of the field to check
+  * @return <code>true</code> if the named field exists and was marked as an
+  * identify field; otherwise <code>false</code>
+  */
+  virtual bool isIdentityField(const char* fieldname) = 0;
+
+  /**
+  * Creates and returns a {@link WritablePdxInstance} whose initial
+  * values are those of this PdxInstance.
+  * This call returns a copy of the current field values so modifications
+  * made to the returned value will not modify this PdxInstance.
+  * @return a {@link WritablePdxInstance}
+  */
+  virtual WritablePdxInstancePtr createWriter() = 0;
+
+  /**
+  * Generates a hashcode based on the identity fields of
+  * this PdxInstance.
+  * <p>If a PdxInstance has marked identity fields using {@link
+  * PdxWriter#markIdentityField}
+  * then only the marked identity fields are its identity fields.
+  * Otherwise all its fields are identity fields.
+  * </p>
+  * For deserialization C++ Native Client requires the domain class to be
+  * registered.
+  * If the field is an array then all array
+  * elements are used for hashcode computation.
+  * Otherwise the raw bytes of its value are used to compute the hash code.
+  * @throws IllegalStateException if the field contains an element that is not
+  * of CacheableKey derived type.
+  *
+  * @see Serializable::registerPdxType
+  */
+  virtual uint32_t hashcode() const = 0;
+
+  /**
+  * Prints out all of the identity fields of this PdxInstance.
+  * <p>If a PdxInstance has marked identity fields using {@link
+  * PdxWriter#markIdentityField}
+  * then only the marked identity fields are its identity fields.
+  * Otherwise all its fields are identity fields</p>.
+  * For deserialization C++ Native Client requires the domain class to be
+  * registered.
+  *
+  * @see Serializable::registerPdxType
+  */
+  virtual CacheableStringPtr toString() const = 0;
+
+  /**
+   * @brief serialize this object. This is an internal method.
+   */
+  virtual void toData(DataOutput& output) const {
+    PdxSerializable::toData(output);
+  }
+
+  /**
+   * @brief deserialize this object, typical implementation should return
+   * the 'this' pointer. This is an internal method.
+   */
+  virtual Serializable* fromData(DataInput& input) {
+    return PdxSerializable::fromData(input);
+  }
+
+  /**
+  * Returns true if the given CacheableKey derived object is equals to this
+  * instance.
+  * <p>If <code>other</code> is not a PdxInstance then it is not equal to this
+  * instance.
+  * NOTE: Even if <code>other</code> is the result of calling {@link
+  * #getObject()} it will not
+  * be equal to this instance</p>.
+  * <p>Otherwise equality of two PdxInstances is determined as follows:
+  * <ol>
+  * <li>The domain class name must be equal for both PdxInstances
+  * <li>Each identity field must be equal.
+  * </ol> </p>
+  * If one of the instances does not have a field that the other one does then
+  * equals will assume it
+  * has the field with a default value.
+  * If a PdxInstance has marked identity fields using {@link
+  * PdxWriter#markIdentityField markIdentityField}
+  * then only the marked identity fields are its identity fields.
+  * Otherwise all its fields are identity fields.
+  * <p>An identity field is equal if all the following are true:
+  * <ol>
+  * <li>The field name is equal.
+  * <li>The field type is equal.
+  * <li>The field value is equal.
+  * </ol> </p>
+  * If an identity field is of type derived from <code>Cacheable</code> then it
+  * is deserialized. For deserialization C++ Native Client requires the domain
+  * class to be registered.
+  * If the deserialized object is an array then all array elements
+  * are used to determine equality.
+  * If an identity field is of type <code>CacheableObjectArray</code> then it is
+  * deserialized and all array elements are used to determine equality.
+  * For all other field types the value does not need to be deserialized.
+  * Instead the serialized raw bytes are compared and used to determine
+  * equality.
+  * @param other the other instance to compare to this.
+  * @return <code>true</code> if this instance is equal to <code>other</code>.
+  * @throws IllegalStateException if the field contains an element that is not
+  * of CacheableKey derived type.
+  *
+  * @see Serializable::registerPdxType
+  */
+  virtual bool operator==(const CacheableKey& other) const = 0;
+
+  /** @return the size of the object in bytes
+   * This is an internal method.
+   * It is used in case of heap LRU property is set.
+   */
+  virtual uint32_t objectSize() const = 0;
+
+  /**
+  * Return an unmodifiable list of the field names on this PdxInstance.
+  * @return an unmodifiable list of the field names on this PdxInstance
+  */
+  virtual CacheableStringArrayPtr getFieldNames() = 0;
+
+  // From PdxSerializable
+  /**
+   * @brief serialize this object in geode PDX format. This is an internal
+   * method.
+   * @param PdxWriter to serialize the PDX object
+   */
+  virtual void toData(PdxWriterPtr output) = 0;
+
+  /**
+  * @brief Deserialize this object. This is an internal method.
+  * @param PdxReader to Deserialize the PDX object
+  */
+  virtual void fromData(PdxReaderPtr input) = 0;
+
+  /**
+  * Return the full name of the class that this pdx instance represents.
+  * @return the name of the class that this pdx instance represents.
+  * @throws IllegalStateException if the PdxInstance typeid is not defined yet,
+  * to get classname
+  * or if PdxType is not defined for PdxInstance.
+  */
+  virtual const char* getClassName() const = 0;
+
+  /**
+* Return the type @see PdxInstance::PdxFieldTypes of the field in the pdx
+* instance.
+* @return the type @see PdxInstance::PdxFieldTypes of the field in the pdx
+* instance.
+* @throws IllegalStateException if the PdxInstance typeid is not defined yet, to
+* get classname
+* or if PdxType is not defined for PdxInstance.
+*/
+  virtual PdxFieldTypes::PdxFieldType getFieldType(
+      const char* fieldname) const = 0;
+
+ protected:
+  /**
+  * @brief constructors
+  */
+  PdxInstance() {}
+
+ private:
+  // never implemented.
+  PdxInstance(const PdxInstance& other);
+  void operator=(const PdxInstance& other);
+};
+}  // namespace client
+}  // namespace geode
+}  // namespace apache
+
+#endif  // GEODE_PDXINSTANCE_H_


Mime
View raw message