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/06/01 14:31:50 UTC
svn commit: r1345118 - in /incubator/etch/trunk/binding-cpp/runtime:
include/common/EtchDate.h lib/capu/modules/capu/include/capu/Config.h
src/main/CMakeLists.txt src/main/common/EtchDate.cpp
src/test/CMakeLists.txt src/test/common/EtchDateTest.cpp
Author: veithm
Date: Fri Jun 1 12:31:49 2012
New Revision: 1345118
URL: http://svn.apache.org/viewvc?rev=1345118&view=rev
Log:
ETCH-150 Implementation of basic primitive data types for the NSDL
EtchDate has been implemented
Change-Id: I3bdf8138a7a2cb30ab65b099c5e2ba4f353d2cba
Added:
incubator/etch/trunk/binding-cpp/runtime/include/common/EtchDate.h
incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchDate.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/common/EtchDateTest.cpp
Modified:
incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Config.h
incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt
Added: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchDate.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchDate.h?rev=1345118&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchDate.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchDate.h Fri Jun 1 12:31:49 2012
@@ -0,0 +1,64 @@
+/* $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 ETCHDATE_H
+#define ETCHDATE_H
+#include "common/EtchObject.h"
+#include "common/EtchObjectType.h"
+#include <time.h>
+
+class EtchDate : public EtchObject {
+public:
+
+ /**
+ * EtchObjectType for EtchDate.
+ */
+ static const EtchObjectType* TYPE();
+
+ //Constructor
+ EtchDate();
+
+ //Destructor
+ virtual ~EtchDate();
+
+ //overridden
+ capu::bool_t equals(const EtchObject* other) const;
+
+ /**
+ * Sets time value.
+ */
+ void set(capu::time_t value);
+
+ /**
+ * Returns time value.
+ */
+ capu::time_t get();
+
+ /**
+ * Returns hash code
+ */
+ capu::uint64_t getHashCode() const;
+
+private:
+
+ capu::time_t mValue;
+
+};
+
+#endif /* ETCHDATE_H */
+
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=1345118&r1=1345117&r2=1345118&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 Fri Jun 1 12:31:49 2012
@@ -43,6 +43,7 @@ namespace capu
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;
@@ -55,6 +56,7 @@ namespace capu
typedef float float_t;
typedef double double_t;
typedef bool bool_t;
+ typedef int64_t time_t;
#endif //_WIN32
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt?rev=1345118&r1=1345117&r2=1345118&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt Fri Jun 1 12:31:49 2012
@@ -61,6 +61,7 @@ SET(MAIN_INCLUDES
${PROJECT_SOURCE_DIR}/include/common/EtchException.h
${PROJECT_SOURCE_DIR}/include/common/EtchAuthenticationException.h
${PROJECT_SOURCE_DIR}/include/common/EtchRuntimeException.h
+ ${PROJECT_SOURCE_DIR}/include/common/EtchDate.h
${PROJECT_SOURCE_DIR}/include/transport/EtchTcpConnection.h
${PROJECT_SOURCE_DIR}/include/transport/EtchTcpListener.h
${PROJECT_SOURCE_DIR}/include/transport/EtchTcpOption.h
@@ -112,6 +113,7 @@ SET(MAIN_SOURCES
common/EtchException.cpp
common/EtchAuthenticationException.cpp
common/EtchRuntimeException.cpp
+ common/EtchDate.cpp
util/EtchURL.cpp
util/EtchResources.cpp
transport/EtchFlexBuffer.cpp
Added: incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchDate.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchDate.cpp?rev=1345118&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchDate.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/common/EtchDate.cpp Fri Jun 1 12:31:49 2012
@@ -0,0 +1,54 @@
+/* $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.
+ */
+
+#include "common/EtchDate.h"
+
+const EtchObjectType* EtchDate::TYPE() {
+ const static EtchObjectType TYPE(EOTID_DATE, NULL);
+ return &TYPE;
+}
+
+EtchDate::EtchDate()
+: EtchObject(EtchDate::TYPE()), mValue(0) {
+}
+
+EtchDate::~EtchDate() {
+
+}
+
+capu::bool_t EtchDate::equals(const EtchObject* other) const{
+ if (other == NULL) {
+ return false;
+ } else if (other->getObjectType() != EtchDate::TYPE()) {
+ return false;
+ }
+ EtchDate *tmp = (EtchDate *) other;
+ return tmp->mValue == this->mValue;
+}
+
+capu::time_t EtchDate::get() {
+ return mValue;
+}
+
+void EtchDate::set(capu::time_t value) {
+ mValue = value;
+}
+
+capu::uint64_t EtchDate::getHashCode() const{
+ return mValue;
+}
\ No newline at end of file
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt?rev=1345118&r1=1345117&r2=1345118&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt Fri Jun 1 12:31:49 2012
@@ -45,6 +45,7 @@ add_executable (etch-cpp-test
common/EtchExceptionTest.cpp
common/EtchAuthenticationExceptionTest.cpp
common/EtchRuntimeExceptionTest.cpp
+ common/EtchDateTest.cpp
util/EtchURLTest.cpp
util/EtchResourcesTest.cpp
transport/EtchFlexBufferTest.cpp
Added: incubator/etch/trunk/binding-cpp/runtime/src/test/common/EtchDateTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/common/EtchDateTest.cpp?rev=1345118&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/common/EtchDateTest.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/common/EtchDateTest.cpp Fri Jun 1 12:31:49 2012
@@ -0,0 +1,52 @@
+/* $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.
+ */
+
+#include <gtest/gtest.h>
+#include "common/EtchDate.h"
+
+TEST(EtchDateTest, Constructor) {
+ EtchDate* i1 = new EtchDate();
+ EXPECT_TRUE(i1->getObjectType() == EtchDate::TYPE());
+ delete i1;
+}
+
+TEST(EtchDateTest, set) {
+ EtchDate* i1 = new EtchDate();
+ i1->set(1234567);
+ EXPECT_TRUE(i1->get() == 1234567);
+ delete i1;
+}
+
+TEST(EtchDateTest, get) {
+ EtchDate* i1 = new EtchDate();
+ time_t _time;
+ time(&_time);
+ i1->set(_time);
+ EXPECT_TRUE(i1->get() == _time);
+ delete i1;
+}
+
+TEST(EtchDateTest, equals) {
+ EtchDate i1, i2;
+ time_t _time = 1234567;
+ i1.set(_time);
+ i2.set(41);
+ EXPECT_TRUE(i1.equals(&i2) == false);
+ i2.set(_time);
+ EXPECT_TRUE(i1.equals(&i2) == true);
+}