You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by ve...@apache.org on 2012/08/02 16:40:14 UTC
svn commit: r1368491 [3/8] - in /incubator/etch/trunk: ./
binding-cpp/runtime/ binding-cpp/runtime/include/common/
binding-cpp/runtime/include/serialization/
binding-cpp/runtime/include/transport/ binding-cpp/runtime/lib/capu/
binding-cpp/runtime/lib/c...
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/acme/toolchain/Windows_X86_32.toolchain
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/acme/toolchain/Windows_X86_32.toolchain?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/acme/toolchain/Windows_X86_32.toolchain (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/acme/toolchain/Windows_X86_32.toolchain Thu Aug 2 14:40:08 2012
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+SET(CMAKE_SYSTEM_NAME Windows)
+SET(CMAKE_SYSTEM_VERSION 1)
+
+SET(TARGET_OS Windows)
+SET(TARGET_ARCH X86_32)
+SET(TARGET_COMPILER MSVC)
+
+SET(CMAKE_C_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG /MP8 /GR-")
+SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /W3")
+
+SET(CMAKE_C_FLAGS_DEBUG "/MDd /Zi /Od /RTC1 /D_DEBUG /MP8" )
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W3")
+
+
+add_definitions("-DOS_WINDOWS")
+add_definitions("-DARCH_X86_32")
+
+# enable the BUILD_CHECK_MEMORY flag if you would like to check for memory leaks with visual leak detector
+#add_definitions("-DBUILD_CHECK_MEMORY")
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/acme/toolchain/Windows_X86_64.toolchain
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/acme/toolchain/Windows_X86_64.toolchain?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/acme/toolchain/Windows_X86_64.toolchain (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/acme/toolchain/Windows_X86_64.toolchain Thu Aug 2 14:40:08 2012
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+SET(CMAKE_SYSTEM_NAME Windows)
+SET(CMAKE_SYSTEM_VERSION 1)
+
+SET(TARGET_OS Windows)
+SET(TARGET_ARCH X86_64)
+SET(TARGET_COMPILER MSVC)
+
+SET(CMAKE_C_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG /MP8 /GR-")
+SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /W3")
+
+SET(CMAKE_C_FLAGS_DEBUG "/MDd /Zi /Od /RTC1 /D_DEBUG /MP8" )
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W3")
+
+
+add_definitions("-DOS_WINDOWS")
+add_definitions("-DARCH_X86_64")
+
+# enable the BUILD_CHECK_MEMORY flag if you would like to check for memory leaks with visual leak detector
+#add_definitions("-DBUILD_CHECK_MEMORY")
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindIP4.cmake
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindIP4.cmake?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindIP4.cmake (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindIP4.cmake Thu Aug 2 14:40:08 2012
@@ -0,0 +1,49 @@
+#
+# 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.
+#
+
+# To specify your package use the following variables
+# ${PACKAGE_NAME}_INCLUDE_DIRS
+# ${PACKAGE_NAME}_LIBRARY_DIRS
+# ${PACKAGE_NAME}_LIBNAMES
+# ${PACKAGE_NAME}_DEPENDENT_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_DEBUG_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_RELEASE_DEFINITIONS
+
+SET(PACKAGE_NAME IP4)
+
+IF("${TARGET_OS}" STREQUAL "Windows")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Linux")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Integrity")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES ip4 PATHS /intarmv7a_vfp_common )
+
+ELSEIF("${TARGET_OS}" STREQUAL "QNX")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ENDIF()
+
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindLibRt.cmake
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindLibRt.cmake?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindLibRt.cmake (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindLibRt.cmake Thu Aug 2 14:40:08 2012
@@ -0,0 +1,49 @@
+#
+# 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.
+#
+
+# To specify your package use the following variables
+# ${PACKAGE_NAME}_INCLUDE_DIRS
+# ${PACKAGE_NAME}_LIBRARY_DIRS
+# ${PACKAGE_NAME}_LIBNAMES
+# ${PACKAGE_NAME}_DEPENDENT_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_DEBUG_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_RELEASE_DEFINITIONS
+
+SET(PACKAGE_NAME LibRt)
+
+IF("${TARGET_OS}" STREQUAL "Windows")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Linux")
+
+ FIND_PATH(${PACKAGE_NAME}_INCLUDE_DIRS time.h /usr/include )
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES rt PATHS /usr/lib )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Integrity")
+
+ FIND_PATH(${PACKAGE_NAME}_INCLUDE_DIRS time.h /INTEGRITY-include )
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES posix PATHS /intarmv7a_vfp_common )
+
+ELSEIF("${TARGET_OS}" STREQUAL "QNX")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ENDIF()
+
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindNet.cmake
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindNet.cmake?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindNet.cmake (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindNet.cmake Thu Aug 2 14:40:08 2012
@@ -0,0 +1,48 @@
+#
+# 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.
+
+# To specify your package use the following variables
+# ${PACKAGE_NAME}_INCLUDE_DIRS
+# ${PACKAGE_NAME}_LIBRARY_DIRS
+# ${PACKAGE_NAME}_LIBNAMES
+# ${PACKAGE_NAME}_DEPENDENT_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_DEBUG_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_RELEASE_DEFINITIONS
+
+SET(PACKAGE_NAME Net)
+
+IF("${TARGET_OS}" STREQUAL "Windows")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Linux")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "" )
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Integrity")
+
+ FIND_PATH(${PACKAGE_NAME}_INCLUDE_DIRS netdb.h /INTEGRITY-include )
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES net PATHS /intarmv7a_vfp_common )
+
+ELSEIF("${TARGET_OS}" STREQUAL "QNX")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ENDIF()
+
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindRes.cmake
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindRes.cmake?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindRes.cmake (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindRes.cmake Thu Aug 2 14:40:08 2012
@@ -0,0 +1,49 @@
+#
+# 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.
+#
+
+# To specify your package use the following variables
+# ${PACKAGE_NAME}_INCLUDE_DIRS
+# ${PACKAGE_NAME}_LIBRARY_DIRS
+# ${PACKAGE_NAME}_LIBNAMES
+# ${PACKAGE_NAME}_DEPENDENT_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_DEBUG_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_RELEASE_DEFINITIONS
+
+SET(PACKAGE_NAME Res)
+
+IF("${TARGET_OS}" STREQUAL "Windows")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Linux")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Integrity")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES res PATHS /intarmv7a_vfp_common )
+
+ELSEIF("${TARGET_OS}" STREQUAL "QNX")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ENDIF()
+
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindSocket.cmake
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindSocket.cmake?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindSocket.cmake (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindSocket.cmake Thu Aug 2 14:40:08 2012
@@ -0,0 +1,48 @@
+#
+# 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.
+
+# To specify your package use the following variables
+# ${PACKAGE_NAME}_INCLUDE_DIRS
+# ${PACKAGE_NAME}_LIBRARY_DIRS
+# ${PACKAGE_NAME}_LIBNAMES
+# ${PACKAGE_NAME}_DEPENDENT_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_DEBUG_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_RELEASE_DEFINITIONS
+
+SET(PACKAGE_NAME Socket)
+
+IF("${TARGET_OS}" STREQUAL "Windows")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Linux")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "" )
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Integrity")
+
+ FIND_PATH(${PACKAGE_NAME}_INCLUDE_DIRS /sys/socket.h /INTEGRITY-include )
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES socket PATHS /intarmv7a_vfp_common )
+
+ELSEIF("${TARGET_OS}" STREQUAL "QNX")
+
+ FIND_PATH(${PACKAGE_NAME}_INCLUDE_DIRS /sys/socket.h /include )
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES socket PATHS /x86/lib )
+
+ENDIF()
+
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindThread.cmake
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindThread.cmake?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindThread.cmake (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/cmake/modules/FindThread.cmake Thu Aug 2 14:40:08 2012
@@ -1,42 +1,48 @@
-#
-# 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.
-#
-
-IF("${TARGET_ARCH}" STREQUAL "Win32")
-
- SET(Thread_INCLUDE_DIR "")
- SET(Thread_LIBRARIES "")
-
-ELSEIF("${TARGET_ARCH}" STREQUAL "Linux")
-
- FIND_PATH(Thread_INCLUDE_DIR pthread.h /usr/include )
- FIND_LIBRARY(Thread_LIBRARIES NAMES pthread PATHS /usr/lib )
-
+#
+# 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.
+
+# To specify your package use the following variables
+# ${PACKAGE_NAME}_INCLUDE_DIRS
+# ${PACKAGE_NAME}_LIBRARY_DIRS
+# ${PACKAGE_NAME}_LIBNAMES
+# ${PACKAGE_NAME}_DEPENDENT_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_DEBUG_DEFINITIONS
+# ${PACKAGE_NAME}_DEPENDENT_RELEASE_DEFINITIONS
+
+SET(PACKAGE_NAME Thread)
+
+IF("${TARGET_OS}" STREQUAL "Windows")
+
+ SET(${PACKAGE_NAME}_INCLUDE_DIRS "")
+ SET(${PACKAGE_NAME}_LIBRARIES "" )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Linux")
+
+ FIND_PATH(${PACKAGE_NAME}_INCLUDE_DIRS pthread.h /usr/include )
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES pthread PATHS /usr/lib )
+
+ELSEIF("${TARGET_OS}" STREQUAL "Integrity")
+
+ FIND_PATH(${PACKAGE_NAME}_INCLUDE_DIRS pthread.h /INTEGRITY-include )
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES posix PATHS /intarmv7a_vfp_common )
+
+ELSEIF("${TARGET_OS}" STREQUAL "QNX")
+
+ FIND_PATH(${PACKAGE_NAME}_INCLUDE_DIRS pthread.h /include )
+ FIND_LIBRARY(${PACKAGE_NAME}_LIBRARIES NAMES c PATHS /x86/lib )
+
ENDIF()
-
-SET( Thread_FOUND "NO" )
-IF(DEFINED Thread_LIBRARIES)
- SET( Thread_FOUND "YES" )
- message(STATUS "Found Thread libs: ${Thread_LIBRARIES}")
- message(STATUS "Found Thread includes: ${Thread_INCLUDE_DIR}")
-ENDIF(DEFINED Thread_LIBRARIES)
-
-MARK_AS_ADVANCED(
- Thread_INCLUDE_DIR
- Thread_ARCH_INCLUDE_DIR
- Thread_LIBRARIES
-)
-
+
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/CMakeLists.txt?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/CMakeLists.txt Thu Aug 2 14:40:08 2012
@@ -17,27 +17,61 @@
ADD_MODULE(capu static)
-ADD_CLASS(Config)
-ADD_CLASS(Error)
-ADD_CLASS(os/Mutex SOURCE_GROUP arch_source_group)
-ADD_CLASS(os/AtomicOperation SOURCE_GROUP arch_source_group)
-ADD_CLASS(util/SmartPointer)
-ADD_CLASS(os/Thread SOURCE_GROUP arch_source_group)
-ADD_CLASS(os/CondVar SOURCE_GROUP arch_source_group)
-ADD_CLASS(os/StringUtils SOURCE_GROUP arch_source_group)
-ADD_CLASS(os/NumericLimits SOURCE_GROUP arch_source_group)
-ADD_CLASS(container/List)
-ADD_CLASS(container/Comparator)
-ADD_CLASS(container/Hash)
-ADD_CLASS(container/Pair)
-ADD_CLASS(util/Traits)
-ADD_CLASS(container/HashTable)
-ADD_CLASS(container/HashSet)
-ADD_CLASS(os/Socket SOURCE_GROUP arch_source_group)
-ADD_CLASS(os/ServerSocket SOURCE_GROUP arch_source_group)
+ADD_FILE(Config)
+ADD_FILE(Error)
+ADD_FILE(os/Mutex SOURCE_GROUP arch_source_group)
+ADD_FILE(os/AtomicOperation SOURCE_GROUP arch_source_group)
+ADD_FILE(os/Thread SOURCE_GROUP arch_source_group)
+ADD_FILE(os/CondVar SOURCE_GROUP arch_source_group)
+ADD_FILE(os/StringUtils SOURCE_GROUP arch_source_group)
+ADD_FILE(os/NumericLimits SOURCE_GROUP arch_source_group)
+ADD_FILE(os/Time SOURCE_GROUP arch_source_group)
+ADD_FILE(container/List)
+ADD_FILE(container/Comparator)
+ADD_FILE(container/Hash)
+ADD_FILE(container/Pair)
+ADD_FILE(container/Array)
+ADD_FILE(container/Queue)
+ADD_FILE(container/RingBuffer)
+ADD_FILE(container/HashTable)
+ADD_FILE(container/HashSet)
+ADD_FILE(os/Socket SOURCE_GROUP arch_source_group)
+ADD_FILE(os/ServerSocket SOURCE_GROUP arch_source_group)
+ADD_FILE(os/UdpSocket SOURCE_GROUP arch_source_group)
+ADD_FILE(os/Memory SOURCE_GROUP arch_source_group)
+ADD_FILE(os/Math SOURCE_GROUP arch_source_group)
+ADD_FILE(util/SmartPointer)
+ADD_FILE(util/Logger)
+ADD_FILE(util/Appender)
+ADD_FILE(util/Runnable)
+ADD_FILE(util/Traits)
REQUIRED_PACKAGE(Thread)
+REQUIRED_PACKAGE(LibRt)
+REQUIRED_PACKAGE(Socket)
+REQUIRED_PACKAGE(Net)
+REQUIRED_PACKAGE(IP4)
+REQUIRED_PACKAGE(Res)
-SOURCE_GROUP(${TARGET_ARCH} FILES ${arch_source_group})
+SOURCE_GROUP(${TARGET_OS}_${TARGET_ARCH} FILES ${arch_source_group})
+
+IF("${TARGET_OS}" STREQUAL "Integrity")
+ ADD_FILE(os/Integrity/global_table)
+ ADD_LINKER_FLAG("${CMAKE_SOURCE_DIR}/modules/capu/res/kernel_default.ld")
+ ADD_LINKER_FLAG("-kernel")
+ENDIF()
+
+SET(USE_BOOST 0 CACHE BOOL "Enable boost performance test")
+SET(USE_STL_UNORDEREDMAP 0 CACHE BOOL "Enable strl tr1 unordered_map performance test")
+
+IF(${USE_BOOST})
+ ADD_COMPILER_FLAG("USE_BOOST")
+ SET(BOOST_ROOT_DIR "" CACHE PATH "Path to boost root")
+ INCLUDE_DIRECTORIES("${BOOST_ROOT_DIR}")
+ENDIF()
+
+IF(${USE_STL_UNORDEREDMAP})
+ ADD_COMPILER_FLAG("USE_STL_UNORDEREDMAP")
+ENDIF()
JUST_DOIT()
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Config.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Config.h?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Config.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Config.h Thu Aug 2 14:40:08 2012
@@ -23,41 +23,108 @@
#include "stdlib.h"
#include "string.h"
-#define DEFAULT_HASH_TABLE_SIZE 1000
+/**
+ * Defines the default hash table size
+ */
+#define HASH_TABLE_DEFAULT_SIZE 1000
-#ifdef _WIN32
- #define _WINSOCKAPI_
+/**
+ * Defines the default hash set size
+ */
+#define HASH_SET_DEFAULT_SIZE 1000
+
+/**
+ * Defines the max number of possible appenders
+ */
+#define LOGGER_APPENDER_MAX 10
+
+/**
+ * os specific defines
+ */
+#ifdef OS_WINDOWS
+ #define _WINSOCKAPI_
#endif
namespace capu
{
- #ifdef _WIN32
- typedef char int8_t;
- typedef unsigned char uint8_t;
- typedef short int16_t;
- typedef unsigned short uint16_t;
- typedef int int32_t;
- typedef signed __int64 int64_t;
- typedef unsigned int uint32_t;
- typedef unsigned __int64 uint64_t;
- typedef float float_t;
- typedef double double_t;
- typedef bool bool_t;
- typedef int64_t time_t;
- #else //other OS should be C99 compliant
- typedef signed char int8_t;
- typedef unsigned char uint8_t;
- typedef short int int16_t;
- typedef unsigned short int uint16_t;
- typedef int int32_t;
- typedef long long int int64_t;
- typedef unsigned long int uint32_t;
+ #if defined (OS_WINDOWS)
+ typedef signed char int8_t;
+ typedef unsigned char uint8_t;
+ typedef short int16_t;
+ typedef unsigned short uint16_t;
+ typedef int int32_t;
+ typedef signed __int64 int64_t;
+ typedef unsigned int uint32_t;
+ typedef unsigned __int64 uint64_t;
+ typedef float float_t;
+ typedef double double_t;
+ typedef bool bool_t;
+ typedef char char_t;
+ typedef uint8_t uchar_t;
+ typedef int64_t time_t;
+ #elif defined (OS_LINUX)
+ typedef signed char int8_t;
+ typedef unsigned char uint8_t;
+ typedef short int int16_t;
+ typedef unsigned short int uint16_t;
+ typedef int int32_t;
+ typedef long long int int64_t;
+ typedef unsigned long int uint32_t;
+ typedef unsigned long long int uint64_t;
+ typedef float float_t;
+ typedef double double_t;
+ typedef bool bool_t;
+ typedef double double_t;
+ typedef char char_t;
+ typedef uint8_t uchar_t;
+ typedef int64_t time_t;
+ #elif defined (OS_INTEGRITY)
+ typedef signed char int8_t;
+ typedef unsigned char uint8_t;
+ typedef short int int16_t;
+ typedef unsigned short int uint16_t;
+ typedef int int32_t;
+ typedef long long int int64_t;
+ typedef unsigned long int uint32_t;
+ typedef unsigned long long int uint64_t;
+ typedef float float_t;
+ typedef double double_t;
+ typedef bool bool_t;
+ typedef double double_t;
+ typedef char char_t;
+ typedef uint8_t uchar_t;
+ typedef int64_t time_t;
+ #elif defined (OS_QNX)
+ typedef signed char int8_t;
+ typedef unsigned char uint8_t;
+ typedef short int int16_t;
+ typedef unsigned short int uint16_t;
+ typedef int int32_t;
+ typedef long long int int64_t;
+ typedef unsigned long int uint32_t;
typedef unsigned long long int uint64_t;
- typedef float float_t;
- typedef double double_t;
- typedef bool bool_t;
- typedef int64_t time_t;
- #endif //_WIN32
+ typedef float float_t;
+ typedef double double_t;
+ typedef bool bool_t;
+ typedef double double_t;
+ typedef char char_t;
+ typedef int64_t time_t;
+ typedef uint8_t uchar_t;
+ #endif
+
+ //platform depended types
+ #if defined (ARCH_X86_32)
+ typedef int32_t int_t;
+ typedef uint32_t uint_t;
+ #elif defined (ARCH_X86_64)
+ typedef int64_t int_t;
+ typedef uint64_t uint_t;
+ #elif defined (ARCH_ARMV7L)
+ typedef int32_t int_t;
+ typedef uint32_t uint_t;
+ #endif
+
}
#endif
+
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h Thu Aug 2 14:40:08 2012
@@ -1,47 +1,47 @@
-/* $Id$
- *
- * 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 __ERROR_H__
-#define __ERROR_H__
-
-#include "Config.h"
-
-namespace capu {
- typedef int32_t status_t;
-
- enum {
- CAPU_OK = 0,
- CAPU_EUNIMPL = 1,
- CAPU_ERANGE = 2,
- CAPU_EINVAL = 3,
- CAPU_ERROR = 4,
- CAPU_SOCKET_EBIND = 5,
- CAPU_SOCKET_ESOCKET = 6,
- CAPU_SOCKET_ECONNECT = 7,
- CAPU_SOCKET_ELISTEN = 8,
- CAPU_SOCKET_ECLOSE = 9,
- CAPU_SOCKET_EADDR = 10,
- CAPU_ENO_MEMORY = 11,
- CAPU_TIMEOUT = 12,
- CAPU_ENOT_EXIST = 13,
- CAPU_ENOT_SUPPORTED = 14,
- CAPU_EIO = 15
- };
-}
-#endif
-
+/* $Id$
+ *
+ * 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 __ERROR_H__
+#define __ERROR_H__
+
+#include "Config.h"
+
+namespace capu {
+ typedef int32_t status_t;
+
+ enum Errors{
+ CAPU_OK = 0,
+ CAPU_EUNIMPL = 1,
+ CAPU_ERANGE = 2,
+ CAPU_EINVAL = 3,
+ CAPU_ERROR = 4,
+ CAPU_SOCKET_EBIND = 5,
+ CAPU_SOCKET_ESOCKET = 6,
+ CAPU_SOCKET_ECONNECT = 7,
+ CAPU_SOCKET_ELISTEN = 8,
+ CAPU_SOCKET_ECLOSE = 9,
+ CAPU_SOCKET_EADDR = 10,
+ CAPU_ENO_MEMORY = 11,
+ CAPU_ETIMEOUT = 12,
+ CAPU_ENOT_EXIST = 13,
+ CAPU_ENOT_SUPPORTED = 14,
+ CAPU_EIO = 15
+ };
+}
+#endif
+
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Array.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Array.h?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Array.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Array.h Thu Aug 2 14:40:08 2012
@@ -0,0 +1,306 @@
+/* $Id$
+ *
+ * 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 __ARRAY_H__
+#define __ARRAY_H__
+
+#include "capu/Config.h"
+#include "capu/Error.h"
+#include "capu/os/Memory.h"
+
+namespace capu
+{
+
+ template<typename T>
+ class Array
+ {
+ public:
+
+ /**
+ * default constructor
+ * @param size fix size of the array
+ */
+ Array<T>();
+
+ /**
+ * constructor
+ * @param size fix size of the array
+ */
+ Array<T>(uint_t size);
+
+ /**
+ * constructor
+ * @param size fix size of the array
+ * @param value for initialization of the array
+ */
+ Array<T>(uint_t size, const T& value);
+
+ /**
+ * constructor for conversion from raw data
+ * @param size fix size of the array
+ * @param value for initialization of the array
+ */
+ Array<T>(const T other[], uint_t size);
+
+ /*
+ * Copy constructor
+ */
+ Array<T>(const Array<T>& other);
+
+ /*
+ * Assignment operator
+ */
+ Array<T>& operator=(const Array<T>& other);
+
+ /**
+ * destructor
+ */
+ virtual ~Array(void);
+
+ /**
+ * return size of the array
+ * @return returns the size of the array
+ */
+ uint_t size() const;
+
+ /**
+ * initializes the array with the given value
+ * @param value initialization value
+ */
+ void set(const T& value);
+
+ /**
+ * sets every array index between start and start+count to value
+ * @param value initialization value
+ * @param start start index
+ * @param count number of elements
+ * @return ETCH_ERANGE if out of bounds
+ * ETCH_OK otherwise
+ */
+ status_t set(const T& value, const uint_t start, const uint_t count);
+
+ /**
+ * swaps to elements
+ * @param index1 index of the first element
+ * @param index2 index of the second element
+ * @return ETCH_ERANGE if out of bounds
+ * ETCH_OK otherwise
+ */
+ status_t swap(uint_t index1, uint_t index2);
+
+ /**
+ * moves elements inside the array
+ * @param start start index
+ * @param count number of elements
+ * @param dst destination index
+ * @return ETCH_ERANGE if out of bounds
+ * ETCH_OK otherwise
+ */
+ status_t move(uint_t start, uint_t count, uint_t dst);
+
+ /**
+ * copies the given values into the array
+ * @param other values for the contents of the array
+ * @param size fix size of the array
+ * @return ETCH_ERANGE if size does not match array size
+ * ETCH_OK otherwise
+ */
+ status_t copy(const T other[], uint_t size);
+
+ /**
+ * Allows access of an array element
+ * @param the index of the element
+ * @return reference to the element at the given position
+ */
+ T& operator [](const uint_t index) const;
+
+ /**
+ * Sets the raw data of the array to the given value
+ * @param the byte value for all array elements
+ */
+ void setRawData(int32_t value);
+
+ private:
+ uint_t mSize;
+ T* mData;
+ status_t setData(const T& value, const uint_t start, const uint_t count);
+};
+
+ template<typename T>
+ Array<T>::Array()
+ : mSize(0)
+ , mData(0)
+ {
+
+ }
+
+ template<typename T>
+ Array<T>::Array(uint_t size)
+ : mSize(size)
+ , mData(new T[size])
+ {
+ }
+
+ template<typename T>
+ Array<T>::Array(uint_t size, const T& value)
+ : mSize(size)
+ , mData(new T[size])
+ {
+ set(value);
+ }
+
+ template<typename T>
+ Array<T>::Array(const T other[], uint_t size)
+ :mSize(size)
+ {
+ mData = new T[mSize];
+ Memory::Copy(mData, other, size * sizeof(T));
+ }
+
+
+ template<typename T>
+ Array<T>::Array(const Array<T>& other)
+ : mSize(other.mSize)
+ {
+ mData = new T[mSize];
+ Memory::Copy(mData, other.mData, other.size() * sizeof(T));
+ }
+
+ template<typename T>
+ Array<T>& Array<T>::operator=(const Array<T>& other)
+ {
+ if(mSize != other.mSize)
+ {
+ if(mData != 0)
+ {
+ delete[] mData;
+ }
+ mSize = other.mSize;
+ mData = new T[mSize];
+ }
+
+ Memory::Copy(mData, other.mData, other.size() * sizeof(T));
+ return *this;
+ }
+
+
+ template<typename T>
+ Array<T>::~Array(void)
+ {
+ delete[] mData;
+ }
+
+ template<typename T>
+ void Array<T>::set(const T& value)
+ {
+ setData(value, 0, mSize);
+ }
+
+ template<typename T>
+ status_t Array<T>::set(const T& value, uint_t index, uint_t count)
+ {
+ return setData(value, index, count);
+ }
+
+ template<typename T>
+ status_t Array<T>::swap(uint_t index1, uint_t index2)
+ {
+ if (index1 >= mSize || index2 >= mSize){
+ return CAPU_ERANGE;
+ }
+ T tmp = mData[index1];
+ mData[index1] = mData[index2];
+ mData[index2] = tmp;
+
+ return CAPU_OK;
+ }
+
+ template<typename T>
+ status_t Array<T>::move(uint_t start, uint_t count, uint_t dst)
+ {
+ if ((start >= mSize) || ((count+start) > mSize) || ((mSize-count) + start < 0) || ((dst+count) > mSize)) {
+ return CAPU_ERANGE;
+ }
+ Memory::Move(mData + dst, mData + start, sizeof(T) * count);
+
+ return CAPU_OK;
+ }
+
+ template<typename T>
+ status_t Array<T>::copy(const T other[], uint_t size)
+ {
+ if (size != mSize) {
+ return CAPU_ERANGE;
+ }
+
+ Memory::Copy(mData, other, size * sizeof(T));
+
+ return CAPU_OK;
+ }
+
+ template<typename T>
+ T& Array<T>::operator[](const uint_t index) const
+ {
+ return mData[index];
+ }
+
+ template<typename T>
+ uint_t Array<T>::size() const
+ {
+ return mSize;
+ }
+
+ template<typename T>
+ status_t Array<T>::setData(const T& value, const uint_t index, const uint_t count) {
+
+ if ((index >= mSize) || ((count+index) > mSize) || ((mSize-count) + index < 0)) {
+ return CAPU_ERANGE;
+ }
+ T* start = &mData[mSize-(mSize-count) + index];
+
+ switch(count)
+ {
+ default:
+ {
+ T* end = start - (count - 10);
+ while(start > end){ *(--start) = value; }
+ }
+ case 10 : *(--start) = value;
+ case 9 : *(--start) = value;
+ case 8 : *(--start) = value;
+ case 7 : *(--start) = value;
+ case 6 : *(--start) = value;
+ case 5 : *(--start) = value;
+ case 4 : *(--start) = value;
+ case 3 : *(--start) = value;
+ case 2 : *(--start) = value;
+ case 1 : *(--start) = value;
+ }
+
+ return CAPU_OK;
+ }
+
+ template<typename T>
+ void Array<T>::setRawData(int32_t value)
+ {
+ Memory::Set(mData, value, sizeof(T) * mSize);
+ }
+}
+
+
+#endif // __ARRAY_H__
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h Thu Aug 2 14:40:08 2012
@@ -35,6 +35,9 @@ namespace capu {
return (strcmp(x,y) == 0);
}
+ bool_t operator () (char* x, char* y) const {
+ return (strcmp(x,y) == 0);
+ }
};
}
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Hash.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Hash.h?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Hash.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Hash.h Thu Aug 2 14:40:08 2012
@@ -24,43 +24,118 @@
namespace capu {
- class Hash {
+ template<typename T>
+ class HashCalculator;
+
+ template<>
+ class HashCalculator<uint32_t>
+ {
+ private:
+ static const uint32_t prime = 16777619UL;
+ static const uint32_t offset_base = 2166136261UL;
public:
+ static uint32_t Hash(void* key, uint32_t len)
+ {
+ uint32_t result = offset_base;
+ uint8_t* ptr = static_cast<uint8_t*>(key);
+ do
+ {
+ result = (result^*ptr) * prime;
+ ++ptr;
+ }while(--len);
- template <typename T>
- static uint64_t Digest(const T &key) {
- uint64_t result = 0;
- for (uint64_t i = 0; i < 10; ++i) {
- result = (result + static_cast<uint64_t> (key) * 13);
- }
- return static_cast<uint64_t> (result);
- }
-
- static uint64_t Digest(char* key) {
- uint64_t result = 0;
- char * keyStart = key;
- char * keyEnd = key + strlen(key);
- while (keyStart != keyEnd) {
- result = (result + static_cast<uint64_t> (*keyStart) * 13);
- ++keyStart;
- }
return result;
}
- static uint64_t Digest(const char* key) {
- uint64_t result = 0;
- const char * keyStart = key;
- const char * keyEnd = key + strlen(key);
- while (keyStart != keyEnd) {
- result = (result + static_cast<uint64_t> (*keyStart) * 13);
- ++keyStart;
- }
+ static uint32_t Hash(char* key)
+ {
+ uint32_t result = offset_base;
+ do
+ {
+ result = (result^*key) * prime;
+ }while(*(++key));
+
return result;
}
-
+ static uint32_t Hash(const char* key)
+ {
+ uint32_t result = offset_base;
+ do
+ {
+ result = (result^*key) * prime;
+ }while(*(++key));
+
+ return result;
+ }
};
+
+ template<>
+ class HashCalculator<uint64_t>
+ {
+ private:
+ static const uint64_t prime = 1099511628211ULL;
+ static const uint64_t offset_base = 14695981039346656037ULL;
+ public:
+ static uint64_t Hash(void* key, uint32_t len)
+ {
+ uint64_t result = offset_base;
+ uint8_t* ptr = static_cast<uint8_t*>(key);
+ do
+ {
+ result = (result^*ptr) * prime;
+ ++ptr;
+ }while(--len);
+
+ return result;
+ }
+
+ static uint64_t Hash(char* key)
+ {
+ uint64_t result = offset_base;
+ do
+ {
+ result = (result^*key) * prime;
+ }while(*(++key));
+
+ return result;
+ }
+
+ static uint64_t Hash(const char* key)
+ {
+ uint64_t result = offset_base;
+ do
+ {
+ result = (result^*key) * prime;
+ }while(*(++key));
+
+ return result;
+ }
+
+ };
+
+ class Hash
+ {
+ public:
+
+ static uint_t Digest(char* key)
+ {
+ return HashCalculator<uint_t>::Hash(key);
+ }
+
+ static uint_t Digest(const char* key)
+ {
+ return HashCalculator<uint_t>::Hash(key);
+ }
+
+ template<typename T>
+ static uint_t Digest(T key)
+ {
+ return HashCalculator<uint_t>::Hash(&key, sizeof(T));
+ }
+ };
+
}
#endif /* HASH_H */
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/HashSet.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/HashSet.h?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/HashSet.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/HashSet.h Thu Aug 2 14:40:08 2012
@@ -23,9 +23,6 @@
#include "capu/container/Hash.h"
#include "capu/container/List.h"
-#define DEFAULT_HASH_SET_SIZE 1000
-
-
namespace capu {
template <class T, class C = Comparator, class H = Hash >
@@ -41,7 +38,7 @@ namespace capu {
* @param list array of linked list which provide channing for hash set
* @param listSize size of hash set (size of linked list array)
*/
- HashSetIterator(List<T, C> * list, uint64_t listSize);
+ HashSetIterator(List<T, C> * list, uint_t listSize);
/**
* destructor
@@ -65,10 +62,10 @@ namespace capu {
status_t next(T* value);
private:
- uint64_t mCurrentListIndex;
+ uint_t mCurrentListIndex;
typename List<T, C>::Iterator mCurrentListIterator;
List<T, C> * mList;
- uint64_t mMaxListSize;
+ uint_t mMaxListSize;
};
public:
@@ -84,7 +81,7 @@ namespace capu {
* Parameterized Constructor
* @param size size of initial HashSet
*/
- HashSet(uint64_t size);
+ HashSet(uint_t size);
/**
* Destructor
@@ -114,10 +111,21 @@ namespace capu {
status_t remove(const T &value);
/**
+ * Checks if the provided value is already contained in the hash set.
+ *
+ * @param value value that will be checked
+ *
+ * @return true if element is already contained in the hash set
+ * false otherwise
+ *
+ */
+ bool_t hasElement(const T &value);
+
+ /**
* Returns count of the hash set.
* @return number of element in hash set
*/
- uint64_t count();
+ uint_t count();
/**
* Clear all values of the hash set.
@@ -142,8 +150,8 @@ namespace capu {
* @return -1 if the key is unique
* otherwise the index in the linked list
*/
- int32_t __check_duplicate_value(uint64_t index, T k) {
- int32_t count = 0;
+ int_t __check_duplicate_value(uint_t index, T k) {
+ int_t count = 0;
typename List<T, C>::Iterator it = mLists[index].begin();
T tmp;
C compare;
@@ -159,13 +167,13 @@ namespace capu {
}
List<T, C> *mLists;
- uint32_t mSize;
- uint32_t mCount;
+ uint_t mSize;
+ uint_t mCount;
};
template <class T, class C, class H>
HashSet<T, C, H>::HashSet()
- : mSize(DEFAULT_HASH_SET_SIZE)
+ : mSize(HASH_SET_DEFAULT_SIZE)
, mCount(0) {
mLists = new List<T, C>[mSize];
}
@@ -176,7 +184,7 @@ namespace capu {
}
template <class T, class C, class H>
- HashSet<T, C, H>::HashSet(uint64_t size)
+ HashSet<T, C, H>::HashSet(uint_t size)
: mSize(size)
, mCount(0) {
mLists = new List<T, C>[mSize];
@@ -185,7 +193,7 @@ namespace capu {
template <class T, class C, class H>
status_t HashSet< T, C, H>::put(const T &value) {
status_t result;
- uint64_t index = H::Digest(value) % mSize;
+ uint_t index = H::Digest(value) % mSize;
if (mLists[index].isEmpty()) {
result = mLists[index].add(value);
if (result != CAPU_OK) {
@@ -194,7 +202,7 @@ namespace capu {
mCount++;
//THERE IS NO OLD VALUE
} else {
- int32_t key_duplicate_index = this->__check_duplicate_value(index, value);
+ int_t key_duplicate_index = this->__check_duplicate_value(index, value);
if (key_duplicate_index < 0) {
result = mLists[index].add(value);
if (result != CAPU_OK) {
@@ -213,9 +221,9 @@ namespace capu {
template <class T, class C, class H>
status_t HashSet< T, C, H>::remove(const T &value) {
status_t result;
- uint64_t index = H::Digest(value) % mSize;
+ uint_t index = H::Digest(value) % mSize;
- int32_t key_index = this->__check_duplicate_value(index, value);
+ int_t key_index = this->__check_duplicate_value(index, value);
if (key_index < 0) {
return CAPU_ERANGE;
} else {
@@ -229,14 +237,28 @@ namespace capu {
return CAPU_OK;
}
+
+ template <class T, class C, class H>
+ bool_t HashSet< T, C, H>::hasElement(const T &value) {
+ uint_t index = H::Digest(value) % mSize;
+
+ int_t key_index = this->__check_duplicate_value(index, value);
+ if (key_index < 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+
template <class T, class C, class H>
- uint64_t HashSet< T, C, H>::count() {
+ uint_t HashSet< T, C, H>::count() {
return mCount;
}
template <class T, class C, class H>
status_t HashSet< T, C, H>::clear() {
- for (uint64_t i = 0; i < mSize; ++i) {
+ for (uint_t i = 0; i < mSize; ++i) {
mLists[i].clear();
}
mCount = 0;
@@ -244,14 +266,14 @@ namespace capu {
}
template <class T, class C, class H>
- HashSet< T, C, H>::HashSetIterator::HashSetIterator(List<T, C> * list, uint64_t list_size) {
+ HashSet< T, C, H>::HashSetIterator::HashSetIterator(List<T, C> * list, uint_t list_size) {
mCurrentListIndex = 0;
this->mList = list;
mMaxListSize = list_size;
this->mCurrentListIterator = list[mCurrentListIndex].begin();
//to point the first non-empty one
- for (uint64_t i = 0; i < list_size; ++i) {
+ for (uint_t i = 0; i < list_size; ++i) {
if (!mList[i].isEmpty()) {
mCurrentListIndex = i;
this->mCurrentListIterator = list[i].begin();
@@ -314,7 +336,7 @@ namespace capu {
template <class T, class C, class H>
typename HashSet<T, C, H>::Iterator HashSet<T, C, H>::begin() {
- return HashSet<T, C, H>::Iterator(mLists, mSize);
+ return typename HashSet<T, C, H>::Iterator(mLists, mSize);
}
}
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/HashTable.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/HashTable.h?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/HashTable.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/HashTable.h Thu Aug 2 14:40:08 2012
@@ -40,7 +40,7 @@ namespace capu {
* @param list array of linked list which provide channing for hashtable
* @param listSize size of hash table (size of linked list array)
*/
- HashTableIterator(List<Pair<Key, T> > * list, uint64_t listSize);
+ HashTableIterator(List<Pair<Key, T> > * list, uint_t listSize);
/**
* destructor
@@ -64,10 +64,10 @@ namespace capu {
status_t next(Pair<Key, T>* value);
private:
- uint64_t mCurrentListIndex;
+ uint_t mCurrentListIndex;
typename List<Pair<Key, T> >::Iterator mCurrentListIterator;
List<Pair<Key, T> > * mList;
- uint64_t mMaxListSize;
+ uint_t mMaxListSize;
};
public:
@@ -82,7 +82,7 @@ namespace capu {
/**
* Constructs HashTable.
*/
- HashTable(uint64_t size);
+ HashTable(uint_t size);
/**
* Destructure.
@@ -100,7 +100,7 @@ namespace capu {
* CAPU_EINVAL if value_old is null
*
*/
- status_t put(const Key &key, T &value, T* value_old = NULL);
+ status_t put(const Key &key, const T &value, T* value_old = NULL);
/**
* Get value associated with key in the hashtable.
@@ -130,7 +130,7 @@ namespace capu {
* Returns count of the hashtable.
* @return number of element in hash table
*/
- uint64_t count();
+ uint_t count();
/**
* Clear all key and values of the hashtable.
@@ -155,8 +155,8 @@ namespace capu {
* @return -1 if the key is unique
* otherwise the index in the linked list
*/
- int32_t getKeyIndexFromBucket(uint64_t index, const Key &k) {
- int32_t count = 0;
+ int_t getKeyIndexFromBucket(uint_t index, const Key &k) {
+ int_t count = 0;
typename List<Pair<Key, T> >::Iterator it = mLists[index].begin();
Pair<Key, T> pair;
C compare;
@@ -172,27 +172,27 @@ namespace capu {
}
List<Pair<Key, T>, Comparator > *mLists;
- uint64_t mSize;
- uint64_t mCount;
+ uint_t mSize;
+ uint_t mCount;
};
template <class Key, class T, class C, class Hash>
HashTable<Key, T, C, Hash>::HashTable()
- : mSize(DEFAULT_HASH_TABLE_SIZE)
+ : mSize(HASH_TABLE_DEFAULT_SIZE)
, mCount(0) {
- mLists = new List<Pair<Key, T>, Comparator >[(uint32_t) mSize];
+ mLists = new List<Pair<Key, T>, Comparator >[mSize];
}
template <class Key, class T, class C, class Hash>
- HashTable<Key, T, C, Hash>::HashTable(uint64_t size)
+ HashTable<Key, T, C, Hash>::HashTable(uint_t size)
: mCount(0) {
if (size <= 0) {
- mSize = DEFAULT_HASH_TABLE_SIZE;
+ mSize = HASH_TABLE_DEFAULT_SIZE;
} else {
mSize = size;
}
- mLists = new List<Pair<Key, T>, Comparator >[(uint32_t) mSize];
+ mLists = new List<Pair<Key, T>, Comparator >[mSize];
}
template <class Key, class T, class C, class Hash>
@@ -201,9 +201,9 @@ namespace capu {
}
template <class Key, class T, class C, class Hash>
- status_t HashTable<Key, T, C, Hash>::put(const Key &key, T &value, T* value_old) {
+ status_t HashTable<Key, T, C, Hash>::put(const Key &key, const T &value, T* value_old) {
status_t result;
- uint64_t index = Hash::Digest(key) % mSize;
+ uint_t index = Hash::Digest(key) % mSize;
if (mLists[index].isEmpty()) {
Pair<Key, T> pair(key, value);
result = mLists[index].add(pair);
@@ -214,7 +214,7 @@ namespace capu {
//THERE IS NO OLD VALUE
} else {
Pair<Key, T> new_pair(key, value);
- int32_t key_duplicate_index = this->getKeyIndexFromBucket(index, key);
+ int_t key_duplicate_index = this->getKeyIndexFromBucket(index, key);
if (key_duplicate_index < 0) {
result = mLists[index].add(new_pair);
if (result != CAPU_OK) {
@@ -250,9 +250,9 @@ namespace capu {
return CAPU_EINVAL;
status_t result;
- uint64_t index = Hash::Digest(key) % mSize;
+ uint_t index = Hash::Digest(key) % mSize;
- int32_t key_index = this->getKeyIndexFromBucket(index, key);
+ int_t key_index = this->getKeyIndexFromBucket(index, key);
if (key_index < 0) {
return CAPU_ENOT_EXIST;
} else {
@@ -273,9 +273,9 @@ namespace capu {
return CAPU_EINVAL;
}
status_t result;
- uint64_t index = Hash::Digest(key) % mSize;
+ uint_t index = Hash::Digest(key) % mSize;
- int32_t key_index = this->getKeyIndexFromBucket(index, key);
+ int_t key_index = this->getKeyIndexFromBucket(index, key);
if (key_index < 0) {
return CAPU_ERANGE;
} else {
@@ -298,13 +298,13 @@ namespace capu {
}
template <class Key, class T, class C, class Hash>
- uint64_t HashTable<Key, T, C, Hash>::count() {
+ uint_t HashTable<Key, T, C, Hash>::count() {
return mCount;
}
template <class Key, class T, class C, class Hash>
status_t HashTable<Key, T, C, Hash>::clear() {
- for (uint64_t i = 0; i < mSize; ++i) {
+ for (uint_t i = 0; i < mSize; ++i) {
mLists[i].clear();
}
mCount = 0;
@@ -313,18 +313,18 @@ namespace capu {
template <class Key, class T, class C, class Hash>
typename HashTable<Key, T, C, Hash>::Iterator HashTable<Key, T, C, Hash>::begin() {
- return HashTable<Key, T, C, Hash>::Iterator(mLists, mSize);
+ return typename HashTable<Key, T, C, Hash>::Iterator(mLists, mSize);
}
template <class Key, class T, class C, class Hash>
- HashTable<Key, T, C, Hash>::HashTableIterator::HashTableIterator(List<Pair<Key, T> > * list, uint64_t list_size) {
+ HashTable<Key, T, C, Hash>::HashTableIterator::HashTableIterator(List<Pair<Key, T> > * list, uint_t list_size) {
mCurrentListIndex = 0;
this->mList = list;
mMaxListSize = list_size;
this->mCurrentListIterator = list[mCurrentListIndex].begin();
//to point the first non-empty one
- for (uint64_t i = 0; i < list_size; ++i) {
+ for (uint_t i = 0; i < list_size; ++i) {
if (!mList[i].isEmpty()) {
mCurrentListIndex = i;
this->mCurrentListIterator = list[i].begin();
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/List.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/List.h?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/List.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/List.h Thu Aug 2 14:40:08 2012
@@ -97,7 +97,7 @@ namespace capu {
ListNode *mHead;
ListNode *mTail;
- int32_t mSize;
+ int_t mSize;
public:
@@ -132,7 +132,7 @@ namespace capu {
* CAPU_OK if the element is successfully added
* CAPU_ERROR otherwise
*/
- status_t add(int32_t index, const T &element);
+ status_t add(int_t index, const T &element);
/**
* Add element to specified position
@@ -153,7 +153,7 @@ namespace capu {
* @return CAPU_EINVAL invalid index
* CAPU_OK if the element is successfully removed
*/
- status_t removeAt(int32_t index, T* elementOld = NULL);
+ status_t removeAt(int_t index, T* elementOld = NULL);
/**
* remove the element in the specified iterator position and if the element_old
@@ -173,13 +173,13 @@ namespace capu {
* @return CAPU_EINVAL invalid index
* CAPU_OK otherwise
*/
- status_t get(int32_t index, T* result);
+ status_t get(int_t index, T* result);
/**
* return size of list
* @return return the size of list
*/
- int32_t size();
+ int_t size();
/**
* check the list is empty or not
@@ -202,7 +202,7 @@ namespace capu {
* @return -1 if the value either does not exist or given value is NULL
* otherwise index of value on linked list
*/
- int32_t find(const T &element);
+ int_t find(const T &element);
/**
*
@@ -212,7 +212,7 @@ namespace capu {
* @return CAPU_EINVAL if the index is not valid
* CAPU_OK otherwise
*/
- status_t set(int32_t index, const T &element, T* elementOld = NULL);
+ status_t set(int_t index, const T &element, T* elementOld = NULL);
/**
* check that if the list contains the given parameter or not
@@ -263,8 +263,8 @@ namespace capu {
}
template <class T, class C>
- int32_t List<T, C>::find(const T &element) {
- int32_t counter = 0;
+ int_t List<T, C>::find(const T &element) {
+ int_t counter = 0;
ListNode * cursor = mHead;
C comparator;
while (cursor != NULL) {
@@ -308,7 +308,7 @@ namespace capu {
}
template <class T, class C>
- status_t List<T, C>::add(int32_t index, const T &element) {
+ status_t List<T, C>::add(int_t index, const T &element) {
if ((index > mSize) || (index < 0)) {
return CAPU_EINVAL;
}
@@ -320,7 +320,7 @@ namespace capu {
return CAPU_ENO_MEMORY;
}
- int32_t counter = 0;
+ int_t counter = 0;
ListNode * cursor = mHead;
if (cursor == NULL) {
//empty list
@@ -376,6 +376,11 @@ namespace capu {
if (mHead == NULL && mTail == NULL) {
mHead = listElem;
mTail = mHead;
+ } else if (iter.mNextPosition == NULL){
+ listElem->mNext = NULL;
+ listElem->mPrev = mTail;
+ mTail->mNext = listElem;
+ mTail = listElem;
} else if (iter.mNextPosition->mNext == NULL) {
listElem->mNext = NULL;
listElem->mPrev = iter.mNextPosition;
@@ -389,7 +394,7 @@ namespace capu {
listElem->mPrev = iter.mNextPosition->mPrev;
listElem->mNext = iter.mNextPosition;
iter.mNextPosition->mPrev->mNext = listElem;
- }
+ }
iter.mNextPosition = listElem;
++mSize;
@@ -399,7 +404,7 @@ namespace capu {
//remove the specific element indicated by the index in the list
template <class T, class C>
- status_t List<T, C>::removeAt(int32_t index, T* elementOld) {
+ status_t List<T, C>::removeAt(int_t index, T* elementOld) {
if ((index < 0) || (index >= mSize)) {
return CAPU_EINVAL;
}
@@ -419,7 +424,7 @@ namespace capu {
mTail->mNext = NULL;
} else {
tmp = mHead;
- for (int32_t i = 0; i < index; ++i) {
+ for (int_t i = 0; i < index; ++i) {
tmp = tmp->mNext;
}
tmp->mNext->mPrev = tmp->mPrev;
@@ -476,7 +481,7 @@ namespace capu {
//get the specified element from list
template <class T, class C>
- status_t List<T, C>::get(int32_t index, T* result) {
+ status_t List<T, C>::get(int_t index, T* result) {
if (((index < 0) || (index >= mSize)) || (result == NULL)) {
return CAPU_EINVAL;
}
@@ -490,7 +495,7 @@ namespace capu {
}
ListNode *cursor = mHead;
- for (int32_t i = 0; i < index; ++i) {
+ for (int_t i = 0; i < index; ++i) {
cursor = cursor->mNext;
}
*result = cursor->mData;
@@ -498,12 +503,12 @@ namespace capu {
}
template <class T, class C>
- status_t List<T, C>::set(int32_t index, const T &element, T* elementOld) {
+ status_t List<T, C>::set(int_t index, const T &element, T* elementOld) {
if ((index < 0) || (index >= mSize))
return CAPU_EINVAL;
ListNode *cursor = mHead;
- for (int32_t i = 0; i < index; ++i) {
+ for (int_t i = 0; i < index; ++i) {
cursor = cursor->mNext;
}
if (elementOld != NULL)
@@ -515,7 +520,7 @@ namespace capu {
//Return element count of list
template <class T, class C>
- int32_t List<T, C>::size() {
+ int_t List<T, C>::size() {
return mSize;
}
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Queue.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Queue.h?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Queue.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Queue.h Thu Aug 2 14:40:08 2012
@@ -0,0 +1,198 @@
+/* $Id$
+ *
+ * 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 __QUEUE_H__
+#define __QUEUE_H__
+
+#include "capu/Error.h"
+#include "capu/Config.h"
+
+namespace capu {
+
+ template <typename T>
+ class Queue {
+
+ class QueueNode
+ {
+ public:
+ ~QueueNode()
+ {
+ }
+
+ QueueNode() {
+ mNext = NULL;
+ }
+
+ QueueNode(T data) {
+ mNext = NULL;
+ this->mData = data;
+ }
+
+ T mData;
+ QueueNode* mNext;
+ };
+
+ QueueNode* mCurrent;
+ QueueNode* mTail;
+ int_t mSize;
+
+ public:
+
+ /**
+ * Default Constructor
+ */
+ Queue();
+
+ /**
+ * Destructor
+ */
+ virtual ~Queue();
+
+ /**
+ * Add element to the end of list
+ * @param element element that will be added
+ * @return CAPU_ENO_MEMORY if allocation of element is failed
+ * CAPU_OK if the element is successfully added
+ */
+ status_t add(const T &element);
+
+
+ /**
+ * Shifts the iterator to the next position and returns the element if next != NULL
+ * @param element
+ * @return ETCH_ERANGE if the next of current node that is pointed, is null
+ * CAPU_OK if the next element has been gotten
+ *
+ */
+ status_t next(T* element = NULL);
+
+ /**
+ * Check if iterator has next element.
+ * @return false if the next of current node that is pointed, is null otherwise true
+ */
+ bool_t hasNext();
+
+ /**
+ * return size of the queue
+ * @return return the size of list
+ */
+ int_t size();
+
+ /**
+ * check the queue is empty or not
+ * @return true if empty
+ * false otherwise
+ */
+ bool_t isEmpty();
+
+ /**
+ * removes all elements from queue
+ *
+ * @return CAPU_OK if all of the elements are deleted
+ *
+ */
+ status_t clear();
+ };
+
+ template <typename T>
+ Queue<T>::Queue()
+ : mCurrent(NULL), mTail(NULL), mSize(0) {
+ //init queue
+ }
+
+ template <typename T>
+ Queue<T>::~Queue() {
+ clear();
+ }
+
+ template <typename T>
+ status_t Queue<T>::next(T* element) {
+ if (mCurrent->mData == NULL) {
+ return CAPU_ERANGE;
+ }
+
+ T tmp = mCurrent->mData;
+ QueueNode* del = mCurrent;
+ mCurrent = mCurrent->mNext;
+ delete del;
+ --mSize;
+
+ if (element != NULL) {
+ *element = tmp;
+ }
+ return CAPU_OK;
+ }
+
+
+ template <typename T>
+ bool_t Queue<T>::hasNext() {
+ return mCurrent != NULL;
+ }
+
+ template <typename T>
+ int_t Queue<T>::size() {
+ return mSize;
+ }
+
+ template <typename T>
+ status_t Queue<T>::clear() {
+ //on the deallocation delete all elements in the queue
+ while (mCurrent != NULL) {
+ Queue::QueueNode* tmp = mCurrent;
+ mCurrent = mCurrent->mNext;
+ delete tmp;
+ }
+ mSize = 0;
+ return CAPU_OK;
+ }
+
+
+ //add elements to the end of queue
+ template <typename T>
+ status_t Queue<T>::add(const T &element) {
+ Queue::QueueNode *qElem = NULL;
+ qElem = new Queue::QueueNode(element);
+ //NOT ALLOCATED
+ if (qElem == NULL) {
+ return CAPU_ENO_MEMORY;
+ }
+
+ //Queue contains some elements so add it to the end of queue
+ if (mCurrent != NULL) {
+ mTail->mNext = qElem;
+ mTail = qElem;
+ ++mSize;
+ return CAPU_OK;
+ }
+ //Queue is empty
+ mCurrent = qElem;
+ mTail = qElem;
+ ++mSize;
+ return CAPU_OK;
+ }
+
+ //checks if the queue is empty or not
+ template <typename T>
+ bool_t Queue<T>::isEmpty() {
+ return (mSize == 0);
+ }
+}
+
+
+#endif /* __QUEUE_H__ */
+
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/RingBuffer.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/RingBuffer.h?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/RingBuffer.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/RingBuffer.h Thu Aug 2 14:40:08 2012
@@ -0,0 +1,244 @@
+/* $Id$
+ *
+ * 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 __RINGBUFFER_H__
+#define __RINGBUFFER_H__
+
+#include "capu/Config.h"
+#include "capu/Error.h"
+
+namespace capu
+{
+ /*
+ * RingBuffer to store data.
+ * The buffer is not thread-safe!
+ */
+ template<typename T>
+ class RingBuffer
+ {
+ /*
+ * Iterator class.
+ */
+ class RingBufferIterator
+ {
+ public:
+ friend class RingBuffer<T>;
+ RingBufferIterator(RingBuffer<T>* buffer);
+ ~RingBufferIterator();
+ bool_t hasNext();
+ status_t next(T* element);
+ private:
+ uint32_t mCurrentIndex;
+ bool_t mMoved;
+ RingBuffer<T>* mBuffer;
+ };
+
+ public:
+ /*
+ * Used for iterations over the buffer.
+ */
+ typedef typename RingBuffer<T>::RingBufferIterator Iterator;
+
+ /*
+ * Destructor.
+ */
+ virtual ~RingBuffer();
+
+ /*
+ * Gets an iterator to iterate over the buffer.
+ * @return Iterator for iteration over the buffer.
+ */
+ Iterator begin();
+
+ /*
+ * Inserts new data in the buffer.
+ * @param element The element that should get added to the buffer.
+ * @return The status to indicate if the add operation did succeed.
+ */
+ status_t add(const T& element);
+
+ /*
+ * Clears the buffer.
+ * @return The status to indicate if the clear operation did succeed.
+ */
+ status_t clear();
+
+ /*
+ * Gets the size of the buffer. This is not the current fill status.
+ * @return The size of the buffer.
+ */
+ uint32_t size();
+
+ /*
+ * Creates a new ring-base buffer with the specified size.
+ *
+ * @param bufferSize The size of the buffer.
+ */
+ RingBuffer(uint32_t bufferSize);
+
+ private:
+ uint32_t mStart;
+ uint32_t mEnd;
+ uint32_t mBufferSize;
+ bool_t mEmpty;
+ T* mData; // we use a backing array for the ring buffer
+
+ /*
+ * Helper function to increase an index so that the new index is always inside the array bounds.
+ * @param index The index that should get increased.
+ */
+ void increase(uint32_t& index);
+
+ /*
+ * Helper function to determine if the buffer is full.
+ * @return True if the buffer is full, false otherwise.
+ */
+ bool_t isFull();
+ };
+
+ template<typename T>
+ inline RingBuffer<T>::RingBuffer(uint32_t bufferSize)
+ : mStart(0)
+ , mEnd(0)
+ , mBufferSize(bufferSize)
+ , mEmpty(true)
+ , mData(new T[bufferSize])
+ {
+ }
+
+ template<typename T>
+ inline RingBuffer<T>::~RingBuffer()
+ {
+ delete[] mData;
+ }
+
+ template<typename T>
+ inline bool_t RingBuffer<T>::isFull()
+ {
+ return mStart == mEnd && !mEmpty;
+ }
+
+ template<typename T>
+ inline void RingBuffer<T>::increase(uint32_t& index)
+ {
+ index = (index + 1) % mBufferSize;
+ }
+
+ template<typename T>
+ inline uint32_t RingBuffer<T>::size()
+ {
+ return mBufferSize;
+ }
+
+ template<typename T>
+ inline status_t RingBuffer<T>::add(const T& element)
+ {
+ if (mBufferSize == 0)
+ {
+ // special case of a zero buffer size
+ return CAPU_ERANGE;
+ }
+
+ mData[mEnd] = element; // write operation into the buffer
+
+ if(isFull())
+ {
+ // only increase 'start pointer' if the buffer is full
+ increase(mStart);
+ }
+ increase(mEnd);
+ mEmpty = false;
+
+ return CAPU_OK;
+ }
+
+ template<typename T>
+ inline status_t RingBuffer<T>::clear()
+ {
+ mStart = 0;
+ mEnd = 0;
+ mEmpty = true;
+ return CAPU_OK;
+ }
+
+ template<typename T>
+ inline typename RingBuffer<T>::Iterator RingBuffer<T>::begin()
+ {
+ return RingBufferIterator(this);
+ }
+
+ template<typename T>
+ inline RingBuffer<T>::RingBufferIterator::RingBufferIterator(RingBuffer<T>* buffer)
+ : mCurrentIndex(buffer->mStart),
+ mMoved(false),
+ mBuffer(buffer)
+
+ {
+ // note: we could use a modification-counter on the RingBuffer to detect concurrent modifications
+ }
+
+ template<typename T>
+ inline RingBuffer<T>::RingBufferIterator::~RingBufferIterator()
+ {
+ }
+
+ template<typename T>
+ inline bool_t RingBuffer<T>::RingBufferIterator::hasNext()
+ {
+ if(mBuffer->mEmpty)
+ {
+ // empty buffer has no next element
+ return false;
+ }
+ if(mCurrentIndex == mBuffer->mEnd)
+ {
+ // pointing to end in an non-empty buffer: we are finished if we did move once!
+ return !mMoved;
+ }
+
+ // buffer is not empty and we're not pointing to the end: iteration can continue
+ return true;
+ }
+
+ template<typename T>
+ inline status_t RingBuffer<T>::RingBufferIterator::next(T* element)
+ {
+ if (!element)
+ {
+ // user did not provide any memory space for the next element
+ return CAPU_ENO_MEMORY;
+ }
+ if (!hasNext())
+ {
+ // note: 'hasNext' is probably called twice:
+ // while(it.hasNext()) <- call in client code
+ // it.next(&curr); <- call to 'hasNext' in 'next' method (this method)
+ // can we ignore that?
+ // but if we do not check here, we cannot know if there is a next element.
+ return CAPU_ENOT_EXIST;
+ }
+
+ mMoved = true;
+ *element = mBuffer->mData[mCurrentIndex]; // assignment operation from the buffer
+ mBuffer->increase(mCurrentIndex); // increase iteration index
+
+ return CAPU_OK;
+ }
+
+}
+
+#endif //__RINGBUFFER_H__
\ No newline at end of file
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/CondVar.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/CondVar.h?rev=1368491&r1=1368490&r2=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/CondVar.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/CondVar.h Thu Aug 2 14:40:08 2012
@@ -1,75 +1,76 @@
-/* $Id$
- *
- * 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 __CONDVAR_H__
-#define __CONDVAR_H__
-
-#include "capu/Config.h"
-#include "capu/Error.h"
-#include "capu/os/Mutex.h"
-
-#define CONDVAR_INC_HEADER
-#include "arch/CondVar.inc"
-#undef CONDVAR_INC_HEADER
-
-namespace capu
-{
- class CondVar
- {
- #define CONDVAR_INC_MEMBER
- #include "arch/CondVar.inc"
- #undef CONDVAR_INC_MEMBER
-
- public:
-
- inline CondVar();
-
- ~CondVar();
-
- /**
- * Wake up single thread that is waiting for this condition variable
- * @return CAPU_OK if the condition variable is correctly signaled
- * CAPU_ERROR otherwise
- */
- inline status_t signal();
-
- /**
- * Wait for a condition variable
- * @param mutex
- * @return CAPU_OK if the condition variable is correctly waited
- * CAPU_EINVAL if the given mutex is NULL
- * CAPU_ERROR otherwise
- */
- inline status_t wait(Mutex *mutex);
-
- /**
- * Wake up all threads that is waiting for this condition variable
- * @return CAPU_OK if the condition variable is correctly broadcasted
- * CAPU_ERROR otherwise
- */
- inline status_t broadcast();
-
- };
-
-#define CONDVAR_INC_IMPL
- #include "arch/CondVar.inc"
-#undef CONDVAR_INC_IMPL
-
-}
-#endif
-
+/* $Id$
+ *
+ * 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 __CONDVAR_H__
+#define __CONDVAR_H__
+
+#include "capu/Config.h"
+#include "capu/Error.h"
+#include "capu/os/Mutex.h"
+
+#define CONDVAR_INC_HEADER
+#include "arch/CondVar.inc"
+#undef CONDVAR_INC_HEADER
+
+namespace capu
+{
+ class CondVar
+ {
+ #define CONDVAR_INC_MEMBER
+ #include "arch/CondVar.inc"
+ #undef CONDVAR_INC_MEMBER
+
+ public:
+
+ inline CondVar();
+
+ ~CondVar();
+
+ /**
+ * Wake up single thread that is waiting for this condition variable
+ * @return CAPU_OK if the condition variable is correctly signaled
+ * CAPU_ERROR otherwise
+ */
+ inline status_t signal();
+
+ /**
+ * Wait for a condition variable
+ * @param mutex
+ * @param timeout (default is infinite)
+ * @return CAPU_OK if the condition variable is correctly waited
+ * CAPU_EINVAL if the given mutex is NULL
+ * CAPU_ERROR otherwise
+ */
+ inline status_t wait(Mutex *mutex, uint32_t millisec = 0);
+
+ /**
+ * Wake up all threads that is waiting for this condition variable
+ * @return CAPU_OK if the condition variable is correctly broadcasted
+ * CAPU_ERROR otherwise
+ */
+ inline status_t broadcast();
+
+ };
+
+#define CONDVAR_INC_IMPL
+ #include "arch/CondVar.inc"
+#undef CONDVAR_INC_IMPL
+
+}
+#endif
+
Copied: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Debug.h (from r1368489, incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h)
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Debug.h?p2=incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Debug.h&p1=incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h&r1=1368489&r2=1368491&rev=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Debug.h Thu Aug 2 14:40:08 2012
@@ -16,27 +16,34 @@
* limitations under the License.
*/
-#ifndef __COMPARATOR_H__
-#define __COMPARATOR_H__
+#ifndef __DEBUG_H__
+#define __DEBUG_H__
#include "capu/Config.h"
+#include "capu/Error.h"
-namespace capu {
+#define DEBUG_INC_HEADER
+#include "arch/Debug.inc"
+#undef DEBUG_INC_HEADER
+
+namespace capu
+{
+ class Debug
+ {
+ #define DEBUG_INC_MEMBER
+ #include "arch/Debug.inc"
+ #undef DEBUG_INC_MEMBER
- class Comparator {
-
public:
- template <class T>
- bool_t operator () (const T &x, const T &y) const {
- return x == y;
- }
-
- bool_t operator () (const char* x, const char* y) const {
- return (strcmp(x,y) == 0);
- }
+
+ static void Assert(bool condition);
};
-}
-#endif /* COMPARATOR_H */
+#define DEBUG_INC_IMPL
+ #include "arch/Debug.inc"
+#undef DEBUG_INC_IMPL
+
+}
+#endif
Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Math.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Math.h?rev=1368491&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Math.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Math.h Thu Aug 2 14:40:08 2012
@@ -0,0 +1,73 @@
+/* $Id$
+ *
+ * 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 __MATH_H__
+#define __MATH_H__
+
+#include "capu/Config.h"
+
+#define MATH_INC_HEADER
+#include "arch/Math.inc"
+#undef MATH_INC_HEADER
+
+namespace capu {
+
+ class Math {
+ #define MATH_INC_MEMBER
+ #include "arch/Math.inc"
+ #undef MATH_INC_MEMBER
+
+ public:
+ static float_t Ceil(float_t val);
+ static double_t Ceil(double_t val);
+ static float_t Floor(float_t val);
+ static double_t Floor(double_t val);
+ static float_t Abs(float_t val);
+ static double_t Abs(double_t val);
+ static int_t Abs(int_t val);
+ static float_t Sqrt(float_t val);
+ static double_t Sqrt(double_t val);
+ static float_t Pow2(float_t val);
+ static double_t Pow2(double_t val);
+ static float_t Pow(float_t val, float_t exponent);
+ static double_t Por(double_t val, double_t exponent);
+ static float_t Cos(float_t val);
+ static double_t Cos(double_t val);
+ static float_t Sin(float_t val);
+ static double_t Sin(double_t val);
+ static float_t Tan(float_t val);
+ static double_t Tan(double_t val);
+ static float_t ArcCos(float_t val);
+ static double_t ArcCos(double_t val);
+ static float_t ArcSin(float_t val);
+ static double_t ArcSin(double_t val);
+ static float_t ArcTan(float_t val);
+ static double_t ArcTan(double_t val);
+ static float_t Rad2Deg(float_t val);
+ static double_t Rad2Deg(double_t val);
+ static float_t Deg2Rad(float_t val);
+ static double_t Deg2Rad(double_t val);
+ };
+
+
+#define MATH_INC_IMPL
+#include "arch/Math.inc"
+#undef MATH_INC_IMPL
+
+}
+
+#endif
\ No newline at end of file
Copied: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Memory.h (from r1368489, incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h)
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Memory.h?p2=incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Memory.h&p1=incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h&r1=1368489&r2=1368491&rev=1368491&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/os/Memory.h Thu Aug 2 14:40:08 2012
@@ -16,27 +16,36 @@
* limitations under the License.
*/
-#ifndef __COMPARATOR_H__
-#define __COMPARATOR_H__
+#ifndef __MEMORY_H__
+#define __MEMORY_H__
#include "capu/Config.h"
+#include "capu/Error.h"
-namespace capu {
+#define MEMORY_INC_HEADER
+#include "arch/Memory.inc"
+#undef MEMORY_INC_HEADER
+
+namespace capu
+{
+ class Memory
+ {
+ #define MEMORY_INC_MEMBER
+ #include "arch/Memory.inc"
+ #undef MEMORY_INC_MEMBER
- class Comparator {
-
public:
- template <class T>
- bool_t operator () (const T &x, const T &y) const {
- return x == y;
- }
-
- bool_t operator () (const char* x, const char* y) const {
- return (strcmp(x,y) == 0);
- }
+ inline static void Set (void* dst, int32_t val , uint_t size);
+ inline static void Copy(void* dst, const void* src, uint_t size);
+ inline static void Move(void* dst, const void* src, uint_t size);
+ inline static int32_t Compare(const void* ptr1, const void* ptr2, uint_t num);
};
-}
-#endif /* COMPARATOR_H */
+#define MEMORY_INC_IMPL
+ #include "arch/Memory.inc"
+#undef MEMORY_INC_IMPL
+
+}
+#endif