Clean up some SonarQube warnings (trailing whitespace, etc).
[platform/upstream/iotivity.git] / android / android_api / base / jni / JniListenerManager.cpp
index c9ccaa3..b06be3b 100644 (file)
-///*\r
-//* //******************************************************************\r
-//* //\r
-//* // Copyright 2015 Intel Corporation.\r
-//* //\r
-//* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-//* //\r
-//* // Licensed under the Apache License, Version 2.0 (the "License");\r
-//* // you may not use this file except in compliance with the License.\r
-//* // You may obtain a copy of the License at\r
-//* //\r
-//* //      http://www.apache.org/licenses/LICENSE-2.0\r
-//* //\r
-//* // Unless required by applicable law or agreed to in writing, software\r
-//* // distributed under the License is distributed on an "AS IS" BASIS,\r
-//* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-//* // See the License for the specific language governing permissions and\r
-//* // limitations under the License.\r
-//* //\r
-//* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-//*/\r
-//\r
-//#include "JniListenerManager.h"\r
-//\r
-//#include "JniOnGetListener.h"\r
-//\r
-//template<class T>\r
-//T* JniListenerManager<T>::addListener(JNIEnv* env, jobject jListener)\r
-//{\r
-//     T *onEventListener = NULL;\r
-//\r
-//     m_mapMutex.lock();\r
-//\r
-//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
-//     {\r
-//             if (env->IsSameObject(jListener, it->first))\r
-//             {\r
-//                     auto refPair = it->second;\r
-//                     onEventListener = refPair.first;\r
-//                     refPair.second++;\r
-//                     it->second = refPair;\r
-//                     m_listenerMap.insert(*it);\r
-//                     LOGD("OnEventListener: ref. count is incremented");\r
-//                     break;\r
-//             }\r
-//     }\r
-//\r
-//     if (!onEventListener)\r
-//     {\r
-//             onEventListener = new T(env, jListener, this);\r
-//             jobject jgListener = env->NewGlobalRef(jListener);\r
-//\r
-//             m_listenerMap.insert(std::pair<jobject, std::pair<T*, int>>(jgListener, std::pair<T*, int>(onEventListener, 1)));\r
-//             LOGD("OnEventListener: new listener");\r
-//     }\r
-//\r
-//     m_mapMutex.unlock();\r
-//\r
-//     return onEventListener;\r
-//}\r
-//\r
-//template<class T>\r
-//void JniListenerManager<T>::removeListener(JNIEnv* env, jobject jListener)\r
-//{\r
-//     m_mapMutex.lock();\r
-//\r
-//     bool isFound = false;\r
-//\r
-//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
-//     {\r
-//             if (env->IsSameObject(jListener, it->first))\r
-//             {\r
-//                     auto refPair = it->second;\r
-//                     if (refPair.second > 1)\r
-//                     {\r
-//                             refPair.second--;\r
-//                             it->second = refPair;\r
-//                             m_listenerMap.insert(*it);\r
-//                             LOGI("OnEventListener: ref. count is decremented");\r
-//                     }\r
-//                     else\r
-//                     {\r
-//                             env->DeleteGlobalRef(it->first);\r
-//                             T* listener = refPair.first;\r
-//                             delete listener;\r
-//                             m_listenerMap.erase(it);\r
-//\r
-//                             LOGI("OnEventListener is removed");\r
-//                     }\r
-//\r
-//                     isFound = true;\r
-//                     break;\r
-//             }\r
-//     }\r
-//\r
-//     if (!isFound)\r
-//     {\r
-//             ThrowOcException(JNI_EXCEPTION, "OnEventListener isn't found");\r
-//     }\r
-//\r
-//     m_mapMutex.unlock();\r
-//}\r
-//\r
+///*
+//* //******************************************************************
+//* //
+//* // Copyright 2015 Intel Corporation.
+//* //
+//* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//* //
+//* // Licensed 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 "JniListenerManager.h"
+//
+//#include "JniOnGetListener.h"
+//
+//template<class T>
+//T* JniListenerManager<T>::addListener(JNIEnv* env, jobject jListener)
+//{
+//     T *onEventListener = NULL;
+//
+//     m_mapMutex.lock();
+//
+//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
+//     {
+//             if (env->IsSameObject(jListener, it->first))
+//             {
+//                     auto refPair = it->second;
+//                     onEventListener = refPair.first;
+//                     refPair.second++;
+//                     it->second = refPair;
+//                     m_listenerMap.insert(*it);
+//                     LOGD("OnEventListener: ref. count is incremented");
+//                     break;
+//             }
+//     }
+//
+//     if (!onEventListener)
+//     {
+//             onEventListener = new T(env, jListener, this);
+//             jobject jgListener = env->NewGlobalRef(jListener);
+//
+//             m_listenerMap.insert(std::pair<jobject, std::pair<T*, int>>(jgListener, std::pair<T*, int>(onEventListener, 1)));
+//             LOGD("OnEventListener: new listener");
+//     }
+//
+//     m_mapMutex.unlock();
+//
+//     return onEventListener;
+//}
+//
+//template<class T>
+//void JniListenerManager<T>::removeListener(JNIEnv* env, jobject jListener)
+//{
+//     m_mapMutex.lock();
+//
+//     bool isFound = false;
+//
+//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
+//     {
+//             if (env->IsSameObject(jListener, it->first))
+//             {
+//                     auto refPair = it->second;
+//                     if (refPair.second > 1)
+//                     {
+//                             refPair.second--;
+//                             it->second = refPair;
+//                             m_listenerMap.insert(*it);
+//                             LOGI("OnEventListener: ref. count is decremented");
+//                     }
+//                     else
+//                     {
+//                             env->DeleteGlobalRef(it->first);
+//                             T* listener = refPair.first;
+//                             delete listener;
+//                             m_listenerMap.erase(it);
+//
+//                             LOGI("OnEventListener is removed");
+//                     }
+//
+//                     isFound = true;
+//                     break;
+//             }
+//     }
+//
+//     if (!isFound)
+//     {
+//             ThrowOcException(JNI_EXCEPTION, "OnEventListener isn't found");
+//     }
+//
+//     m_mapMutex.unlock();
+//}
+//