http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PdxType.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxType.cpp b/src/cppcache/src/PdxType.cpp index 3fd619a..f5fb711 100644 --- a/src/cppcache/src/PdxType.cpp +++ b/src/cppcache/src/PdxType.cpp @@ -44,7 +44,7 @@ PdxType::~PdxType() { } PdxType::PdxType() : Serializable() { - // m_lockObj = NULLPTR; + // m_lockObj = nullptr; m_className = NULL; m_isLocal = false; m_numberOfVarLenFields = 0; @@ -69,7 +69,7 @@ PdxType::PdxType() : Serializable() { PdxType::PdxType(const char* pdxDomainClassName, bool isLocal) : Serializable() { - // m_lockObj = NULLPTR; + // m_lockObj = nullptr; m_className = Utils::copyString(pdxDomainClassName); m_isLocal = isLocal; m_numberOfVarLenFields = 0; @@ -146,7 +146,7 @@ Serializable* PdxType::fromData(DataInput& input) { bool foundVarLenType = false; for (int i = 0; i < len; i++) { - PdxFieldTypePtr pft(new PdxFieldType()); + auto pft = std::make_shared<PdxFieldType>(); pft->fromData(input); m_pdxFieldTypes->push_back(pft); @@ -190,9 +190,9 @@ void PdxType::addFixedLengthTypeField(const char* fieldName, fieldName); throw IllegalStateException(excpStr); } - PdxFieldTypePtr pfxPtr(new PdxFieldType( + auto pfxPtr = std::make_shared<PdxFieldType>( fieldName, className, typeId, static_cast<int32_t>(m_pdxFieldTypes->size()), - false, size, 0)); + false, size, 0); m_pdxFieldTypes->push_back(pfxPtr); m_fieldNameVsPdxType[fieldName] = pfxPtr; } @@ -217,9 +217,9 @@ void PdxType::addVariableLengthTypeField(const char* fieldName, } m_numberOfVarLenFields++; m_isVarLenFieldAdded = true; - PdxFieldTypePtr pfxPtr(new PdxFieldType( + auto pfxPtr = std::make_shared<PdxFieldType>( fieldName, className, typeId, static_cast<int32_t>(m_pdxFieldTypes->size()), - true, -1, m_varLenFieldIdx)); + true, -1, m_varLenFieldIdx); m_pdxFieldTypes->push_back(pfxPtr); m_fieldNameVsPdxType[fieldName] = pfxPtr; } @@ -239,12 +239,12 @@ void PdxType::initRemoteToLocal() { // -1 = local type don't have this VariableLengthType field // -2 = local type don't have this FixedLengthType field - PdxTypePtr localPdxType = NULLPTR; + PdxTypePtr localPdxType = nullptr; //[TODO - open this up once PdxTypeRegistry is done] localPdxType = PdxTypeRegistry::getLocalPdxType(m_className); m_numberOfFieldsExtra = 0; - if (localPdxType != NULLPTR) { + if (localPdxType != nullptr) { std::vector<PdxFieldTypePtr>* localPdxFields = localPdxType->getPdxFieldTypes(); int32_t fieldIdx = 0; @@ -262,8 +262,8 @@ void PdxType::initRemoteToLocal() { for (std::vector<PdxFieldTypePtr>::iterator localPdxfield = localPdxFields->begin(); localPdxfield != localPdxFields->end(); ++localPdxfield) { - // PdxFieldType* remotePdx = (*(remotePdxField)).ptr(); - // PdxFieldType* localPdx = (*(localPdxfield)).ptr(); + // PdxFieldType* remotePdx = (*(remotePdxField)).get(); + // PdxFieldType* localPdx = (*(localPdxfield)).get(); if ((*localPdxfield)->equals(*remotePdxField)) { found = true; m_remoteToLocalFieldMap[fieldIdx++] = 1; // field there in remote @@ -275,7 +275,7 @@ void PdxType::initRemoteToLocal() { if (!found) { // while writing take this from weakhashmap // local field is not in remote type - // if((*(remotePdxField)).ptr()->IsVariableLengthType()) { + // if((*(remotePdxField)).get()->IsVariableLengthType()) { if ((*remotePdxField)->IsVariableLengthType()) { m_remoteToLocalFieldMap[fieldIdx++] = -1; // local type don't have this fields @@ -300,10 +300,10 @@ void PdxType::initLocalToRemote() { // then mark m_localToRemoteFieldMap with remotePdxField sequenceId // 5. else if local field is not in remote type then -1 - PdxTypePtr localPdxType = NULLPTR; + PdxTypePtr localPdxType = nullptr; localPdxType = PdxTypeRegistry::getLocalPdxType(m_className); - if (localPdxType != NULLPTR) { + if (localPdxType != nullptr) { std::vector<PdxFieldTypePtr>* localPdxFields = localPdxType->getPdxFieldTypes(); @@ -316,8 +316,8 @@ void PdxType::initLocalToRemote() { for (int32_t i = 0; i < localToRemoteFieldMapSize && i < static_cast<int32_t>(m_pdxFieldTypes->size()); i++) { - // PdxFieldType* localPdx = localPdxFields->at(fieldIdx).ptr(); - // PdxFieldType* remotePdx = m_pdxFieldTypes->at(i).ptr(); + // PdxFieldType* localPdx = localPdxFields->at(fieldIdx).get(); + // PdxFieldType* remotePdx = m_pdxFieldTypes->at(i).get(); if (localPdxFields->at(fieldIdx)->equals(m_pdxFieldTypes->at(i))) { // fields are in same order, we can read as it is m_localToRemoteFieldMap[fieldIdx++] = -2; @@ -336,8 +336,8 @@ void PdxType::initLocalToRemote() { remotePdxfield != m_pdxFieldTypes->end(); ++remotePdxfield) // for each(PdxFieldType^ remotePdxfield in m_pdxFieldTypes) { - // PdxFieldType* localPdx = localPdxField.ptr(); - PdxFieldType* remotePdx = (*(remotePdxfield)).ptr(); + // PdxFieldType* localPdx = localPdxField.get(); + PdxFieldType* remotePdx = (*(remotePdxfield)).get(); if (localPdxField->equals(*remotePdxfield)) { found = true; // store pdxfield type position to get the offset quickly @@ -364,7 +364,7 @@ int32_t PdxType::getFieldPosition(const char* fieldName, uint8_t* offsetPosition, int32_t offsetSize, int32_t pdxStreamlen) { PdxFieldTypePtr pft = this->getPdxField(fieldName); - if (pft != NULLPTR) { + if (pft != nullptr) { if (pft->IsVariableLengthType()) { return variableLengthFieldPosition(pft, offsetPosition, offsetSize, pdxStreamlen); @@ -379,7 +379,7 @@ int32_t PdxType::getFieldPosition(const char* fieldName, int32_t PdxType::getFieldPosition(int32_t fieldIdx, uint8_t* offsetPosition, int32_t offsetSize, int32_t pdxStreamlen) { PdxFieldTypePtr pft = m_pdxFieldTypes->at(fieldIdx); - if (pft != NULLPTR) { + if (pft != nullptr) { if (pft->IsVariableLengthType()) { return variableLengthFieldPosition(pft, offsetPosition, offsetSize, pdxStreamlen); @@ -464,20 +464,20 @@ PdxTypePtr PdxType::isContains(PdxTypePtr first, PdxTypePtr second) { bool matched = false; for (; j < static_cast<int>(first->m_pdxFieldTypes->size()); j++) { PdxFieldTypePtr firstPdt = first->m_pdxFieldTypes->at(j); - // PdxFieldType* firstType = firstPdt.ptr(); - // PdxFieldType* secondType = secondPdt.ptr(); + // PdxFieldType* firstType = firstPdt.get(); + // PdxFieldType* secondType = secondPdt.get(); if (firstPdt->equals(secondPdt)) { matched = true; break; } } - if (!matched) return NULLPTR; + if (!matched) return nullptr; } return first; } PdxTypePtr PdxType::clone() { - PdxTypePtr clone(new PdxType(m_className, false)); + auto clone = std::make_shared<PdxType>(m_className, false); clone->m_geodeTypeId = 0; clone->m_numberOfVarLenFields = m_numberOfVarLenFields; @@ -491,25 +491,25 @@ PdxTypePtr PdxType::clone() { PdxTypePtr PdxType::isLocalTypeContains(PdxTypePtr otherType) { if (m_pdxFieldTypes->size() >= otherType->m_pdxFieldTypes->size()) { - return isContains(PdxTypePtr(this), otherType); + return isContains(shared_from_this(), otherType); } - return NULLPTR; + return nullptr; } PdxTypePtr PdxType::isRemoteTypeContains(PdxTypePtr remoteType) { if (m_pdxFieldTypes->size() <= remoteType->m_pdxFieldTypes->size()) { - return isContains(remoteType, PdxTypePtr(this)); + return isContains(remoteType, shared_from_this()); } - return NULLPTR; + return nullptr; } PdxTypePtr PdxType::mergeVersion(PdxTypePtr otherVersion) { // int nTotalFields = otherVersion->m_pdxFieldTypes->size(); - PdxTypePtr contains = NULLPTR; + PdxTypePtr contains = nullptr; - if (isLocalTypeContains(otherVersion) != NULLPTR) return PdxTypePtr(this); + if (isLocalTypeContains(otherVersion) != nullptr) return shared_from_this(); - if (isRemoteTypeContains(otherVersion) != NULLPTR) return otherVersion; + if (isRemoteTypeContains(otherVersion) != nullptr) return otherVersion; // need to create new one, clone of local PdxTypePtr newone = clone(); @@ -529,13 +529,13 @@ PdxTypePtr PdxType::mergeVersion(PdxTypePtr otherVersion) { } } if (!found) { - PdxFieldTypePtr newFt(new PdxFieldType( + auto newFt = std::make_shared< PdxFieldType>( (*it)->getFieldName(), (*it)->getClassName(), (*it)->getTypeId(), static_cast<int32_t>(newone->m_pdxFieldTypes->size()), // sequence id (*it)->IsVariableLengthType(), (*it)->getFixedSize(), ((*it)->IsVariableLengthType() ? varLenFields++ /*it increase after that*/ - : 0))); + : 0)); newone->m_pdxFieldTypes->push_back( newFt); // fieldnameVsPFT will happen after that } @@ -554,7 +554,7 @@ void PdxType::generatePositionMap() { int lastVarLenSeqId = 0; int prevFixedSizeOffsets = 0; // set offsets from back first - PdxFieldTypePtr previousField = NULLPTR; + PdxFieldTypePtr previousField = nullptr; for (int i = static_cast<int>(m_pdxFieldTypes->size()) - 1; i >= 0; i--) { PdxFieldTypePtr tmpft = m_pdxFieldTypes->at(i); @@ -577,7 +577,7 @@ void PdxType::generatePositionMap() { tmpft->setVarLenOffsetIndex(-1); // Pdx header length // relative offset is subtracted from var len offsets tmpft->setRelativeOffset(-tmpft->getFixedSize()); - if (previousField != NULLPTR) { // boundary condition + if (previousField != nullptr) { // boundary condition tmpft->setRelativeOffset(-tmpft->getFixedSize() + previousField->getRelativeOffset()); } @@ -606,9 +606,9 @@ void PdxType::generatePositionMap() { } bool PdxType::Equals(PdxTypePtr otherObj) { - if (otherObj == NULLPTR) return false; + if (otherObj == nullptr) return false; - PdxType* ot = dynamic_cast<PdxType*>(otherObj.ptr()); + PdxType* ot = dynamic_cast<PdxType*>(otherObj.get()); if (ot == NULL) return false;
http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PdxType.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxType.hpp b/src/cppcache/src/PdxType.hpp index 157e01a..cefafa2 100644 --- a/src/cppcache/src/PdxType.hpp +++ b/src/cppcache/src/PdxType.hpp @@ -102,6 +102,10 @@ class PdxType : public Serializable, PdxTypePtr isLocalTypeContains(PdxTypePtr otherType); PdxTypePtr isRemoteTypeContains(PdxTypePtr localType); + PdxTypePtr shared_from_this() { + return std::static_pointer_cast<PdxType>(Serializable::shared_from_this()); + } + public: PdxType(); @@ -172,7 +176,7 @@ class PdxType : public Serializable, if (iter != m_fieldNameVsPdxType.end()) { return (*iter).second; } - return NULLPTR; + return nullptr; } bool isLocal() const { return m_isLocal; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PdxTypeRegistry.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxTypeRegistry.cpp b/src/cppcache/src/PdxTypeRegistry.cpp index d3d1fba..6f34b9f 100644 --- a/src/cppcache/src/PdxTypeRegistry.cpp +++ b/src/cppcache/src/PdxTypeRegistry.cpp @@ -39,9 +39,9 @@ TypeNameVsPdxType* PdxTypeRegistry::localTypeToPdxType = NULL; // *PdxTypeRegistry::preserveData = NULL; PreservedHashMap PdxTypeRegistry::preserveData; -CacheableHashMapPtr PdxTypeRegistry::enumToInt = NULLPTR; +CacheableHashMapPtr PdxTypeRegistry::enumToInt = nullptr; -CacheableHashMapPtr PdxTypeRegistry::intToEnum = NULLPTR; +CacheableHashMapPtr PdxTypeRegistry::intToEnum = nullptr; ACE_RW_Thread_Mutex PdxTypeRegistry::g_readerWriterLock; @@ -94,7 +94,7 @@ int32_t PdxTypeRegistry::getPDXIdForType(const char* type, const char* poolname, // WriteGuard guard(g_readerWriterLock); if (checkIfThere) { PdxTypePtr lpdx = getLocalPdxType(type); - if (lpdx != NULLPTR) { + if (lpdx != nullptr) { int id = lpdx->getTypeId(); if (id != 0) { return id; @@ -147,9 +147,9 @@ void PdxTypeRegistry::clear() { if (localTypeToPdxType != NULL) localTypeToPdxType->clear(); - if (intToEnum != NULLPTR) intToEnum->clear(); + if (intToEnum != nullptr) intToEnum->clear(); - if (enumToInt != NULLPTR) enumToInt->clear(); + if (enumToInt != nullptr) enumToInt->clear(); if (pdxTypeToTypeIdMap != NULL) pdxTypeToTypeIdMap->clear(); } @@ -167,14 +167,14 @@ void PdxTypeRegistry::addPdxType(int32_t typeId, PdxTypePtr pdxType) { PdxTypePtr PdxTypeRegistry::getPdxType(int32_t typeId) { ReadGuard guard(g_readerWriterLock); - PdxTypePtr retValue = NULLPTR; + PdxTypePtr retValue = nullptr; TypeIdVsPdxType::iterator iter; iter = typeIdToPdxType->find(typeId); if (iter != typeIdToPdxType->end()) { retValue = (*iter).second; return retValue; } - return NULLPTR; + return nullptr; } void PdxTypeRegistry::addLocalPdxType(const char* localType, @@ -186,14 +186,14 @@ void PdxTypeRegistry::addLocalPdxType(const char* localType, PdxTypePtr PdxTypeRegistry::getLocalPdxType(const char* localType) { ReadGuard guard(g_readerWriterLock); - PdxTypePtr localTypePtr = NULLPTR; + PdxTypePtr localTypePtr = nullptr; TypeNameVsPdxType::iterator it; it = localTypeToPdxType->find(localType); if (it != localTypeToPdxType->end()) { localTypePtr = (*it).second; return localTypePtr; } - return NULLPTR; + return nullptr; } void PdxTypeRegistry::setMergedType(int32_t remoteTypeId, PdxTypePtr mergedType) { @@ -203,7 +203,7 @@ void PdxTypeRegistry::setMergedType(int32_t remoteTypeId, PdxTypePtr mergedType) } PdxTypePtr PdxTypeRegistry::getMergedType(int32_t remoteTypeId) { - PdxTypePtr retVal = NULLPTR; + PdxTypePtr retVal = nullptr; TypeIdVsPdxType::iterator it; it = remoteTypeIdToMergedPdxType->find(remoteTypeId); if (it != remoteTypeIdToMergedPdxType->end()) { @@ -251,20 +251,21 @@ PdxRemotePreservedDataPtr PdxTypeRegistry::getPreserveData( PdxRemotePreservedDataPtr retValPtr = iter.second(); return retValPtr; } - return NULLPTR; + return nullptr; } int32_t PdxTypeRegistry::getEnumValue(EnumInfoPtr ei) { + // TODO locking - naive concurrent optimization? CacheableHashMapPtr tmp; tmp = enumToInt; if (tmp->contains(ei)) { - CacheableInt32Ptr val = tmp->operator[](ei); + auto val = std::static_pointer_cast<CacheableInt32>(tmp->operator[](ei)); return val->value(); } WriteGuard guard(g_readerWriterLock); tmp = enumToInt; if (tmp->contains(ei)) { - CacheableInt32Ptr val = tmp->operator[](ei); + auto val = std::static_pointer_cast<CacheableInt32>(tmp->operator[](ei)); return val->value(); } int val = SerializationRegistry::GetEnumValue(ei); @@ -275,30 +276,33 @@ int32_t PdxTypeRegistry::getEnumValue(EnumInfoPtr ei) { } EnumInfoPtr PdxTypeRegistry::getEnum(int32_t enumVal) { + // TODO locking - naive concurrent optimization? EnumInfoPtr ret; CacheableHashMapPtr tmp; + auto enumValPtr = CacheableInt32::create(enumVal); tmp = intToEnum; - if (tmp->contains(CacheableInt32::create(enumVal))) { - ret = tmp->operator[](CacheableInt32::create(enumVal)); + if (tmp->contains(enumValPtr)) { + ret = std::static_pointer_cast<EnumInfo>(tmp->operator[](enumValPtr)); } - if (ret != NULLPTR) { + if (ret != nullptr) { return ret; } WriteGuard guard(g_readerWriterLock); tmp = intToEnum; - if (tmp->contains(CacheableInt32::create(enumVal))) { - ret = tmp->operator[](CacheableInt32::create(enumVal)); + if (tmp->contains(enumValPtr)) { + ret = std::static_pointer_cast<EnumInfo>(tmp->operator[](enumValPtr)); } - if (ret != NULLPTR) { + if (ret != nullptr) { return ret; } - ret = SerializationRegistry::GetEnum(enumVal); + ret = std::static_pointer_cast<EnumInfo>( + SerializationRegistry::GetEnum(enumVal)); tmp = intToEnum; - tmp->update(CacheableInt32::create(enumVal), ret); + tmp->update(enumValPtr, ret); intToEnum = tmp; return ret; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PdxWrapper.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxWrapper.cpp b/src/cppcache/src/PdxWrapper.cpp index 6943567..815ac7d 100644 --- a/src/cppcache/src/PdxWrapper.cpp +++ b/src/cppcache/src/PdxWrapper.cpp @@ -43,7 +43,7 @@ PdxWrapper::PdxWrapper(void *userObject, const char *className) { m_serializer = SerializationRegistry::getPdxSerializer(); - if (m_serializer == NULLPTR) { + if (m_serializer == nullptr) { LOGERROR("No registered PDX serializer found for PdxWrapper"); throw IllegalArgumentException( "No registered PDX serializer found for PdxWrapper"); @@ -75,7 +75,7 @@ PdxWrapper::PdxWrapper(const char *className) { m_serializer = SerializationRegistry::getPdxSerializer(); - if (m_serializer == NULLPTR) { + if (m_serializer == nullptr) { LOGERROR( "No registered PDX serializer found for PdxWrapper deserialization"); throw IllegalArgumentException( http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PdxWriterWithTypeCollector.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxWriterWithTypeCollector.cpp b/src/cppcache/src/PdxWriterWithTypeCollector.cpp index 0b394e1..ab01cb2 100644 --- a/src/cppcache/src/PdxWriterWithTypeCollector.cpp +++ b/src/cppcache/src/PdxWriterWithTypeCollector.cpp @@ -41,7 +41,7 @@ PdxWriterWithTypeCollector::PdxWriterWithTypeCollector( } void PdxWriterWithTypeCollector::initialize() { - m_pdxType = new PdxType(m_domainClassName, true); + m_pdxType = std::make_shared<PdxType>(m_domainClassName, true); } PdxWriterWithTypeCollector::~PdxWriterWithTypeCollector() {} @@ -99,7 +99,7 @@ bool PdxWriterWithTypeCollector::isFieldWritingStarted() { PdxWriterPtr PdxWriterWithTypeCollector::writeUnreadFields( PdxUnreadFieldsPtr unread) { PdxLocalWriter::writeUnreadFields(unread); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeChar(const char* fieldName, @@ -107,7 +107,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeChar(const char* fieldName, m_pdxType->addFixedLengthTypeField(fieldName, "char", PdxFieldTypes::CHAR, PdxTypes::CHAR_SIZE); PdxLocalWriter::writeChar(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeWideChar(const char* fieldName, @@ -115,7 +115,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeWideChar(const char* fieldName, m_pdxType->addFixedLengthTypeField(fieldName, "char", PdxFieldTypes::CHAR, PdxTypes::CHAR_SIZE); PdxLocalWriter::writeWideChar(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeBoolean(const char* fieldName, @@ -123,7 +123,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeBoolean(const char* fieldName, m_pdxType->addFixedLengthTypeField( fieldName, "boolean", PdxFieldTypes::BOOLEAN, PdxTypes::BOOLEAN_SIZE); PdxLocalWriter::writeBoolean(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeByte(const char* fieldName, @@ -131,7 +131,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeByte(const char* fieldName, m_pdxType->addFixedLengthTypeField(fieldName, "byte", PdxFieldTypes::BYTE, PdxTypes::BYTE_SIZE); PdxLocalWriter::writeByte(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeShort(const char* fieldName, @@ -139,7 +139,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeShort(const char* fieldName, m_pdxType->addFixedLengthTypeField(fieldName, "short", PdxFieldTypes::SHORT, PdxTypes::SHORT_SIZE); PdxLocalWriter::writeShort(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeInt(const char* fieldName, @@ -147,7 +147,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeInt(const char* fieldName, m_pdxType->addFixedLengthTypeField(fieldName, "int", PdxFieldTypes::INT, PdxTypes::INTEGER_SIZE); PdxLocalWriter::writeInt(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeLong(const char* fieldName, @@ -155,7 +155,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeLong(const char* fieldName, m_pdxType->addFixedLengthTypeField(fieldName, "long", PdxFieldTypes::LONG, PdxTypes::LONG_SIZE); PdxLocalWriter::writeLong(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeFloat(const char* fieldName, @@ -163,7 +163,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeFloat(const char* fieldName, m_pdxType->addFixedLengthTypeField(fieldName, "float", PdxFieldTypes::FLOAT, PdxTypes::FLOAT_SIZE); PdxLocalWriter::writeFloat(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeDouble(const char* fieldName, @@ -171,7 +171,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeDouble(const char* fieldName, m_pdxType->addFixedLengthTypeField(fieldName, "double", PdxFieldTypes::DOUBLE, PdxTypes::DOUBLE_SIZE); PdxLocalWriter::writeDouble(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeDate(const char* fieldName, @@ -179,7 +179,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeDate(const char* fieldName, m_pdxType->addFixedLengthTypeField(fieldName, "Date", PdxFieldTypes::DATE, PdxTypes::DATE_SIZE); PdxLocalWriter::writeDate(fieldName, date); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeString(const char* fieldName, @@ -187,7 +187,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeString(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "String", PdxFieldTypes::STRING); PdxLocalWriter::writeString(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeWideString(const char* fieldName, @@ -195,7 +195,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeWideString(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "String", PdxFieldTypes::STRING); PdxLocalWriter::writeWideString(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeObject(const char* fieldName, @@ -203,7 +203,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeObject(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "Serializable", PdxFieldTypes::OBJECT); PdxLocalWriter::writeObject(fieldName, value); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeBooleanArray( @@ -211,7 +211,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeBooleanArray( m_pdxType->addVariableLengthTypeField(fieldName, "bool[]", PdxFieldTypes::BOOLEAN_ARRAY); PdxLocalWriter::writeBooleanArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeCharArray(const char* fieldName, @@ -220,7 +220,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeCharArray(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "char[]", PdxFieldTypes::CHAR_ARRAY); PdxLocalWriter::writeCharArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeWideCharArray( @@ -228,7 +228,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeWideCharArray( m_pdxType->addVariableLengthTypeField(fieldName, "char[]", PdxFieldTypes::CHAR_ARRAY); PdxLocalWriter::writeWideCharArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeByteArray(const char* fieldName, @@ -237,7 +237,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeByteArray(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "byte[]", PdxFieldTypes::BYTE_ARRAY); PdxLocalWriter::writeByteArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeShortArray(const char* fieldName, @@ -246,7 +246,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeShortArray(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "short[]", PdxFieldTypes::SHORT_ARRAY); PdxLocalWriter::writeShortArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeIntArray(const char* fieldName, @@ -255,7 +255,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeIntArray(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "int[]", PdxFieldTypes::INT_ARRAY); PdxLocalWriter::writeIntArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeLongArray(const char* fieldName, @@ -264,7 +264,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeLongArray(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "long[]", PdxFieldTypes::LONG_ARRAY); PdxLocalWriter::writeLongArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeFloatArray(const char* fieldName, @@ -273,7 +273,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeFloatArray(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "float[]", PdxFieldTypes::FLOAT_ARRAY); PdxLocalWriter::writeFloatArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeDoubleArray(const char* fieldName, @@ -282,7 +282,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeDoubleArray(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "double[]", PdxFieldTypes::DOUBLE_ARRAY); PdxLocalWriter::writeDoubleArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeStringArray(const char* fieldName, @@ -291,7 +291,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeStringArray(const char* fieldName, m_pdxType->addVariableLengthTypeField(fieldName, "String[]", PdxFieldTypes::STRING_ARRAY); PdxLocalWriter::writeStringArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeWideStringArray( @@ -299,7 +299,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeWideStringArray( m_pdxType->addVariableLengthTypeField(fieldName, "String[]", PdxFieldTypes::STRING_ARRAY); PdxLocalWriter::writeWideStringArray(fieldName, array, length); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeObjectArray( @@ -307,7 +307,7 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeObjectArray( m_pdxType->addVariableLengthTypeField(fieldName, "Object[]", PdxFieldTypes::OBJECT_ARRAY); PdxLocalWriter::writeObjectArray(fieldName, array); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::writeArrayOfByteArrays( @@ -317,19 +317,19 @@ PdxWriterPtr PdxWriterWithTypeCollector::writeArrayOfByteArrays( PdxFieldTypes::ARRAY_OF_BYTE_ARRAYS); PdxLocalWriter::writeArrayOfByteArrays(fieldName, byteArrays, arrayLength, elementLength); - return PdxWriterPtr(this); + return shared_from_this(); } PdxWriterPtr PdxWriterWithTypeCollector::markIdentityField( const char* fieldName) { PdxFieldTypePtr pft = m_pdxType->getPdxField(fieldName); - if (pft == NULLPTR) { + if (pft == nullptr) { throw IllegalStateException( "Field, must be written to PdxWriter before calling " "MarkIdentityField "); } pft->setIdentityField(true); - return PdxWriterPtr(this); + return shared_from_this(); } } // namespace client } // namespace geode http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/Pool.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/Pool.cpp b/src/cppcache/src/Pool.cpp index 54ad10a..be14fb0 100644 --- a/src/cppcache/src/Pool.cpp +++ b/src/cppcache/src/Pool.cpp @@ -73,7 +73,7 @@ RegionServicePtr Pool::createSecureUserCache(PropertiesPtr credentials) { if (this->getMultiuserAuthentication()) { CachePtr realCache = CacheFactory::getAnyInstance(); - if (!(realCache != NULLPTR && realCache->m_cacheImpl != NULL)) { + if (!(realCache != nullptr && realCache->m_cacheImpl != NULL)) { throw IllegalStateException("cache has not been created yet."); ; } @@ -82,21 +82,19 @@ RegionServicePtr Pool::createSecureUserCache(PropertiesPtr credentials) { throw IllegalStateException("cache has been closed. "); } - if (credentials != NULLPTR && credentials.ptr() == NULL) { + if (credentials != nullptr && credentials.get() == NULL) { LOGDEBUG("Pool::createSecureUserCache creds are null"); - credentials = NULLPTR; + credentials = nullptr; } - PoolPtr tmpPool(this); // TODO: this will return cache with userattribtes - ProxyCachePtr userCache(new ProxyCache(credentials, tmpPool)); - return userCache; + return std::make_shared<ProxyCache>(credentials, shared_from_this()); } throw IllegalStateException( "This operation is only allowed when attached pool is in " "multiuserSecureMode"); - // return NULLPTR; + // return nullptr; } bool Pool::getPRSingleHopEnabled() const { return m_attrs->getPRSingleHopEnabled(); @@ -110,12 +108,12 @@ int Pool::getPendingEventCount() const { throw IllegalStateException( "This operation should only be called by durable client"); } - PoolPtr currPool(this); - ThinClientPoolHADMPtr poolHADM = dynCast<ThinClientPoolHADMPtr>(currPool); - if (poolHADM->isReadyForEvent()) { + const auto poolHADM = dynamic_cast<const ThinClientPoolHADM*>(this); + if (nullptr == poolHADM || poolHADM->isReadyForEvent()) { LOGERROR("This operation should only be called before readyForEvents."); throw IllegalStateException( "This operation should only be called before readyForEvents"); } + return poolHADM->getPrimaryServerQueueSize(); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PoolAttributes.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PoolAttributes.cpp b/src/cppcache/src/PoolAttributes.cpp index 97834b3..80d5879 100644 --- a/src/cppcache/src/PoolAttributes.cpp +++ b/src/cppcache/src/PoolAttributes.cpp @@ -44,8 +44,7 @@ PoolAttributes::PoolAttributes() m_serverGrp(PoolFactory::DEFAULT_SERVER_GROUP) {} PoolAttributesPtr PoolAttributes::clone() { - PoolAttributesPtr ptr(new PoolAttributes(*this)); - return ptr; + return std::make_shared<PoolAttributes>(*this); } /** Return true if all the attributes are equal to those of other. */ http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PoolFactory.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PoolFactory.cpp b/src/cppcache/src/PoolFactory.cpp index 5bc5861..36bde60 100644 --- a/src/cppcache/src/PoolFactory.cpp +++ b/src/cppcache/src/PoolFactory.cpp @@ -116,7 +116,7 @@ PoolPtr PoolFactory::create(const char* name) { { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(connectionPoolsLock); - if (PoolManager::find(name) != NULLPTR) { + if (PoolManager::find(name) != nullptr) { throw IllegalStateException("Pool with the same name already exists"); } // Create a clone of Attr; @@ -155,23 +155,25 @@ PoolPtr PoolFactory::create(const char* name) { if (copyAttrs ->getThreadLocalConnectionSetting() /*&& !copyAttrs->getPRSingleHopEnabled()*/) { // TODO: what should we do for sticky connections - poolDM = new ThinClientPoolStickyDM(name, copyAttrs, tccm); + poolDM = + std::make_shared<ThinClientPoolStickyDM>(name, copyAttrs, tccm); } else { LOGDEBUG("ThinClientPoolDM created "); - poolDM = new ThinClientPoolDM(name, copyAttrs, tccm); + poolDM = std::make_shared<ThinClientPoolDM>(name, copyAttrs, tccm); } } else { LOGDEBUG("ThinClientPoolHADM created "); if (copyAttrs ->getThreadLocalConnectionSetting() /*&& !copyAttrs->getPRSingleHopEnabled()*/) { - poolDM = new ThinClientPoolStickyHADM(name, copyAttrs, tccm); + poolDM = + std::make_shared<ThinClientPoolStickyHADM>(name, copyAttrs, tccm); } else { - poolDM = new ThinClientPoolHADM(name, copyAttrs, tccm); + poolDM = std::make_shared<ThinClientPoolHADM>(name, copyAttrs, tccm); } } connectionPools->insert(CacheableString::create(name), - staticCast<PoolPtr>(poolDM)); + std::static_pointer_cast<GF_UNWRAP_SP(PoolPtr)>(poolDM)); } // TODO: poolDM->init() should not throw exceptions! @@ -180,7 +182,7 @@ PoolPtr PoolFactory::create(const char* name) { poolDM->init(); } - return staticCast<PoolPtr>(poolDM); + return std::static_pointer_cast<GF_UNWRAP_SP(PoolPtr)>(poolDM); } void PoolFactory::addCheck(const char* host, int port) { http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PoolManager.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PoolManager.cpp b/src/cppcache/src/PoolManager.cpp index 9470d60..acad2d8 100644 --- a/src/cppcache/src/PoolManager.cpp +++ b/src/cppcache/src/PoolManager.cpp @@ -50,8 +50,7 @@ void PoolManager::close(bool keepAlive) { for (HashMapOfPools::Iterator iter = connectionPools->begin(); iter != connectionPools->end(); ++iter) { - PoolPtr currPool(iter.second()); - poolsList.push_back(currPool); + poolsList.push_back(iter.second()); } for (std::vector<PoolPtr>::iterator iter = poolsList.begin(); @@ -73,16 +72,16 @@ PoolPtr PoolManager::find(const char* name) { HashMapOfPools::Iterator iter = connectionPools->find(CacheableString::create(name)); - PoolPtr poolPtr = NULLPTR; + PoolPtr poolPtr = nullptr; if (iter != connectionPools->end()) { poolPtr = iter.second(); - GF_DEV_ASSERT(poolPtr != NULLPTR); + GF_DEV_ASSERT(poolPtr != nullptr); } return poolPtr; } else { - return NULLPTR; + return nullptr; } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/Properties.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/Properties.cpp b/src/cppcache/src/Properties.cpp index 9a28725..a381653 100644 --- a/src/cppcache/src/Properties.cpp +++ b/src/cppcache/src/Properties.cpp @@ -42,7 +42,7 @@ class ACE_Equal_To<apache::geode::client::CacheableKeyPtr> { public: int operator()(const apache::geode::client::CacheableKeyPtr& lhs, const apache::geode::client::CacheableKeyPtr& rhs) const { - return (*lhs.ptr() == *rhs.ptr()); + return (*lhs.get() == *rhs.get()); } }; ACE_END_VERSIONED_NAMESPACE_DECL @@ -95,23 +95,23 @@ CacheableStringPtr Properties::find(const char* key) { CacheablePtr value; int status = MAP->find(keyptr, value); if (status != 0) { - return NULLPTR; + return nullptr; } - if (value == NULLPTR) { - return NULLPTR; + if (value == nullptr) { + return nullptr; } return value->toString(); } CacheablePtr Properties::find(const CacheableKeyPtr& key) { - if (key == NULLPTR) { + if (key == nullptr) { throw NullPointerException("Properties::find: Null key given."); } CacheableKeyCacheableMapGuard guard(MAP->mutex()); CacheablePtr value; int status = MAP->find(key, value); if (status != 0) { - return NULLPTR; + return nullptr; } return value; } @@ -138,7 +138,7 @@ void Properties::insert(const char* key, const int value) { } void Properties::insert(const CacheableKeyPtr& key, const CacheablePtr& value) { - if (key == NULLPTR) { + if (key == nullptr) { throw NullPointerException("Properties::insert: Null key given."); } MAP->rebind(key, value); @@ -153,7 +153,7 @@ void Properties::remove(const char* key) { } void Properties::remove(const CacheableKeyPtr& key) { - if (key == NULLPTR) { + if (key == nullptr) { throw NullPointerException("Properties::remove: Null key given."); } MAP->unbind(key); @@ -175,7 +175,7 @@ void Properties::foreach (Visitor& visitor) const { } void Properties::addAll(const PropertiesPtr& other) { - if (other == NULLPTR) return; + if (other == nullptr) return; class Copier : public Visitor { Properties& m_lhs; @@ -290,14 +290,14 @@ void Properties::toData(DataOutput& output) const { while (iter != MAP->end()) { // changed CacheableString* csPtr = - dynamic_cast<CacheableString*>(((*iter).ext_id_).ptr()); + dynamic_cast<CacheableString*>(((*iter).ext_id_).get()); if (csPtr == NULL) { output.writeObject((*iter).ext_id_); // changed } else { output.writeNativeString(csPtr->asChar()); } - csPtr = dynamic_cast<CacheableString*>(((*iter).int_id_).ptr()); + csPtr = dynamic_cast<CacheableString*>(((*iter).int_id_).get()); if (csPtr == NULL) { output.writeObject((*iter).int_id_); // changed } else { http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/ProxyCache.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ProxyCache.cpp b/src/cppcache/src/ProxyCache.cpp index 0b3b92b..1e9bc54 100644 --- a/src/cppcache/src/ProxyCache.cpp +++ b/src/cppcache/src/ProxyCache.cpp @@ -57,9 +57,9 @@ bool ProxyCache::isClosed() const { return m_isProxyCacheClosed; } void ProxyCache::close() { LOGDEBUG("ProxyCache::close: isProxyCacheClosed = %d", m_isProxyCacheClosed); if (!m_isProxyCacheClosed) { - if (m_remoteQueryService != NULLPTR) { + if (m_remoteQueryService != nullptr) { ProxyRemoteQueryService* prqs = - static_cast<ProxyRemoteQueryService*>(m_remoteQueryService.ptr()); + static_cast<ProxyRemoteQueryService*>(m_remoteQueryService.get()); prqs->closeCqs(false); } @@ -70,8 +70,8 @@ void ProxyCache::close() { // send message to server PoolPtr userAttachedPool = m_userAttributes->getPool(); PoolPtr pool = PoolManager::find(userAttachedPool->getName()); - if (pool != NULLPTR && pool.ptr() == userAttachedPool.ptr()) { - ThinClientPoolDMPtr poolDM(static_cast<ThinClientPoolDM*>(pool.ptr())); + if (pool != nullptr && pool.get() == userAttachedPool.get()) { + auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool); if (!poolDM->isDestroyed()) { poolDM->sendUserCacheCloseMessage(false); } @@ -88,17 +88,16 @@ RegionPtr ProxyCache::getRegion(const char* path) { RegionPtr result; CachePtr realCache = CacheFactory::getAnyInstance(); - if (realCache != NULLPTR && !realCache->isClosed()) { - CacheRegionHelper::getCacheImpl(realCache.ptr())->getRegion(path, result); + if (realCache != nullptr && !realCache->isClosed()) { + CacheRegionHelper::getCacheImpl(realCache.get())->getRegion(path, result); } - if (result != NULLPTR) { + if (result != nullptr) { PoolPtr userAttachedPool = m_userAttributes->getPool(); PoolPtr pool = PoolManager::find(result->getAttributes()->getPoolName()); - if (pool != NULLPTR && pool.ptr() == userAttachedPool.ptr() && + if (pool != nullptr && pool.get() == userAttachedPool.get() && !pool->isDestroyed()) { - ProxyRegionPtr pRegion(new ProxyRegion(this, result)); - return pRegion; + return std::make_shared<ProxyRegion>(shared_from_this(), result); } throw IllegalArgumentException( "The Region argument is not attached with the pool, which used to " @@ -121,8 +120,9 @@ RegionPtr ProxyCache::getRegion(const char* path) { QueryServicePtr ProxyCache::getQueryService() { if (!m_isProxyCacheClosed) { - if (m_remoteQueryService != NULLPTR) return m_remoteQueryService; - QueryServicePtr prqsPtr(new ProxyRemoteQueryService(this)); + if (m_remoteQueryService != nullptr) return m_remoteQueryService; + auto prqsPtr = + std::make_shared<ProxyRemoteQueryService>(this->shared_from_this()); m_remoteQueryService = prqsPtr; return prqsPtr; } @@ -136,7 +136,7 @@ void ProxyCache::rootRegions(VectorOfRegion& regions) { RegionPtr result; CachePtr realCache = CacheFactory::getAnyInstance(); - if (realCache != NULLPTR && !realCache->isClosed()) { + if (realCache != nullptr && !realCache->isClosed()) { VectorOfRegion tmp; // this can cause issue when pool attached with region in multiuserSecure // mode @@ -147,7 +147,8 @@ void ProxyCache::rootRegions(VectorOfRegion& regions) { RegionPtr reg = tmp.at(i); if (strcmp(m_userAttributes->getPool()->getName(), reg->getAttributes()->getPoolName()) == 0) { - ProxyRegionPtr pRegion(new ProxyRegion(this, reg)); + auto pRegion = + std::make_shared<ProxyRegion>(shared_from_this(), reg); regions.push_back(pRegion); } } @@ -157,17 +158,14 @@ void ProxyCache::rootRegions(VectorOfRegion& regions) { } ProxyCache::ProxyCache(PropertiesPtr credentials, PoolPtr pool) { - m_remoteQueryService = NULLPTR; + m_remoteQueryService = nullptr; m_isProxyCacheClosed = false; - UserAttributesPtr userAttr; - userAttr = new UserAttributes(credentials, pool, this); - m_userAttributes = userAttr; + m_userAttributes = std::make_shared<UserAttributes>(credentials, pool, this); } ProxyCache::~ProxyCache() {} PdxInstanceFactoryPtr ProxyCache::createPdxInstanceFactory( const char* className) { - PdxInstanceFactoryPtr pIFPtr(new PdxInstanceFactoryImpl(className)); - return pIFPtr; + return std::make_shared<PdxInstanceFactoryImpl>(className); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/ProxyCache.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ProxyCache.hpp b/src/cppcache/src/ProxyCache.hpp index 043318d..23d085c 100644 --- a/src/cppcache/src/ProxyCache.hpp +++ b/src/cppcache/src/ProxyCache.hpp @@ -52,7 +52,9 @@ class FunctionServiceImpl; * <p>A cache can have multiple root regions, each with a different name. * */ -class CPPCACHE_EXPORT ProxyCache : public RegionService { +class CPPCACHE_EXPORT ProxyCache + : public RegionService, + public std::enable_shared_from_this<ProxyCache> { /** * @brief public methods */ @@ -79,7 +81,7 @@ class CPPCACHE_EXPORT ProxyCache : public RegionService { /** Look up a region with the full path from root. * @param path the region's path, such as <code>RootA/Sub1/Sub1A</code>. - * @returns region, or NULLPTR if no such region exists. + * @returns region, or nullptr if no such region exists. */ virtual RegionPtr getRegion(const char* path); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/ProxyRegion.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ProxyRegion.hpp b/src/cppcache/src/ProxyRegion.hpp index bcb755d..ec7c710 100644 --- a/src/cppcache/src/ProxyRegion.hpp +++ b/src/cppcache/src/ProxyRegion.hpp @@ -68,7 +68,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { return m_realRegion->getFullPath(); } - /** Returns the parent region, or NULLPTR if a root region. + /** Returns the parent region, or nullptr if a root region. * @throws RegionDestroyedException */ virtual RegionPtr getParentRegion() const { @@ -87,7 +87,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { */ virtual AttributesMutatorPtr getAttributesMutator() const { unSupportedOperation("Region.getAttributesMutator()"); - return NULLPTR; + return nullptr; } // virtual void updateAccessOrModifiedTime() = 0; @@ -104,7 +104,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param aCallbackArgument a user-defined parameter to pass to callback events * triggered by this method. - * Can be NULLPTR. If it is sent on the wire, it has to be Serializable. + * Can be nullptr. If it is sent on the wire, it has to be Serializable. * @throws CacheListenerException if CacheListener throws an exception; if this * occurs some subregions may have already been successfully * invalidated @@ -114,7 +114,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * This operation is not distributed. */ virtual void invalidateRegion( - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("Region.invalidateRegion()"); } @@ -128,7 +128,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param aCallbackArgument a user-defined parameter to pass to callback events * triggered by this method. - * Can be NULLPTR. If it is sent on the wire, it has to be Serializable. + * Can be nullptr. If it is sent on the wire, it has to be Serializable. * @throws CacheListenerException if CacheListener throws an exception; if this * occurs some subregions may have already been successfully invalidated @@ -138,7 +138,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { */ virtual void localInvalidateRegion( - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("Region.localInvalidateRegion()"); } @@ -156,7 +156,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param aCallbackArgument a user-defined parameter to pass to callback events * triggered by this call. - * Can be NULLPTR. If it is sent on the wire, it has to be Serializable. + * Can be nullptr. If it is sent on the wire, it has to be Serializable. * @throws CacheWriterException if CacheWriter aborts the operation; if this * occurs some subregions may have already been successfully destroyed. * @throws CacheListenerException if CacheListener throws an exception; if this @@ -176,7 +176,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @throws TimeoutException if operation timed out * @see invalidateRegion */ - virtual void destroyRegion(const UserDataPtr& aCallbackArgument = NULLPTR) { + virtual void destroyRegion(const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); m_realRegion->destroyRegion(aCallbackArgument); } @@ -189,7 +189,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see CacheListener#afterRegionClear * @see CacheWriter#beforeRegionClear */ - virtual void clear(const UserDataPtr& aCallbackArgument = NULLPTR) { + virtual void clear(const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); m_realRegion->clear(aCallbackArgument); } @@ -201,7 +201,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see CacheListener#afterRegionClear * @see CacheWriter#beforeRegionClear */ - virtual void localClear(const UserDataPtr& aCallbackArgument = NULLPTR) { + virtual void localClear(const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("localClear()"); } @@ -215,7 +215,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param aCallbackArgument a user-defined parameter to pass to callback events * triggered by this call. - * Can be NULLPTR. If it is sent on the wire, it has to be Serializable. + * Can be nullptr. If it is sent on the wire, it has to be Serializable. * @throws CacheWriterException if CacheWriter aborts the operation; if this * occurs some subregions may have already been successfully destroyed. * @throws CacheListenerException if CacheListener throws an exception; if this @@ -225,35 +225,34 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see localInvalidateRegion */ virtual void localDestroyRegion( - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("Region.localDestroyRegion()"); } - /** Returns the subregion identified by the path, NULLPTR if no such subregion + /** Returns the subregion identified by the path, nullptr if no such subregion */ virtual RegionPtr getSubregion(const char* path) { LOGDEBUG("ProxyRegion getSubregion"); RegionPtr rPtr = m_realRegion->getSubregion(path); - if (rPtr == NULLPTR) return rPtr; + if (rPtr == nullptr) return rPtr; - RegionPtr prPtr(new ProxyRegion(m_proxyCache.ptr(), rPtr)); - return prPtr; + return std::make_shared<ProxyRegion>(m_proxyCache, rPtr); } /** Creates a subregion with the specified attributes */ virtual RegionPtr createSubregion( const char* subregionName, const RegionAttributesPtr& aRegionAttributes) { unSupportedOperation("createSubregion()"); - return NULLPTR; + return nullptr; /*LOGDEBUG("ProxyRegion getSubregion"); RegionPtr rPtr = m_realRegion->createSubregion(subregionName, aRegionAttributes); - if(rPtr == NULLPTR) + if(rPtr == nullptr) return rPtr; - RegionPtr prPtr( new ProxyRegion(m_proxyCache.ptr(), rPtr)); + auto prPtr = std::make_shared<ProxyRegion>(m_proxyCache.get(), rPtr); return prPtr;*/ } @@ -270,8 +269,8 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { if (realVectorRegion.size() > 0) { for (int32_t i = 0; i < realVectorRegion.size(); i++) { - RegionPtr prPtr( - new ProxyRegion(m_proxyCache.ptr(), realVectorRegion.at(i))); + auto prPtr = + std::make_shared<ProxyRegion>(m_proxyCache, realVectorRegion.at(i)); sr.push_back(prPtr); } } @@ -310,7 +309,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @param aCallbackArgument an argument passed into the CacheLoader if * loader is used. If it is sent on the wire, it has to be Serializable. * - * @throws IllegalArgumentException if key is NULLPTR or aCallbackArgument is + * @throws IllegalArgumentException if key is nullptr or aCallbackArgument is * not serializable and a remote CacheLoader needs to be invoked * @throws CacheLoaderException if CacheLoader throws an exception * @throws CacheServerException If an exception is received from the Java cache @@ -329,7 +328,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { *region **/ virtual CacheablePtr get(const CacheableKeyPtr& key, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); return m_realRegion->get(key, aCallbackArgument); } @@ -337,7 +336,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline CacheablePtr get(const KEYTYPE& key, - const UserDataPtr& callbackArg = NULLPTR) { + const UserDataPtr& callbackArg = nullptr) { return get(createKey(key), callbackArg); } @@ -364,7 +363,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @param value the value to be put into the cache * @param aCallbackArgument an argument that is passed to the callback function * - * @throws IllegalArgumentException if key or value is NULLPTR + * @throws IllegalArgumentException if key or value is nullptr * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception * @throws RegionDestroyedException if region no longer valid @@ -382,7 +381,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @throws OutOfMemoryException if not enoough memory for the value */ virtual void put(const CacheableKeyPtr& key, const CacheablePtr& value, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); return m_realRegion->put(key, value, aCallbackArgument); } @@ -390,21 +389,21 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { /** Convenience method allowing both key and value to be a const char* */ template <class KEYTYPE, class VALUETYPE> inline void put(const KEYTYPE& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { put(createKey(key), createValue(value), arg); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline void put(const KEYTYPE& key, const CacheablePtr& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { put(createKey(key), value, arg); } /** Convenience method allowing value to be a const char* */ template <class VALUETYPE> inline void put(const CacheableKeyPtr& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { put(key, createValue(value), arg); } @@ -424,14 +423,14 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @since 8.1 * @param aCallbackArgument an argument that is passed to the callback * functions. - * It is ignored if NULLPTR. It must be serializable if this operation is + * It is ignored if nullptr. It must be serializable if this operation is * distributed. * @throws IllegalArgumentException If timeout * parameter is greater than 2^31/1000, ie 2147483. */ virtual void putAll(const HashMapOfCacheable& map, uint32_t timeout = DEFAULT_RESPONSE_TIMEOUT, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); return m_realRegion->putAll(map, timeout, aCallbackArgument); } @@ -454,35 +453,35 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @param aCallbackArgument an argument that is passed to the callback * functions * - * @throws IllegalArgumentException if key or value is NULLPTR + * @throws IllegalArgumentException if key or value is nullptr * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception * @throws RegionDestroyedException if region no longer valid * @throws OutOfMemoryException if not enoough memory for the value */ virtual void localPut(const CacheableKeyPtr& key, const CacheablePtr& value, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("Region.localPut()"); } /** Convenience method allowing both key and value to be a const char* */ template <class KEYTYPE, class VALUETYPE> inline void localPut(const KEYTYPE& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { localPut(createKey(key), createValue(value), arg); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline void localPut(const KEYTYPE& key, const CacheablePtr& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { localPut(createKey(key), value, arg); } /** Convenience method allowing value to be a const char* */ template <class VALUETYPE> inline void localPut(const CacheableKeyPtr& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { localPut(key, createValue(value), arg); } @@ -504,12 +503,12 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param key the key smart pointer for which to create the entry in this * region. - * @param value the value for the new entry, which may be NULLPTR meaning + * @param value the value for the new entry, which may be nullptr meaning * the new entry starts as if it had been locally invalidated. * @param aCallbackArgument a user-defined parameter to pass to callback events - * triggered by this method. Can be NULLPTR. Should be serializable if + * triggered by this method. Can be nullptr. Should be serializable if * passed to remote callback events - * @throws IllegalArgumentException if key is NULLPTR or if the key, value, or + * @throws IllegalArgumentException if key is nullptr or if the key, value, or * aCallbackArgument do not meet serializability requirements * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception @@ -530,7 +529,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @throws EntryExistsException if an entry with this key already exists */ virtual void create(const CacheableKeyPtr& key, const CacheablePtr& value, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); m_realRegion->create(key, value, aCallbackArgument); } @@ -538,21 +537,21 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { /** Convenience method allowing both key and value to be a const char* */ template <class KEYTYPE, class VALUETYPE> inline void create(const KEYTYPE& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { create(createKey(key), createValue(value), arg); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline void create(const KEYTYPE& key, const CacheablePtr& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { create(createKey(key), value, arg); } /** Convenience method allowing value to be a const char* */ template <class VALUETYPE> inline void create(const CacheableKeyPtr& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { create(key, createValue(value), arg); } @@ -567,14 +566,14 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param key the key smart pointer for which to create the entry in this * region. - * @param value the value for the new entry, which may be NULLPTR meaning + * @param value the value for the new entry, which may be nullptr meaning * the new entry starts as if it had been locally invalidated. * @param aCallbackArgument a user-defined parameter to pass to callback * events - * triggered by this method. Can be NULLPTR. Should be serializable if + * triggered by this method. Can be nullptr. Should be serializable if * passed to remote callback events * - * @throws IllegalArgumentException if key or value is NULLPTR + * @throws IllegalArgumentException if key or value is nullptr * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception * @throws RegionDestroyedException if region is no longer valid @@ -583,28 +582,28 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { */ virtual void localCreate(const CacheableKeyPtr& key, const CacheablePtr& value, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("Region.localCreate()"); } /** Convenience method allowing both key and value to be a const char* */ template <class KEYTYPE, class VALUETYPE> inline void localCreate(const KEYTYPE& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { localCreate(createKey(key), createValue(value), arg); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline void localCreate(const KEYTYPE& key, const CacheablePtr& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { localCreate(createKey(key), value, arg); } /** Convenience method allowing value to be a const char* */ template <class VALUETYPE> inline void localCreate(const CacheableKeyPtr& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { localCreate(key, createValue(value), arg); } @@ -620,9 +619,9 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param key the key of the value to be invalidated * @param aCallbackArgument a user-defined parameter to pass to callback events - * triggered by this method. Can be NULLPTR. Should be serializable if + * triggered by this method. Can be nullptr. Should be serializable if * passed to remote callback events - * @throws IllegalArgumentException if key is NULLPTR + * @throws IllegalArgumentException if key is nullptr * @throws CacheListenerException if CacheListener throws an exception * @throws EntryNotFoundException if this entry does not exist in this region * locally @@ -631,14 +630,14 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see CacheListener::afterInvalidate */ virtual void invalidate(const CacheableKeyPtr& key, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); m_realRegion->invalidate(key, aCallbackArgument); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> - inline void invalidate(const KEYTYPE& key, const UserDataPtr& arg = NULLPTR) { + inline void invalidate(const KEYTYPE& key, const UserDataPtr& arg = nullptr) { invalidate(createKey(key), arg); } @@ -652,9 +651,9 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param key the key of the value to be invalidated * @param aCallbackArgument a user-defined parameter to pass to callback events - * triggered by this method. Can be NULLPTR. Should be serializable if + * triggered by this method. Can be nullptr. Should be serializable if * passed to remote callback events - * @throws IllegalArgumentException if key is NULLPTR + * @throws IllegalArgumentException if key is nullptr * @throws CacheListenerException if CacheListener throws an exception * @throws EntryNotFoundException if this entry does not exist in this region * locally @@ -663,14 +662,14 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see CacheListener::afterInvalidate */ virtual void localInvalidate(const CacheableKeyPtr& key, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("Region.localInvalidate()"); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline void localInvalidate(const KEYTYPE& key, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { localInvalidate(createKey(key), arg); } @@ -693,8 +692,8 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @param key the key of the entry to destroy * @param aCallbackArgument a user-defined parameter to pass to callback events * triggered by this method. - * Can be NULLPTR. If it is sent on the wire, it has to be Serializable. - * @throws IllegalArgumentException if key is NULLPTR + * Can be nullptr. If it is sent on the wire, it has to be Serializable. + * @throws IllegalArgumentException if key is nullptr * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception * @throws CacheServerException If an exception is received from the Geode @@ -717,14 +716,14 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see CacheWriter::beforeDestroy */ virtual void destroy(const CacheableKeyPtr& key, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); m_realRegion->destroy(key, aCallbackArgument); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> - inline void destroy(const KEYTYPE& key, const UserDataPtr& arg = NULLPTR) { + inline void destroy(const KEYTYPE& key, const UserDataPtr& arg = nullptr) { destroy(createKey(key), arg); } @@ -742,8 +741,8 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param key the key of the entry to destroy. * @param aCallbackArgument the callback for user to pass in, default is - * NULLPTR. - * @throws IllegalArgumentException if key is NULLPTR + * nullptr. + * @throws IllegalArgumentException if key is nullptr * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception * @throws EntryNotFoundException if the entry does not exist in this region @@ -753,14 +752,14 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see CacheWriter::beforeDestroy */ virtual void localDestroy(const CacheableKeyPtr& key, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("Region.localDestroy()"); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline void localDestroy(const KEYTYPE& key, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { localDestroy(createKey(key), arg); } @@ -783,11 +782,11 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * <p> * * @param key the key of the entry to remove - * @param value the value of the key to remove, it can be NULLPTR. + * @param value the value of the key to remove, it can be nullptr. * @param aCallbackArgument a user-defined parameter to pass to callback events * triggered by this method. - * Can be NULLPTR. If it is sent on the wire, it has to be Serializable. - * @throws IllegalArgumentException if key is NULLPTR + * Can be nullptr. If it is sent on the wire, it has to be Serializable. + * @throws IllegalArgumentException if key is nullptr * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception * @throws CacheServerException If an exception is received from the Geode @@ -813,7 +812,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see CacheWriter::beforeDestroy */ virtual bool remove(const CacheableKeyPtr& key, const CacheablePtr& value, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); return m_realRegion->remove(key, value, aCallbackArgument); } @@ -821,21 +820,21 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { /** Convenience method allowing both key and value to be a const char* */ template <class KEYTYPE, class VALUETYPE> inline bool remove(const KEYTYPE& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { return remove(createKey(key), createValue(value), arg); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline bool remove(const KEYTYPE& key, const CacheablePtr& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { return remove(createKey(key), value, arg); } /** Convenience method allowing value to be a const char* */ template <class VALUETYPE> inline bool remove(const CacheableKeyPtr& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { return remove(key, createValue(value), arg); } @@ -859,8 +858,8 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @param key the key of the entry to remove * @param aCallbackArgument a user-defined parameter to pass to callback events * triggered by this method. - * Can be NULLPTR. If it is sent on the wire, it has to be Serializable. - * @throws IllegalArgumentException if key is NULLPTR + * Can be nullptr. If it is sent on the wire, it has to be Serializable. + * @throws IllegalArgumentException if key is nullptr * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception * @throws CacheServerException If an exception is received from the Geode @@ -887,14 +886,14 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { */ virtual bool removeEx(const CacheableKeyPtr& key, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); return m_realRegion->removeEx(key, aCallbackArgument); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> - inline bool removeEx(const KEYTYPE& key, const UserDataPtr& arg = NULLPTR) { + inline bool removeEx(const KEYTYPE& key, const UserDataPtr& arg = nullptr) { return removeEx(createKey(key), arg); } @@ -915,8 +914,8 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @param key the key of the entry to remove. * @param value the value of the entry to remove. * @param aCallbackArgument the callback for user to pass in, default is - * NULLPTR. - * @throws IllegalArgumentException if key is NULLPTR + * nullptr. + * @throws IllegalArgumentException if key is nullptr * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception * @return the boolean true if an entry(key, value)has been removed or @@ -927,7 +926,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { */ virtual bool localRemove(const CacheableKeyPtr& key, const CacheablePtr& value, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("Region.localRemove()"); return false; } @@ -935,21 +934,21 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { /** Convenience method allowing both key and value to be a const char* */ template <class KEYTYPE, class VALUETYPE> inline bool localRemove(const KEYTYPE& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { return localRemove(createKey(key), createValue(value), arg); } /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline bool localRemove(const KEYTYPE& key, const CacheablePtr& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { return localRemove(createKey(key), value, arg); } /** Convenience method allowing value to be a const char* */ template <class VALUETYPE> inline bool localRemove(const CacheableKeyPtr& key, const VALUETYPE& value, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { return localRemove(key, createValue(value), arg); } @@ -968,8 +967,8 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param key the key of the entry to remove. * @param aCallbackArgument the callback for user to pass in, default is - * NULLPTR. - * @throws IllegalArgumentException if key is NULLPTR + * nullptr. + * @throws IllegalArgumentException if key is nullptr * @throws CacheWriterException if CacheWriter aborts the operation * @throws CacheListenerException if CacheListener throws an exception * @return the boolean true if an entry(key, value)has been removed or @@ -979,7 +978,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see CacheWriter::beforeDestroy */ virtual bool localRemoveEx(const CacheableKeyPtr& key, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { unSupportedOperation("Region.localRemoveEx()"); return false; } @@ -987,7 +986,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { /** Convenience method allowing key to be a const char* */ template <class KEYTYPE> inline bool localRemoveEx(const KEYTYPE& key, - const UserDataPtr& arg = NULLPTR) { + const UserDataPtr& arg = nullptr) { return localRemoveEx(createKey(key), arg); } @@ -1186,7 +1185,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * ( {@link AttributesFactory::setClientNotification} ) is true. * * @param isDurable flag to indicate whether this is a durable registration - * @param resultKeys If non-NULLPTR then all the keys on the server that got + * @param resultKeys If non-nullptr then all the keys on the server that got * registered are returned. The vector is cleared at the start to discard * any existing keys in the vector. * @param getInitialValues true to populate the cache with values of all keys @@ -1213,7 +1212,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @throws TimeoutException if operation timed out */ virtual void registerAllKeys(bool isDurable = false, - VectorOfCacheableKeyPtr resultKeys = NULLPTR, + VectorOfCacheableKeyPtr resultKeys = nullptr, bool getInitialValues = false, bool receiveValues = true) { unSupportedOperation("Region.registerAllKeys()"); @@ -1250,7 +1249,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param regex The regular expression string. * @param isDurable flag to indicate whether this is a durable registration - * @param resultKeys If non-NULLPTR then the keys that match the regular + * @param resultKeys If non-nullptr then the keys that match the regular * expression on the server are returned. The vector is cleared at the * start to discard any existing keys in the vector. * @param getInitialValues true to populate the cache with values of the keys @@ -1283,7 +1282,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @throws TimeoutException if operation timed out */ virtual void registerRegex(const char* regex, bool isDurable = false, - VectorOfCacheableKeyPtr resultKeys = NULLPTR, + VectorOfCacheableKeyPtr resultKeys = nullptr, bool getInitialValues = false, bool receiveValues = true) { unSupportedOperation("Region.registerRegex()"); @@ -1331,21 +1330,21 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * * @param keys the array of keys * @param values Output parameter that provides the map of keys to - * respective values. It is ignored if NULLPTR, and when NULLPTR then at + * respective values. It is ignored if nullptr, and when nullptr then at *least * the <code>addToLocalCache</code> parameter should be true and caching * should be enabled for the region to get values into the region * otherwise an <code>IllegalArgumentException</code> is thrown. * @param exceptions Output parameter that provides the map of keys - * to any exceptions while obtaining the key. It is ignored if NULLPTR. + * to any exceptions while obtaining the key. It is ignored if nullptr. * @param addToLocalCache true if the obtained values have also to be added * to the local cache * @since 8.1 * @param aCallbackArgument an argument that is passed to the callback *functions. - * It may be NULLPTR. Must be serializable if this operation is distributed. + * It may be nullptr. Must be serializable if this operation is distributed. * @throws IllegalArgumentException If the array of keys is empty. Other - * invalid case is when the <code>values</code> parameter is NULLPTR, and + * invalid case is when the <code>values</code> parameter is nullptr, and * either <code>addToLocalCache</code> is false or caching is disabled * for this region. * @throws CacheServerException If an exception is received from the Java @@ -1362,7 +1361,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { HashMapOfCacheablePtr values, HashMapOfExceptionPtr exceptions, bool addToLocalCache = false, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); m_realRegion->getAll(keys, values, exceptions, false /*TODO:*/, aCallbackArgument); @@ -1446,7 +1445,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @throws TimeoutException if operation timed out * @throws CacheClosedException if the cache has been closed * @returns A smart pointer to the single ResultSet or StructSet item, or - * NULLPTR of no results are available. + * nullptr of no results are available. */ virtual SerializablePtr selectValue( const char* predicate, @@ -1468,7 +1467,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @param keys the keys to remove from this region. * @param aCallbackArgument an argument that is passed to the callback * functions. - * It is ignored if NULLPTR. It must be serializable if this operation is + * It is ignored if nullptr. It must be serializable if this operation is * distributed. * @throws IllegalArgumentException If the array of keys is empty. * @throws CacheServerException If an exception is received from the Java @@ -1484,7 +1483,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { * @see destroy */ virtual void removeAll(const VectorOfCacheableKey& keys, - const UserDataPtr& aCallbackArgument = NULLPTR) { + const UserDataPtr& aCallbackArgument = nullptr) { GuardUserAttribures gua(m_proxyCache); m_realRegion->removeAll(keys, aCallbackArgument); } @@ -1497,9 +1496,8 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { virtual const PoolPtr& getPool() { return m_realRegion->getPool(); } - ProxyRegion(ProxyCache* proxyCache, RegionPtr realRegion) { - ProxyCachePtr pcp(proxyCache); - m_proxyCache = pcp; + ProxyRegion(const ProxyCachePtr& proxyCache, const RegionPtr& realRegion) { + m_proxyCache = proxyCache; m_realRegion = realRegion; } @@ -1514,6 +1512,8 @@ class CPPCACHE_EXPORT ProxyRegion : public Region { ProxyRegion(const ProxyRegion&); ProxyRegion& operator=(const ProxyRegion&); friend class FunctionService; + + FRIEND_STD_SHARED_PTR(ProxyRegion) }; typedef SharedPtr<ProxyRegion> ProxyRegionPtr;