[ 
https://issues.apache.org/jira/browse/GEODE-10096?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17501610#comment-17501610
 ] 

ASF GitHub Bot commented on GEODE-10096:
----------------------------------------

pivotal-jbarrett commented on a change in pull request #938:
URL: https://github.com/apache/geode-native/pull/938#discussion_r820003010



##########
File path: cppcache/src/util/to_underlying.hpp
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#ifndef UTIL_UNDERLYING_TYPE_HPP
+#define UTIL_UNDERLYING_TYPE_HPP
+
+#include <type_traits>
+
+/* Note: this implementation can be thrown away once we upgrade to C++14. */
+
+template< class T >
+using underlying_type_t = typename std::underlying_type<T>::type;
+
+/* Note: this implementation can be thrown away once we upgrade to C++23. */
+
+template< class Enum >
+constexpr underlying_type_t<Enum> to_underlying( Enum e ) noexcept {

Review comment:
       I am torn on this... I both like and dislike it.
   
   Dislikes:
   - The name, underlying doesn't feel right, but I can't put my finger on it. 
`to_ordinal`?
   - It sort of undoes one of the key features of `enum class` by casting the 
enum something, you don't really see what, that can decay to another type.
   - Doesn't have a reverse like `static_cast` does so there is no mirror 
operation going back and forth between enum and ordinal value.
   
   Like:
   - Hides the mess of casting to a int type.
   🤷 

##########
File path: cppcache/src/util/to_underlying.hpp
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#ifndef UTIL_UNDERLYING_TYPE_HPP
+#define UTIL_UNDERLYING_TYPE_HPP
+
+#include <type_traits>
+
+/* Note: this implementation can be thrown away once we upgrade to C++14. */
+
+template< class T >
+using underlying_type_t = typename std::underlying_type<T>::type;
+
+/* Note: this implementation can be thrown away once we upgrade to C++23. */
+
+template< class Enum >
+constexpr underlying_type_t<Enum> to_underlying( Enum e ) noexcept {

Review comment:
       I am torn on this... I both like and dislike it.
   
   Dislikes:
   - The name, underlying doesn't feel right, but I can't put my finger on it. 
`to_ordinal`?
   - It sort of undoes one of the key features of `enum class` by casting the 
enum something, you don't really see what, that can decay to another type.
   - Doesn't have a reverse like `static_cast` does so there is no mirror 
operation going back and forth between enum and ordinal value.
   
   Like:
   - Hides the mess of casting to a int type.
   
   🤷 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Handshake "acceptance codes" should be an enum class
> ----------------------------------------------------
>
>                 Key: GEODE-10096
>                 URL: https://issues.apache.org/jira/browse/GEODE-10096
>             Project: Geode
>          Issue Type: Improvement
>          Components: native client
>            Reporter: Blake Bender
>            Priority: Major
>              Labels: pull-request-available
>
> In the method TcrConnection::initTcrConnection, the following block of code 
> appears:
> {code:java}
>     switch (acceptanceCode[0]) {
>       case REPLY_OK:
>       case SUCCESSFUL_SERVER_TO_CLIENT:
>         LOGFINER("Handshake reply: %u,%u,%u", acceptanceCode[0],
>                  serverQueueStatus[0], recvMsgLen2);
>         if (isClientNotification) 
> readHandshakeInstantiatorMsg(connectTimeout);
>         break;
>       case REPLY_AUTHENTICATION_FAILED: {
>         AuthenticationFailedException ex(
>             reinterpret_cast<char*>(recvMessage.data()));
>         m_conn.reset();
>         throwException(ex);
>       }
>       case REPLY_AUTHENTICATION_REQUIRED: {
>         AuthenticationRequiredException ex(
>             reinterpret_cast<char*>(recvMessage.data()));
>         m_conn.reset();
>         throwException(ex);
>       }
>       case REPLY_DUPLICATE_DURABLE_CLIENT: {
>         DuplicateDurableClientException ex(
>             reinterpret_cast<char*>(recvMessage.data()));
>         m_conn.reset();
>         throwException(ex);
>       }
>       case REPLY_REFUSED:
>       case REPLY_INVALID:
>       case UNSUCCESSFUL_SERVER_TO_CLIENT: {
>         LOGERROR("Handshake rejected by server[%s]: %s",
>                  m_endpointObj->name().c_str(),
>                  reinterpret_cast<char*>(recvMessage.data()));
>         auto message = std::string("TcrConnection::TcrConnection: ") +
>                        "Handshake rejected by server: " +
>                        reinterpret_cast<char*>(recvMessage.data());
>         CacheServerException ex(message);
>         m_conn.reset();
>         throw ex;
>       }
> {code}
> These response codes are unique to the server handshake, and not used 
> anywhere else in the code. We need to remove the #defines for them and put 
> them in a proper enum class.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to