[PATCH 2.3.1 1/5] MAMAC: Complete support of Vector Bool and Vector Char field types.


Alireza Assadzadeh <Alireza.Assadzadeh@...>
 

Add enumerator for Vector Bool and Vector Char for mamaFieldType and
complete the corresponding changes in MAMAC for using these two types.

Signed-off-by: Alireza Assadzadeh <Alireza.Assadzadeh@solacesystems.com>
---

I have raised bug http://bugs.openmama.org/show_bug.cgi?id=168 to track
this issue and attached the patches to the bug.

The patches are against 'next' branch. They are tested by using gunittests,
and sample programs (capturereplayc, mamalistenc and bookticker).

mama/c_cpp/src/c/dictionary.c | 8 +++
mama/c_cpp/src/c/fieldcache/fieldcachefield.c | 82 ++++++++++++++++++++++
mama/c_cpp/src/c/fieldcache/fieldcacheimpl.c | 42 +++++++++++
mama/c_cpp/src/c/fielddesc.c | 8 +++
mama/c_cpp/src/c/mama/fieldcache/fieldcachefield.h | 65 +++++++++++++++++
mama/c_cpp/src/c/mama/fielddesc.h | 2 +
mama/c_cpp/src/c/msgfield.c | 18 +++++
7 files changed, 225 insertions(+)

