Home | History | Annotate | Download | only in src
      1 /*
      2  INTEL CONFIDENTIAL
      3  Copyright 2009 Intel Corporation All Rights Reserved.
      4  The source code contained or described herein and all documents related to the source code ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the Material remains with Intel Corporation or its suppliers and licensors. The Material contains trade secrets and proprietary and confidential information of Intel or its suppliers and licensors. The Material is protected by worldwide copyright and trade secret laws and treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, or disclosed in any way without Intels prior express written permission.
      5 
      6  No license under any patent, copyright, trade secret or other intellectual property right is granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement, estoppel or otherwise. Any license under such intellectual property rights must be express and approved by Intel in writing.
      7 */
      8 
      9 #ifndef __MIX_PARAMS_H__
     10 #define __MIX_PARAMS_H__
     11 
     12 #include <glib-object.h>
     13 
     14 G_BEGIN_DECLS
     15 
     16 #define MIX_TYPE_PARAMS          (mix_params_get_type())
     17 #define MIX_IS_PARAMS(obj)       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIX_TYPE_PARAMS))
     18 #define MIX_IS_PARAMS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MIX_TYPE_PARAMS))
     19 #define MIX_PARAMS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MIX_TYPE_PARAMS, MixParamsClass))
     20 #define MIX_PARAMS(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIX_TYPE_PARAMS, MixParams))
     21 #define MIX_PARAMS_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST ((klass), MIX_TYPE_PARAMS, MixParamsClass))
     22 #define MIX_PARAMS_CAST(obj)     ((MixParams*)(obj))
     23 
     24 typedef struct _MixParams MixParams;
     25 typedef struct _MixParamsClass MixParamsClass;
     26 
     27 /**
     28  * MixParamsDupFunction:
     29  * @obj: Params to duplicate
     30  * @returns: reference to cloned instance.
     31  *
     32  * Virtual function prototype for methods to create duplicate of instance.
     33  *
     34  */
     35 typedef MixParams * (*MixParamsDupFunction) (const MixParams *obj);
     36 
     37 /**
     38  * MixParamsCopyFunction:
     39  * @target: target of the copy
     40  * @src: source of the copy
     41  * @returns: boolean indicates if copy is successful.
     42  *
     43  * Virtual function prototype for methods to create copies of instance.
     44  *
     45  */
     46 typedef gboolean (*MixParamsCopyFunction) (MixParams* target, const MixParams *src);
     47 
     48 /**
     49  * MixParamsFinalizeFunction:
     50  * @obj: Params to finalize
     51  *
     52  * Virtual function prototype for methods to free ressources used by
     53  * object.
     54  */
     55 typedef void (*MixParamsFinalizeFunction) (MixParams *obj);
     56 
     57 /**
     58  * MixParamsEqualsFunction:
     59  * @first: first object in the comparison
     60  * @second: second object in the comparison
     61  *
     62  * Virtual function prototype for methods to compare 2 objects and check if they are equal.
     63  */
     64 typedef gboolean (*MixParamsEqualFunction) (MixParams *first, MixParams *second);
     65 
     66 /**
     67  * MIX_VALUE_HOLDS_PARAMS:
     68  * @value: the #GValue to check
     69  *
     70  * Checks if the given #GValue contains a #MIX_TYPE_PARAM value.
     71  */
     72 #define MIX_VALUE_HOLDS_PARAMS(value)  (G_VALUE_HOLDS(value, MIX_TYPE_PARAMS))
     73 
     74 /**
     75  * MIX_PARAMS_REFCOUNT:
     76  * @obj: a #MixParams
     77  *
     78  * Get access to the reference count field of the object.
     79  */
     80 #define MIX_PARAMS_REFCOUNT(obj)           ((MIX_PARAMS_CAST(obj))->refcount)
     81 /**
     82  * MIX_PARAMS_REFCOUNT_VALUE:
     83  * @obj: a #MixParams
     84  *
     85  * Get the reference count value of the object
     86  */
     87 #define MIX_PARAMS_REFCOUNT_VALUE(obj)     (g_atomic_int_get (&(MIX_PARAMS_CAST(obj))->refcount))
     88 
     89 /**
     90  * MixParams:
     91  * @instance: type instance
     92  * @refcount: atomic refcount
     93  *
     94  * Base class for a refcounted parameter objects.
     95  */
     96 struct _MixParams {
     97   GTypeInstance instance;
     98   /*< public >*/
     99   gint refcount;
    100 
    101   /*< private >*/
    102   gpointer _reserved;
    103 };
    104 
    105 /**
    106  * MixParamsClass:
    107  * @dup: method to duplicate the object.
    108  * @copy: method to copy details in one object to the other.
    109  * @finalize: destructor
    110  * @equal: method to check if the content of two objects are equal.
    111  *
    112  * #MixParams class strcut.
    113  */
    114 struct _MixParamsClass {
    115   GTypeClass type_class;
    116 
    117   MixParamsDupFunction dup;
    118   MixParamsCopyFunction copy;
    119   MixParamsFinalizeFunction finalize;
    120   MixParamsEqualFunction equal;
    121 
    122   /*< private >*/
    123   gpointer _mix_reserved;
    124 };
    125 
    126 /**
    127  * mix_params_get_type:
    128  * @returns: type of this object.
    129  *
    130  * Get type.
    131  */
    132 GType mix_params_get_type(void);
    133 
    134 /**
    135  * mix_params_new:
    136  * @returns: return a newly allocated object.
    137  *
    138  * Create new instance of the object.
    139  */
    140 MixParams* mix_params_new();
    141 
    142 /**
    143  * mix_params_copy:
    144  * @target: copy to target
    145  * @src: copy from source
    146  * @returns: boolean indicating if copy is successful.
    147  *
    148  * Copy data from one instance to the other. This method internally invoked the #MixParams::copy method such that derived object will be copied correctly.
    149  */
    150 gboolean mix_params_copy(MixParams *target, const MixParams *src);
    151 
    152 
    153 /**
    154  * mix_params_ref:
    155  * @obj: a #MixParams object.
    156  * @returns: the object with reference count incremented.
    157  *
    158  * Increment reference count.
    159  */
    160 MixParams* mix_params_ref(MixParams *obj);
    161 
    162 
    163 /**
    164  * mix_params_unref:
    165  * @obj: a #MixParams object.
    166  *
    167  * Decrement reference count.
    168  */
    169 void mix_params_unref  (MixParams *obj);
    170 
    171 /**
    172  * mix_params_replace:
    173  * @olddata:
    174  * @newdata:
    175  *
    176  * Replace a pointer of the object with the new one.
    177  */
    178 void mix_params_replace(MixParams **olddata, MixParams *newdata);
    179 
    180 /**
    181  * mix_params_dup:
    182  * @obj: #MixParams object to duplicate.
    183  * @returns: A newly allocated duplicate of the object, or NULL if failed.
    184  *
    185  * Duplicate the given #MixParams and allocate a new instance. This method is chained up properly and derive object will be dupped properly.
    186  */
    187 MixParams *mix_params_dup(const MixParams *obj);
    188 
    189 /**
    190  * mix_params_equal:
    191  * @first: first object to compare
    192  * @second: second object to compare
    193  * @returns: boolean indicates if the 2 object contains same data.
    194  *
    195  * Note that the parameter comparison compares the values that are hold inside the object, not for checking if the 2 pointers are of the same instance.
    196  */
    197 gboolean mix_params_equal(MixParams *first, MixParams *second);
    198 
    199 G_END_DECLS
    200 
    201 #endif
    202 
    203