/**
- * Validity structure
+ * Validity structure.
*/
typedef struct {
MMAttrsType type;
};
} MMAttrsInfo;
+/**
+ * Value structure.
+ */
+typedef struct {
+ MMAttrsType type;
+ int size;
+ union {
+ int i_val;
+ double d_val;
+ char *s_val;
+ void *p_val;
+ } value;
+} MMAttrsValue;
+
+/**
+ * Construction information structure.
+ */
+typedef struct {
+ char *name;
+ MMAttrsType value_type;
+ int flags;
+ void *default_value;
+} MMAttrsConstructInfo;
+
+/**
+ * Attributes commit callback function type.
+ *
+ * @param index [in] Index of attribute
+ * @param name [in] Name of attribute
+ * @param value [in] Value of attribute
+ * @param user_param [in] User parameter
+ *
+ * @return This callback function should return true on success, or false on failure.
+ * @see mm_attrs_new
+ */
+typedef bool (*mm_attrs_commit_callback) (int index, const char *name, const MMAttrsValue *value, void *user_param);
#if __GNUC__ >= 4
#define __NULL_TERMINATED __attribute__((__sentinel__))
#endif
/**
+ * This function is to create handle of attributes list and register the commit callback.
+ *
+ * @param info [in] Attributes construction information
+ * @param count [in] The number of attributes
+ * @param name [in] Name of the attributes list (optional, this can be NULL)
+ * @param callback [in] Commit callback (optional, this can be NULL)
+ * @param user_param [in] User param of the commit callback (optional, this can be NULL)
+ * @param attrs [out] Handle of attributes list
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ * @see mm_attrs_commit_all
+ * @see mm_attrs_commit
+ * @see mm_attrs_free
+ */
+int mm_attrs_new(MMAttrsConstructInfo *info, int count, const char *name,
+ mm_attrs_commit_callback callback, void *user_param, MMHandleType *attrs);
+
+
+/**
+ * This function releases resources and destroy the attributes handle created by mm_attrs_new.
+ *
+ * @param attrs [in] Handle of attributes list
+ * @see mm_attrs_new
+ */
+void mm_attrs_free(MMHandleType attrs);
+
+
+/**
+ * This function is to commit all the attributes.
+ *
+ * @param attrs [in] Handle of attributes list
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ * @see mm_attrs_new
+ * @see mm_attrs_commit
+ */
+int mm_attrs_commit_all(MMHandleType attrs);
+
+
+/**
+ * This function is to commit the attribute.
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ * @see mm_attrs_new
+ * @see mm_attrs_commit_all
+ */
+int mm_attrs_commit(MMHandleType attrs, int index);
+
+
+/**
* This function is to set the integer value to the attribute by name.
*
- * @param attrs [in] MMAttrs handle
- * @param attr_name [in] attribute name
- * @param val [in] integer value to set
+ * @param attrs [in] Handle of attributes list
+ * @param attr_name [in] Name of attribute
+ * @param val [in] Integer value to set
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
*/
* This function is to get the name of attribute at the given index.
*
* @param attrs [in] Handle of attributes list
- * @param index [in] Index of the attribute
+ * @param index [in] Index of attribute
* @param name [out] Name of attribute
*
* @return This function returns the name of attribute on success, or NULL
/**
* This function is to set the string to attribute by name.
*
- * @param attrs [in] MMAttrs handle
- * @param attr_name [in] attribute name
- * @param string [in] string value to set
+ * @param attrs [in] MMAttrs handle
+ * @param attr_name [in] Name of attribute
+ * @param string [in] String value to set
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
*/
/**
* This function is to set the data to the attribute by name.
*
- * @param attrs [in] MMAttrs handle
- * @param attr_name [in] attribute name
- * @param data [in] data pointer to set
- * @param size [in] data size to set
+ * @param attrs [in] Handle of attributes list
+ * @param attr_name [in] Name of attribute
+ * @param data [in] Data pointer to set
+ * @param size [in] Data size to set
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
*/
int mm_attrs_set_data_by_name(MMHandleType attrs, const char *attr_name, void *data, int size);
+
/**
* This function is to get the data from the attribute by name.
*
* @param attrs [in] Handle of attributes list
* @param attr_name [in] Name of attribute
- * @param data [out] data pointer to set
+ * @param data [out] Data pointer to set
*
* @return This function returns user defined value on success, or NULL
* on failure
/**
* This function is to retrieve type of attribute.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param attrtype [out] On return contains type of attribute
+ * @param attrs [in] List of attributes
+ * @param index [in] Index of attribute
+ * @param attrtype [out] Type of attribute
*
* @return This function returns MM_ERROR_NONE.
* @see MMAttrsType
/**
* This function is to get flags of attribute with given index.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param flags [out] On return contains flags of attribute.
+ * @param attrs [in] List of attributes
+ * @param index [in] Index of attribute
+ * @param flags [out] Flags of attribute
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @see MMAttrsFlag
/**
* This function is to get valid value type of attribute with given index.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param type [out] On return contains valid value type of attribute
+ * @param attrs [in] List of attributes
+ * @param index [in] Index of attribute
+ * @param type [out] Valid value type of attribute
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @see MMAttrsType
*/
-int mm_attrs_get_valid_type(MMHandleType attrs, int index, int *type);
+int mm_attrs_get_valid_type(MMHandleType attrs, int index, MMAttrsValidType *type);
/**
* This function is to get valid range of attribute with given index.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param min [out] minimum value of the valid range
- * @param max [out] maximum value of the valid range
+ * @param attrs [in] List of attributes
+ * @param index [in] Index of attribute
+ * @param min [out] Minimum value of the valid range
+ * @param max [out] Maximum value of the valid range
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
*/
/**
* This function is to get valid array of attribute with given index.
*
- * @param attrs [in] list of attributes
- * @param index [in] Index of attribute
- * @param count [out] number of array
- * @param array [out] on return contains valid array of attribute
+ * @param attrs [in] List of attributes
+ * @param index [in] Index of attribute
+ * @param count [out] The number of array
+ * @param array [out] Valid array of attribute
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
*/
/**
* This function is to set integer value to attribute with given index.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param val [in] integer value to set
+ * @param attrs [in] List of attributes
+ * @param index [in] Index of attribute
+ * @param val [in] Integer value to set
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @see mm_attrs_get_int
/**
* This function is to get integer value to attribute with given index.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param val [out] On return contains integer value of attribute
+ * @param attrs [in] List of attributes
+ * @param index [in] Index of attribute
+ * @param val [out] Integer value of attribute
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @remarks If type of attributes is not an integer type, the value which is returned by this function is meaningless.
*
* @param attrs [in] List of attributes
* @param index [in] Index of attribute
- * @param attrval [out] On return contains double value of attribute on success, or invalid value.
+ * @param attrval [out] Double value of attribute on success, or invalid value
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @see mm_attrs_set_double
/**
* This function is to set string to attribute with given index.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param string [in] String to set
- * @param size [in] length of string to set
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param string [in] String to set
+ * @param size [in] Length of string to set
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @see mm_attrs_get_string
/**
* This function is to get string to attribute with given index.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param sval [in] Placeholder to output string buffer
- * @param size [in] The field contains number of characters filled in the buffer
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param sval [in] Placeholder to output string buffer
+ * @param size [in] The field contains number of characters filled in the buffer
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @remarks Application would be responsible for managing/releasing the string
/**
* This function is to set pointer to attribute with given index.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param data [in] data to set
- * @param size [in] Length of input data
- * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param data [in] Data to set
+ * @param size [in] Length of input data
*
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @remarks Data type is the reference to memory which is allocated by user. The allocated memory must be freed by user.
* @see mm_attrs_get_data
*/
int mm_attrs_set_data(MMHandleType attrs, int index, void *data, int size);
+
/**
* This function is to get pointer to attribute with given index.
*
- * @param attrs [in] List of attributes
- * @param index [in] Index of attribute
- * @param data [out] Placeholder to output data buffer
- * @param size [out] The field contains number of bytes filled in the buffer
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param data [out] Placeholder to output data buffer
+ * @param size [out] The field contains number of bytes filled in the buffer
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @remarks Application would be responsible for managing/releasing data
/**
* A function to get information of the attribute
*
- * @param attrs [in] List of attributes
+ * @param attrs [in] Handle of attributes list
* @param index [in] Index of attribute
* @param info [out] Information of the attribute
*
/**
* This function is to get array of attribute with given name.
*
- * @param attrs [in] List of attributes
+ * @param attrs [in] Handle of attributes list
* @param attr_name [in] Name of attribute
* @param info [out] Information of the attribute
*
*/
int mm_attrs_get_info_by_name(MMHandleType attrs, const char *attr_name, MMAttrsInfo *info);
+
/**
* Sets properties on an object.
*
- * @param attrs [in] List of attributes
- * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
- * @param attribute_name [in] name of the first property to set
- * @param ... [in] value for the first property, followed optionally by more
+ * @param attrs [in] Handle of attributes list
+ * @param err_attr_name [out] Name of attributes that occurs error. Free this variable after use
+ * @param attribute_name [in] Name of the first property to set
+ * @param ... [in] Value for the first property, followed optionally by more
* name/value pairs, followed by %NULL
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
/**
* Gets properties on an object.
*
- * @param attrs [in] List of attributes
- * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
- * @param attribute_name [in] name of the first property to set
- * @param ... [in] value for the first property, followed optionally by more
+ * @param attrs [in] Handle of attributes list
+ * @param err_attr_name [out] Name of attributes that occurs error. Free this variable after use
+ * @param attribute_name [in] Name of the first property to set
+ * @param ... [in] Value for the first property, followed optionally by more
* name/value pairs, followed by %NULL
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
/**
* Sets properties on an object with va_list param.
*
- * @param attrs [in] List of attributes
- * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
- * @param attribute_name [in] name of the first property to set
- * @param var_args [in] variable arguments
+ * @param attrs [in] Handle of attributes list
+ * @param err_attr_name [out] Name of attributes that occurs error. Free this variable after use
+ * @param attribute_name [in] Name of the first property to set
+ * @param var_args [in] Variable arguments
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @remarks Multiple setter of attribute
/**
* Gets properties on an object with va_list param.
*
- * @param attrs [in] List of attributes
- * @param err_attr_name [out] the name of attributes that occurs error. Free this variable after use.
- * @param attribute_name [in] name of the first property to set
- * @param var_args [in] variable arguments
+ * @param attrs [in] Handle of attributes list
+ * @param err_attr_name [out] Name of attributes that occurs error. Free this variable after use
+ * @param attribute_name [in] Name of the first property to set
+ * @param var_args [in] Variable arguments
*
* @return This function returns MM_ERROR_NONE on success, or negative value with error code.
* @remarks Multiple setter of attribute
*/
int mm_attrs_get_valist(MMHandleType attrs, char **err_attr_name, const char *attribute_name, va_list var_args);
+
+/**
+ * This function is to set the valid attribute type.
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param type [in] Type of attribute
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ */
+int mm_attrs_set_valid_type(MMHandleType attrs, int index, MMAttrsValidType type);
+
+
+/**
+ * This function is to set the valid integer range to the attribute.
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param min [in] Minimum value of the valid range
+ * @param max [in] Maximum value of the valid range
+ * @param dval [in] Default value
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ */
+int mm_attrs_set_valid_range(MMHandleType attrs, int index, int min, int max, int dval);
+
+
+/**
+ * This function is to set the valid integer array to the attribute.
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param array [in] Array contains integer values to set
+ * @param count [in] The number of items in array
+ * @param dval [in] Default value
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ */
+int mm_attrs_set_valid_array(MMHandleType attrs, int index, const int *array, int count, int dval);
+
+
+/**
+ * This function is to set the valid double range to the attribute.
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param min [in] Minimum value of the valid range
+ * @param max [in] Maximum value of the valid range
+ * @param dval [in] Default value
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ */
+int mm_attrs_set_valid_double_range(MMHandleType attrs, int index, double min, double max, double dval);
+
+
+/**
+ * This function is to set the valid double array to the attribute.
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param array [in] Array contains double values to set
+ * @param count [in] The number of items in array
+ * @param dval [in] Default value
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ */
+int mm_attrs_set_valid_double_array(MMHandleType attrs, int index, const double *array, int count, double dval);
+
+
+/**
+ * This function is to check whether the attribute is modified
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ * @param modified [out] Modified or not (true = modified, false = not modified)
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ */
+int mm_attrs_is_modified(MMHandleType attrs, int index, bool *modified);
+
+
+/**
+ * This function is to set the attribute to modified
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ */
+int mm_attrs_set_modified(MMHandleType attrs, int index);
+
+
+/**
+ * This function is to set the attribute to read-only
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ */
+int mm_attrs_set_readonly(MMHandleType attrs, int index);
+
+
+/**
+ * This function is to set the attribute to disabled
+ *
+ * @param attrs [in] Handle of attributes list
+ * @param index [in] Index of attribute
+ *
+ * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
+ */
+int mm_attrs_set_disabled(MMHandleType attrs, int index);
+
+
+
/**
* @}
*/