diff --git a/mama/c_cpp/src/c/dictionary.c b/mama/c_cpp/src/c/dictionary.c
index 7f7d605..effa28a 100644
--- a/mama/c_cpp/src/c/dictionary.c
+++ b/mama/c_cpp/src/c/dictionary.c
@@ -952,6 +952,8 @@ void populateMessageFromDictionary (mamaDictionaryImpl* impl,
int i = 0;
mama_status status = MAMA_STATUS_OK;

+ const mama_bool_t bool_vector[] = {0};
+ const char char_vector[] = {' '};
const mama_i8_t i8_vector[] = {1};
const mama_u8_t u8_vector[] = {1};
const mama_i16_t i16_vector[] = {1};
@@ -1048,6 +1050,12 @@ void populateMessageFromDictionary (mamaDictionaryImpl* impl,
case MAMA_FIELD_TYPE_PRICE:
ADD_TO_DICT (Price, price);
break;
+ case MAMA_FIELD_TYPE_VECTOR_BOOL:
+ ADD_VECTOR_TO_DICT (Bool, bool_vector);
+ break;
+ case MAMA_FIELD_TYPE_VECTOR_CHAR:
+ ADD_VECTOR_TO_DICT (Char, char_vector);
+ break;
case MAMA_FIELD_TYPE_VECTOR_I8:
ADD_VECTOR_TO_DICT (I8, i8_vector);
break;
diff --git a/mama/c_cpp/src/c/fieldcache/fieldcachefield.c b/mama/c_cpp/src/c/fieldcache/fieldcachefield.c
index 43a3c05..89389fd 100644
--- a/mama/c_cpp/src/c/fieldcache/fieldcachefield.c
+++ b/mama/c_cpp/src/c/fieldcache/fieldcachefield.c
@@ -273,6 +273,22 @@ mamaFieldCacheField_copy(const mamaFieldCacheField field, mamaFieldCacheField co
mamaFieldCacheField_setDateTime(copy, value);
break;
}
+ case MAMA_FIELD_TYPE_VECTOR_BOOL:
+ {
+ const mama_bool_t* values = NULL;
+ mama_size_t size;
+ mamaFieldCacheField_getBoolVector(field, &values, &size);
+ mamaFieldCacheField_setBoolVector(copy, values, size);
+ break;
+ }
+ case MAMA_FIELD_TYPE_VECTOR_CHAR:
+ {
+ const char* values = NULL;
+ mama_size_t size;
+ mamaFieldCacheField_getCharVector(field, &values, &size);
+ mamaFieldCacheField_setCharVector(copy, values, size);
+ break;
+ }
case MAMA_FIELD_TYPE_VECTOR_I8:
{
const mama_i8_t* values = NULL;
@@ -728,6 +744,40 @@ mama_status mamaFieldCacheField_getDateTime(const mamaFieldCacheField field,
return MAMA_STATUS_OK;
}

+mama_status mamaFieldCacheField_getBoolVector(const mamaFieldCacheField field,
+ const mama_bool_t** values,
+ mama_size_t* size)
+{
+ if (!field || !values || !size)
+ {
+ return MAMA_STATUS_NULL_ARG;
+ }
+ if (field->mType != MAMA_FIELD_TYPE_VECTOR_BOOL)
+ {
+ return MAMA_STATUS_INVALID_ARG;
+ }
+ *values = (mama_bool_t*)field->mData.data; /* NOT COPYING */
+ *size = field->mVectorSize;
+ return MAMA_STATUS_OK;
+}
+
+mama_status mamaFieldCacheField_getCharVector(const mamaFieldCacheField field,
+ const char** values,
+ mama_size_t* size)
+{
+ if (!field || !values || !size)
+ {
+ return MAMA_STATUS_NULL_ARG;
+ }
+ if (field->mType != MAMA_FIELD_TYPE_VECTOR_CHAR)
+ {
+ return MAMA_STATUS_INVALID_ARG;
+ }
+ *values = (char*)field->mData.data; /* NOT COPYING */
+ *size = field->mVectorSize;
+ return MAMA_STATUS_OK;
+}
+
mama_status mamaFieldCacheField_getI8Vector(const mamaFieldCacheField field,
const mama_i8_t** values,
mama_size_t* size)
@@ -1223,6 +1273,38 @@ mama_status mamaFieldCacheField_setDateTime(const mamaFieldCacheField field,
return MAMA_STATUS_OK;
}

+mama_status mamaFieldCacheField_setBoolVector(const mamaFieldCacheField field,
+ const mama_bool_t* values,
+ mama_size_t size)
+{
+ if (!field || !values)
+ {
+ return MAMA_STATUS_NULL_ARG;
+ }
+ if (field->mType != MAMA_FIELD_TYPE_VECTOR_BOOL)
+ {
+ return MAMA_STATUS_INVALID_ARG;
+ }
+ field->mVectorSize = size;
+ return mamaFieldCacheField_setDataValue(field, values, size * sizeof(mama_bool_t));
+}
+
+mama_status mamaFieldCacheField_setCharVector(const mamaFieldCacheField field,
+ const char* values,
+ mama_size_t size)
+{
+ if (!field || !values)
+ {
+ return MAMA_STATUS_NULL_ARG;
+ }
+ if (field->mType != MAMA_FIELD_TYPE_VECTOR_CHAR)
+ {
+ return MAMA_STATUS_INVALID_ARG;
+ }
+ field->mVectorSize = size;
+ return mamaFieldCacheField_setDataValue(field, values, size * sizeof(char));
+}
+
mama_status mamaFieldCacheField_setI8Vector(const mamaFieldCacheField field,
const mama_i8_t* values,
mama_size_t size)
diff --git a/mama/c_cpp/src/c/fieldcache/fieldcacheimpl.c b/mama/c_cpp/src/c/fieldcache/fieldcacheimpl.c
index 48cbf20..1d7d7a9 100644
--- a/mama/c_cpp/src/c/fieldcache/fieldcacheimpl.c
+++ b/mama/c_cpp/src/c/fieldcache/fieldcacheimpl.c
@@ -183,6 +183,22 @@ mama_status mamaFieldCache_updateCacheFromMsgField(mamaFieldCache fieldCache,
mamaFieldCacheField_setDateTime(field, fieldCache->mReusableDateTime);
break;
}
+ case MAMA_FIELD_TYPE_VECTOR_BOOL:
+ {
+ const mama_bool_t* values = NULL;
+ mama_size_t size = 0;
+ mamaMsgField_getVectorBool(messageField, &values, &size);
+ mamaFieldCacheField_setBoolVector(field, values, size);
+ break;
+ }
+ case MAMA_FIELD_TYPE_VECTOR_CHAR:
+ {
+ const char* values = NULL;
+ mama_size_t size = 0;
+ mamaMsgField_getVectorChar(messageField, &values, &size);
+ mamaFieldCacheField_setCharVector(field, values, size);
+ break;
+ }
case MAMA_FIELD_TYPE_VECTOR_I8:
{
const mama_i8_t* values = NULL;
@@ -502,6 +518,32 @@ mama_status mamaFieldCache_updateMsgField(mamaFieldCache fieldCache,
: mamaMsg_addDateTime(message, name, fid, value);
break;
}
+ case MAMA_FIELD_TYPE_VECTOR_BOOL:
+ {
+ const mama_bool_t* values = NULL;
+ mama_size_t size = 0;
+ mamaFieldCacheField_getBoolVector(field, &values, &size);
+ if (!values)
+ {
+ return MAMA_STATUS_INVALID_ARG;
+ }
+ status = useUpdate ? mamaMsg_updateVectorBool(message, name, fid, values, size)
+ : mamaMsg_addVectorBool(message, name, fid, values, size);
+ break;
+ }
+ case MAMA_FIELD_TYPE_VECTOR_CHAR:
+ {
+ const char* values = NULL;
+ mama_size_t size = 0;
+ mamaFieldCacheField_getCharVector(field, &values, &size);
+ if (!values)
+ {
+ return MAMA_STATUS_INVALID_ARG;
+ }
+ status = useUpdate ? mamaMsg_updateVectorChar(message, name, fid, values, size)
+ : mamaMsg_addVectorChar(message, name, fid, values, size);
+ break;
+ }
case MAMA_FIELD_TYPE_VECTOR_I8:
{
const mama_i8_t* values = NULL;
diff --git a/mama/c_cpp/src/c/fielddesc.c b/mama/c_cpp/src/c/fielddesc.c
index a948567..1f08e01 100644
--- a/mama/c_cpp/src/c/fielddesc.c
+++ b/mama/c_cpp/src/c/fielddesc.c
@@ -196,6 +196,10 @@ mamaFieldTypeToString (mamaFieldType type)
return "TIME";
case MAMA_FIELD_TYPE_PRICE:
return "PRICE";
+ case MAMA_FIELD_TYPE_VECTOR_BOOL:
+ return "VECTOR_BOOL";
+ case MAMA_FIELD_TYPE_VECTOR_CHAR:
+ return "VECTOR_CHAR";
case MAMA_FIELD_TYPE_VECTOR_I8:
return "VECTOR_I8";
case MAMA_FIELD_TYPE_VECTOR_U8:
@@ -270,6 +274,10 @@ stringToMamaFieldType (const char* str)
return MAMA_FIELD_TYPE_TIME;
if (strcmp(str, "PRICE") == 0)
return MAMA_FIELD_TYPE_PRICE;
+ if (strcmp(str, "VECTOR_BOOL") == 0)
+ return MAMA_FIELD_TYPE_VECTOR_BOOL;
+ if (strcmp(str, "VECTOR_CHAR") == 0)
+ return MAMA_FIELD_TYPE_VECTOR_CHAR;
if (strcmp(str, "VECTOR_I8") == 0)
return MAMA_FIELD_TYPE_VECTOR_I8;
if (strcmp(str, "VECTOR_U8") == 0)
diff --git a/mama/c_cpp/src/c/mama/fieldcache/fieldcachefield.h b/mama/c_cpp/src/c/mama/fieldcache/fieldcachefield.h
index 55dbd9b..a9ca40f 100644
--- a/mama/c_cpp/src/c/mama/fieldcache/fieldcachefield.h
+++ b/mama/c_cpp/src/c/mama/fieldcache/fieldcachefield.h
@@ -442,6 +442,40 @@ mamaFieldCacheField_getDateTime(const mamaFieldCacheField field,
const mamaDateTime* result);

/**
+ * This function will get the values a <code>mamaFieldCacheField</code> of type Bool vector.
+ *
+ * @param field (in) The field.
+ * @param values (out) The array of values of the field.
+ * @param size (out) The number of values.
+ * @return Resulting status of the call which can be
+ * MAMA_STATUS_NULL_ARG
+ * MAMA_STATUS_INVALID_ARG
+ * MAMA_STATUS_OK
+ */
+MAMAExpDLL
+extern mama_status
+mamaFieldCacheField_getBoolVector(const mamaFieldCacheField field,
+ const mama_bool_t** values,
+ mama_size_t* size);
+/**
+ * This function will get the values a <code>mamaFieldCacheField</code> of type Char vector.
+ *
+ * @param field (in) The field.
+ * @param values (out) The array of values of the field.
+ * @param size (out) The number of values.
+ * @return Resulting status of the call which can be
+ * MAMA_STATUS_NULL_ARG
+ * MAMA_STATUS_INVALID_ARG
+ * MAMA_STATUS_OK
+ */
+MAMAExpDLL
+extern mama_status
+mamaFieldCacheField_getCharVector(const mamaFieldCacheField field,
+ const char** values,
+ mama_size_t* size);
+
+
+/**
* This function will get the values a <code>mamaFieldCacheField</code> of type I8 vector.
*
* @param field (in) The field.
@@ -879,6 +913,37 @@ mamaFieldCacheField_setDateTime(const mamaFieldCacheField field,
const mamaDateTime value);

/**
+ * This function will set the values of a <code>mamaFieldCacheField</code> of type Bool vector.
+ *
+ * @param field (in) The field to set the value to.
+ * @param value (in) The new value of the field.
+ * @return Resulting status of the call which can be
+ * MAMA_STATUS_NULL_ARG
+ * MAMA_STATUS_INVALID_ARG
+ * MAMA_STATUS_OK
+ */
+MAMAExpDLL
+extern mama_status
+mamaFieldCacheField_setBoolVector(const mamaFieldCacheField field,
+ const mama_bool_t* values,
+ mama_size_t size);
+/**
+ * This function will set the values of a <code>mamaFieldCacheField</code> of type Char vector.
+ *
+ * @param field (in) The field to set the value to.
+ * @param value (in) The new value of the field.
+ * @return Resulting status of the call which can be
+ * MAMA_STATUS_NULL_ARG
+ * MAMA_STATUS_INVALID_ARG
+ * MAMA_STATUS_OK
+ */
+MAMAExpDLL
+extern mama_status
+mamaFieldCacheField_setCharVector(const mamaFieldCacheField field,
+ const char* values,
+ mama_size_t size);
+
+/**
* This function will set the values of a <code>mamaFieldCacheField</code> of type I8 vector.
*
* @param field (in) The field to set the value to.
diff --git a/mama/c_cpp/src/c/mama/fielddesc.h b/mama/c_cpp/src/c/mama/fielddesc.h
index e3af6e1..a374489 100644
--- a/mama/c_cpp/src/c/mama/fielddesc.h
+++ b/mama/c_cpp/src/c/mama/fielddesc.h
@@ -90,6 +90,8 @@ typedef enum mamaFieldType_
MAMA_FIELD_TYPE_PRICE = 27,

/** Array type support */
+ MAMA_FIELD_TYPE_VECTOR_BOOL = 29,
+ MAMA_FIELD_TYPE_VECTOR_CHAR = 30,
MAMA_FIELD_TYPE_VECTOR_I8 = 34,
MAMA_FIELD_TYPE_VECTOR_U8 = 35,
MAMA_FIELD_TYPE_VECTOR_I16 = 36,
diff --git a/mama/c_cpp/src/c/msgfield.c b/mama/c_cpp/src/c/msgfield.c
index 904a365..52fda4f 100644
--- a/mama/c_cpp/src/c/msgfield.c
+++ b/mama/c_cpp/src/c/msgfield.c
@@ -486,6 +486,24 @@ mamaMsgField_getMsg (
}

mama_status
+mamaMsgField_getVectorBool (
+ const mamaMsgField msgField,
+ const mama_bool_t** result,
+ size_t* size)
+{
+ mamaMsgFieldImpl* impl =
+ (mamaMsgFieldImpl*)(msgField);
+ if (!impl) return MAMA_STATUS_INVALID_ARG;
+
+ if (impl->myPayloadBridge)
+ {
+ return impl->myPayloadBridge->msgFieldPayloadGetVectorBool (
+ impl->myPayload, result, size);
+ }
+ return MAMA_STATUS_NULL_ARG;
+}
+
+mama_status
mamaMsgField_getVectorChar (
const mamaMsgField msgField,
const char** result,
--
1.9.3