You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by fi...@apache.org on 2012/06/01 13:38:32 UTC
svn commit: r1345074 - in /incubator/etch/trunk/binding-cpp/runtime:
include/common/ include/serialization/ src/main/ src/main/serialization/
Author: fitzner
Date: Fri Jun 1 11:38:32 2012
New Revision: 1345074
URL: http://svn.apache.org/viewvc?rev=1345074&view=rev
Log:
ETCH-184 Interfaces of EtchValueFactory and EtchImportExportHelper
Change-Id: Id315807b90bbc3ea608254fb278fe67b442006c5
Added:
incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchImportExportHelper.h
incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchValueFactory.cpp
Modified:
incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h
incubator/etch/trunk/binding-cpp/runtime/src/main/CMakeLists.txt
Modified: incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h?rev=1345074&r1=1345073&r2=1345074&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/common/EtchObjectType.h Fri Jun 1 11:38:32 2012
@@ -51,6 +51,7 @@ enum EtchObjectTypeIds {
EOTID_VALIDATOR_OBJECT,
EOTID_FIELD,
EOTID_OBJECT,
+ EOTID_VALUE_FACTORY,
EOTID_NATIVE_INT8,
EOTID_NATIVE_INT16,
Added: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchImportExportHelper.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchImportExportHelper.h?rev=1345074&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchImportExportHelper.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchImportExportHelper.h Fri Jun 1 11:38:32 2012
@@ -0,0 +1,62 @@
+/* $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 __ETCHIMPORTEXPORTHELPER_H__
+#define __ETCHIMPORTEXPORTHELPER_H__
+#include "serialization/EtchValueFactory.h"
+
+class EtchStructValue;
+
+/**
+ * Interface used to implement ValueFactory based import / export code
+ * for service defined types.
+ */
+class EtchImportExportHelper {
+public:
+
+ /**
+ * Destructor
+ */
+ virtual ~EtchImportExportHelper() {
+ }
+
+ /**
+ * Exports a value by creating an equivalent StructValue.
+ * @param vf the value factory for this connection.
+ * @param value a service defined type to export.
+ * @param result as out parameter where the exported value will be stored.
+ * @return ETCH_OK if successfully exported
+ * ETCH_EINVAL if it is locked
+ * ETCH_ERROR otherwise
+ */
+ virtual status_t exportValue(EtchValueFactory* vf, capu::SmartPointer<EtchObject> value, EtchStructValue *&result) = 0;
+
+ /**
+ * Imports a value from an equivalent StructValue.
+ * @param struct a StructValue representing the exported value.
+ * @param result as out parameter where the imported value will be stored.
+ * @return ETCH_OK if successfully imported
+ * ETCH_EINVAL if it is locked
+ * ETCH_ERROR otherwise
+ */
+ virtual status_t importValue(EtchStructValue* value, capu::SmartPointer<EtchObject> &result) = 0;
+
+};
+
+#endif /* ETCHIMPORTEXPORTHELPER_H */
+
Added: incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h?rev=1345074&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/include/serialization/EtchValueFactory.h Fri Jun 1 11:38:32 2012
@@ -0,0 +1,218 @@
+/* $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 __ETCHVALUEFACTORY_H__
+#define __ETCHVALUEFACTORY_H__
+
+
+#include "serialization/EtchLevel.h"
+#include "common/EtchString.h"
+#include "serialization/EtchField.h"
+#include "capu/util/SmartPointer.h"
+
+class EtchStructValue;
+class EtchMessage;
+class EtchType;
+
+/**
+ * Interface which defines the value factory which helps
+ * the idl compiler serialize and deserialize messages,
+ * convert values, etc.
+ */
+
+
+class EtchValueFactory : public EtchObject {
+public:
+
+ /**
+ * TypeID
+ */
+ static const EtchObjectType TYPE;
+
+ /**
+ * Default Constructor
+ */
+ EtchValueFactory();
+
+ /**
+ * Destructor
+ */
+ virtual ~EtchValueFactory() {
+
+ }
+
+ /**
+ * Translates a type id into the appropriate Type object. If the type does
+ * not exist, and if dynamic typing is enabled, adds it to the dynamic types.
+ * @param id a type id.
+ * @param result a output buffer.
+ */
+ virtual status_t getType(capu::uint32_t id, EtchType *&result) = 0;
+
+ /**
+ * Translates a type name into the appropriate Type object. If the type does
+ * not exist, and if dynamic typing is enabled, adds it to the dynamic types.
+ * @param name a type name.
+ * @param result a output buffer.
+ */
+ virtual status_t getType(EtchString &name, EtchType *&result) = 0;
+
+ /**
+ * Adds the type if it doesn't already exist. Use this to dynamically add
+ * types to a ValueFactory. The type is per instance of the ValueFactory,
+ * not global. Not available if dynamic typing is locked.
+ * @param type
+ */
+ virtual status_t addType(EtchType *type) = 0;
+
+ /**
+ * Locks the dynamic typing so that no new types may be created by addType
+ * or getType.
+ */
+ virtual status_t lockDynamicTypes() = 0;
+
+ /**
+ * Unlocks the dynamic typing so that new types may be created by addType
+ * or getType.
+ */
+ virtual status_t unlockDynamicTypes() = 0;
+
+
+ ////////////////
+ // MESSAGE ID //
+ ////////////////
+
+ /**
+ * @param msg the message whose well-known message-id field is to be
+ * returned.
+ * @param the value of the well-known message-id field. This is a
+ * unique identifier for this message on a particular transport
+ * during a particular session. If there is no well-known message-id
+ * field defined, or if the message-id field has not been set, then
+ * return null.
+ * @return ETCH_OK if successfully getted
+ * ETCH_EINVAL if msg is null
+ * ETCH_ERROR if it is not found
+ */
+ virtual status_t getMessageId(EtchMessage *msg, capu::int64_t &result) = 0;
+
+ /**
+ * Sets the value of the well-known message-id field. This is a
+ * unique identifier for this message on a particular transport
+ * during a particular session. If there is no well-known message-id
+ * field defined then nothing is done. If msgid is null, then the
+ * field is cleared.
+ * @param msg the message whose well-known message-id field is to
+ * be set.
+ * @param msgid the value of the well-known message-id field.
+ * @return ETCH_EINVAL if msg is null
+ * ETCH_OK otherwise
+ */
+ virtual status_t setMessageId(EtchMessage *msg, capu::int64_t msgid) = 0;
+
+ /**
+ * @return well-known message field for message id.
+ */
+ virtual EtchField get_mf__messageId() = 0;
+
+ /////////////////
+ // IN REPLY TO //
+ /////////////////
+
+ /**
+ * @param msg the message whose well-known in-reply-to field is to
+ * be returned.
+ * @param result output buffer
+ * @return ETCH_OK if successfully getted
+ * ETCH_EINVAL if msg is null
+ * ETCH_ERROR if it is not found
+ */
+ virtual status_t getInReplyTo(EtchMessage *msg, capu::int64_t &result) = 0;
+
+ /**
+ * @param msg the message whose well-known in-reply-to field is to
+ * be set.
+ * @param msgid the value of the well-known in-reply-to field. If
+ * there is no well-known in-reply-to field defined then nothing
+ * is done. If msgid is null, then the field is cleared.
+ * @return ETCH_EINVAL if msg is null
+ * ETCH_OK otherwise
+ */
+ virtual status_t setInReplyTo(EtchMessage *msg, capu::int64_t msgid) = 0;
+
+ /**
+ * @return well-known message field for in reply to.
+ */
+ virtual EtchField get_mf__inReplyTo() = 0;
+
+ //////////////////////
+ // VALUE CONVERSION //
+ //////////////////////
+
+ /**
+ * Converts a value to a struct value representation to be exported
+ * to a tagged data output.
+ * @param value a custom type defined by a service, or a well-known
+ * @param result buffer to store result which contains a struct value representing the value.
+ * standard type (e.g., date).
+ * @return ETCH_ERROR if the type cannot be exported.
+ * ETCH_OK otherwise
+ */
+ virtual status_t exportCustomValue(capu::SmartPointer<EtchObject> value, EtchStructValue *&result) = 0;
+
+ /**
+ * Converts a struct value imported from a tagged data input to
+ * a normal type.
+ * @param value a struct value representation of a custom type, or a well known standard type.
+ * @param result buffer to store result which contains a custom type, or a well known standard type.
+ * @return ETCH_ERROR if the type cannot be imported.
+ * ETCH_OK otherwise
+ */
+ virtual status_t importCustomValue(EtchStructValue* value, capu::SmartPointer<EtchObject> &result) = 0;
+
+ /**
+ * @param c the class of a custom value.
+ * @param type the class of a custom value.
+ * @return ETCH_OK if the type is found correctly.
+ * ETCH_EINVAL otherwise
+ */
+ virtual status_t getCustomStructType(capu::int32_t c, EtchType *&type) = 0;
+
+ /**
+ * @return well-known message type for exception thrown by one-way
+ * message.
+ */
+ virtual EtchType* get_mt__exception() = 0;
+
+ /**
+ * @return the validation level of field StructValue.put and TaggedDataOutput
+ */
+ virtual EtchLevel getLevel() = 0;
+
+ /**
+ * Sets the validation level of field StructValue.put and TaggedDataOutput
+ * @param level
+ * @return the old value
+ */
+ virtual EtchLevel setLevel(EtchLevel level) = 0;
+
+};
+
+#endif /* ETCHVALUEFACTORY_H */
+
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=1345074&r1=1345073&r2=1345074&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 11:38:32 2012
@@ -35,7 +35,7 @@ SET(MAIN_INCLUDES
${PROJECT_SOURCE_DIR}/include/common/EtchComparatorNative.h
${PROJECT_SOURCE_DIR}/include/common/EtchConfig.h
${PROJECT_SOURCE_DIR}/include/common/EtchError.h
- ${PROJECT_SOURCE_DIR}/include/common/EtchObjectHash.h
+ ${PROJECT_SOURCE_DIR}/include/common/EtchObjectHash.h
${PROJECT_SOURCE_DIR}/include/common/EtchHashNative.h
${PROJECT_SOURCE_DIR}/include/common/EtchHashTable.h
${PROJECT_SOURCE_DIR}/include/common/EtchHashSet.h
@@ -45,7 +45,7 @@ SET(MAIN_INCLUDES
${PROJECT_SOURCE_DIR}/include/common/EtchServerSocket.h
${PROJECT_SOURCE_DIR}/include/util/EtchURL.h
${PROJECT_SOURCE_DIR}/include/util/EtchResources.h
- ${PROJECT_SOURCE_DIR}/include/util/EtchHash.h
+ ${PROJECT_SOURCE_DIR}/include/util/EtchHash.h
${PROJECT_SOURCE_DIR}/include/transport/EtchFlexBuffer.h
${PROJECT_SOURCE_DIR}/include/transport/EtchSession.h
${PROJECT_SOURCE_DIR}/include/transport/EtchSessionData.h
@@ -77,6 +77,8 @@ SET(MAIN_INCLUDES
${PROJECT_SOURCE_DIR}/include/serialization/EtchField.h
${PROJECT_SOURCE_DIR}/include/serialization/EtchValidatorObject.h
${PROJECT_SOURCE_DIR}/include/serialization/EtchFieldMap.h
+ ${PROJECT_SOURCE_DIR}/include/serialization/EtchValueFactory.h
+ ${PROJECT_SOURCE_DIR}/include/serialization/EtchImportExportHelper.h
${PROJECT_SOURCE_DIR}/include/util/EtchUtil.h
)
@@ -115,6 +117,7 @@ SET(MAIN_SOURCES
serialization/EtchField.cpp
serialization/EtchValidatorObject.cpp
serialization/EtchFieldMap.cpp
+ serialization/EtchValueFactory.cpp
util/EtchUtil.cpp
)
Added: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchValueFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchValueFactory.cpp?rev=1345074&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchValueFactory.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchValueFactory.cpp Fri Jun 1 11:38:32 2012
@@ -0,0 +1,25 @@
+/* $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 "serialization/EtchValueFactory.h"
+
+const EtchObjectType EtchValueFactory::TYPE(EOTID_VALUE_FACTORY, NULL);
+
+EtchValueFactory::EtchValueFactory()
+: EtchObject(&EtchValueFactory::TYPE) {
+}