matecomponent-arg

matecomponent-arg — simplified CORBA_Any wrappers

Synopsis

typedef             MateComponentArg;
typedef             MateComponentArgType;
#define             MATECOMPONENT_ARG_NULL
#define             MATECOMPONENT_ARG_BOOLEAN
#define             MATECOMPONENT_ARG_SHORT
#define             MATECOMPONENT_ARG_INT
#define             MATECOMPONENT_ARG_LONG
#define             MATECOMPONENT_ARG_LONGLONG
#define             MATECOMPONENT_ARG_FLOAT
#define             MATECOMPONENT_ARG_DOUBLE
#define             MATECOMPONENT_ARG_CHAR
#define             MATECOMPONENT_ARG_STRING
#define             MATECOMPONENT_ARG_GET_GENERAL       (a,
                                                         c,
                                                         t,
                                                         e)
#define             MATECOMPONENT_ARG_SET_GENERAL       (a,
                                                         v,
                                                         c,
                                                         t,
                                                         e)
#define             MATECOMPONENT_ARG_GET_BOOLEAN       (a)
#define             MATECOMPONENT_ARG_SET_BOOLEAN       (a,
                                                         v)
#define             MATECOMPONENT_ARG_GET_SHORT         (a)
#define             MATECOMPONENT_ARG_SET_SHORT         (a,
                                                         v)
#define             MATECOMPONENT_ARG_GET_INT           (a)
#define             MATECOMPONENT_ARG_SET_INT           (a,
                                                         v)
#define             MATECOMPONENT_ARG_GET_LONG          (a)
#define             MATECOMPONENT_ARG_SET_LONG          (a,
                                                         v)
#define             MATECOMPONENT_ARG_GET_LONGLONG      (a)
#define             MATECOMPONENT_ARG_SET_LONGLONG      (a,
                                                         v)
#define             MATECOMPONENT_ARG_GET_FLOAT         (a)
#define             MATECOMPONENT_ARG_SET_FLOAT         (a,
                                                         v)
#define             MATECOMPONENT_ARG_GET_DOUBLE        (a)
#define             MATECOMPONENT_ARG_SET_DOUBLE        (a,
                                                         v)
#define             MATECOMPONENT_ARG_GET_CHAR          (a)
#define             MATECOMPONENT_ARG_SET_CHAR          (a,
                                                         v)
#define             MATECOMPONENT_ARG_GET_STRING        (a)
#define             MATECOMPONENT_ARG_SET_STRING        (a,
                                                         v)
MateComponentArg *  matecomponent_arg_new               (MateComponentArgType t);
MateComponentArg *  matecomponent_arg_new_from          (MateComponentArgType t,
                                                         gconstpointer data);
void                matecomponent_arg_release           (MateComponentArg *arg);
MateComponentArg *  matecomponent_arg_copy              (const MateComponentArg *arg);
void                matecomponent_arg_from_gvalue       (MateComponentArg *a,
                                                         const GValue *value);
MateComponentArgType matecomponent_arg_type_from_gtype  (GType t);
void                matecomponent_arg_to_gvalue         (GValue *value,
                                                         const MateComponentArg *arg);
GType               matecomponent_arg_type_to_gtype     (MateComponentArgType id);
gboolean            matecomponent_arg_is_equal          (const MateComponentArg *a,
                                                         const MateComponentArg *b,
                                                         CORBA_Environment *opt_ev);
gboolean            matecomponent_arg_type_is_equal     (MateComponentArgType a,
                                                         MateComponentArgType b,
                                                         CORBA_Environment *opt_ev);

Description

The MateComponentArg code, and macros are designed to make the use of CORBA_Any's slightly simpler by providing a glib like binding for them. The matecomponent-arg code also provides mappings between GValues and CORBA_anys.

A typical use of the MateComponentArg macros would be in

Example 14. Property bag implementation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
static void
get_prop (MateComponentPropertyBag *bag,
	  MateComponentArg         *arg,
	  guint              arg_id,
	  CORBA_Environment *ev,
	  gpointer           user_data)
{
	GObject *clock = user_data;
	switch (arg_id) {
	case PROP_RUNNING: {
		MATECOMPONENT_ARG_SET_BOOLEAN (arg, is_it_running);
		break;
	}
	default:
		matecomponent_exception_set (ev, ex_MateComponent_PropertyBag_NotFound);
		break;
	}
}


Details

MateComponentArg

typedef CORBA_any      MateComponentArg;

A glib style looking type alias for a CORBA_any


MateComponentArgType

typedef CORBA_TypeCode MateComponentArgType;

A glib style looking typedef for a CORBA type description.


MATECOMPONENT_ARG_NULL

#define MATECOMPONENT_ARG_NULL     TC_null

the null type


MATECOMPONENT_ARG_BOOLEAN

#define MATECOMPONENT_ARG_BOOLEAN  TC_CORBA_boolean

the boolean type


MATECOMPONENT_ARG_SHORT

#define MATECOMPONENT_ARG_SHORT    TC_CORBA_short

the short type


MATECOMPONENT_ARG_INT

#define MATECOMPONENT_ARG_INT      TC_CORBA_long

the integer type [ in fact a long ]


MATECOMPONENT_ARG_LONG

#define MATECOMPONENT_ARG_LONG     TC_CORBA_long

the long type


MATECOMPONENT_ARG_LONGLONG

#define MATECOMPONENT_ARG_LONGLONG TC_CORBA_long_long

the long long type


MATECOMPONENT_ARG_FLOAT

#define MATECOMPONENT_ARG_FLOAT    TC_CORBA_float

the float type


MATECOMPONENT_ARG_DOUBLE

#define MATECOMPONENT_ARG_DOUBLE   TC_CORBA_double

the double type


MATECOMPONENT_ARG_CHAR

#define MATECOMPONENT_ARG_CHAR     TC_CORBA_char

the char type


MATECOMPONENT_ARG_STRING

#define MATECOMPONENT_ARG_STRING   TC_CORBA_string

the string type


MATECOMPONENT_ARG_GET_GENERAL()

# define MATECOMPONENT_ARG_GET_GENERAL(a,c,t,e)   ({g_assert (matecomponent_arg_type_is_equal ((a)->_type, c, e)); *((t *)((a)->_value)); })

A macro to extract a value from a MateComponentArg with the given CORBA type t.

a :

the MateComponentArg

c :

a MateComponentArgType for checking

t :

the C type of the value eg. for MATECOMPONENT_ARG_LONG: CORBA_long

e :

an optional CORBA_Environment or NULL.

MATECOMPONENT_ARG_SET_GENERAL()

# define MATECOMPONENT_ARG_SET_GENERAL(a,v,c,t,e) ({g_assert (matecomponent_arg_type_is_equal ((a)->_type, c, e)); *((t *)((a)->_value)) = (t)(v); })

A macro to insert a value into an empty MateComponentArg with the given CORBA type t.

a :

the MateComponentArg

v :

a pointer to the value to insert.

c :

a MateComponentArgType for checking

t :

the C type of the value eg. for MATECOMPONENT_ARG_LONG: CORBA_long

e :

an optional CORBA_Environment or NULL.

MATECOMPONENT_ARG_GET_BOOLEAN()

#define MATECOMPONENT_ARG_GET_BOOLEAN(a)   (MATECOMPONENT_ARG_GET_GENERAL (a, TC_CORBA_boolean, CORBA_boolean, NULL))

This macro returns a CORBA_boolean from inside a MateComponentArg. If the MateComponentArg's type does not match, the behavior is undefined, and may cause faults.

a :

the MateComponentArg to extract the value from.

MATECOMPONENT_ARG_SET_BOOLEAN()

#define MATECOMPONENT_ARG_SET_BOOLEAN(a,v) (MATECOMPONENT_ARG_SET_GENERAL (a, v, TC_CORBA_boolean, CORBA_boolean, NULL))

This macro sets the value of a to contain v

a :

the MateComponent arg to insert the value into

v :

a CORBA_boolean.

MATECOMPONENT_ARG_GET_SHORT()

#define MATECOMPONENT_ARG_GET_SHORT(a)     (MATECOMPONENT_ARG_GET_GENERAL (a, TC_CORBA_short, CORBA_short, NULL))

This macro returns a CORBA_short from inside a MateComponentArg. If the MateComponentArg's type does not match, the behavior is undefined, and may cause faults.

a :

the MateComponentArg to extract the value from.

MATECOMPONENT_ARG_SET_SHORT()

#define MATECOMPONENT_ARG_SET_SHORT(a,v)   (MATECOMPONENT_ARG_SET_GENERAL (a, v, TC_CORBA_short, CORBA_short, NULL))

This macro sets the value of a to contain v

a :

the MateComponent arg to insert the value into

v :

a CORBA_short.

MATECOMPONENT_ARG_GET_INT()

#define MATECOMPONENT_ARG_GET_INT(a)       (MATECOMPONENT_ARG_GET_GENERAL (a, TC_CORBA_long, CORBA_long, NULL))

this macro returns a CORBA_long from inside a MateComponentArg, if the MateComponentArg's type does not match, the behavior is undefined, and may cause faults.

a :

the MateComponentArg to extract the value from.

MATECOMPONENT_ARG_SET_INT()

#define MATECOMPONENT_ARG_SET_INT(a,v)     (MATECOMPONENT_ARG_SET_GENERAL (a, v, TC_CORBA_long, CORBA_long, NULL))

This macro sets the value of a to contain v

a :

the MateComponent arg to insert the value into

v :

a CORBA_long.

MATECOMPONENT_ARG_GET_LONG()

#define MATECOMPONENT_ARG_GET_LONG(a)      (MATECOMPONENT_ARG_GET_GENERAL (a, TC_CORBA_long, CORBA_long, NULL))

this macro returns a CORBA_long from from inside a MateComponentArg, if the MateComponentArg's type does not match, the behavior is undefined, and may cause faults.

a :

the MateComponentArg to extract the value from.

MATECOMPONENT_ARG_SET_LONG()

#define MATECOMPONENT_ARG_SET_LONG(a,v)    (MATECOMPONENT_ARG_SET_GENERAL (a, v, TC_CORBA_long, CORBA_long, NULL))

This macro sets the value of a to contain v

a :

the MateComponent arg to insert the value into

v :

a CORBA_long.

MATECOMPONENT_ARG_GET_LONGLONG()

#define MATECOMPONENT_ARG_GET_LONGLONG(a)  (MATECOMPONENT_ARG_GET_GENERAL (a, TC_CORBA_long_long, CORBA_long_long, NULL))

this macro returns a CORBA_long_long from from inside a MateComponentArg, if the MateComponentArg's type does not match, the behavior is undefined, and may cause faults.

a :

the MateComponentArg to extract the value from.

MATECOMPONENT_ARG_SET_LONGLONG()

#define MATECOMPONENT_ARG_SET_LONGLONG(a,v) (MATECOMPONENT_ARG_SET_GENERAL (a, v, TC_CORBA_long_long, CORBA_long_long, NULL))

This macro sets the value of a to contain v

a :

the MateComponent arg to insert the value into

v :

a CORBA_long_long.

MATECOMPONENT_ARG_GET_FLOAT()

#define MATECOMPONENT_ARG_GET_FLOAT(a)     (MATECOMPONENT_ARG_GET_GENERAL (a, TC_CORBA_float, CORBA_float, NULL))

this macro returns a CORBA_float from inside a MateComponentArg, if the MateComponentArg's type does not match, the behavior is undefined, and may cause faults.

a :

the MateComponentArg to extract the value from.

MATECOMPONENT_ARG_SET_FLOAT()

#define MATECOMPONENT_ARG_SET_FLOAT(a,v)   (MATECOMPONENT_ARG_SET_GENERAL (a, v, TC_CORBA_float, CORBA_float, NULL))

This macro sets the value of a to contain v

a :

the MateComponent arg to insert the value into

v :

a CORBA_float.

MATECOMPONENT_ARG_GET_DOUBLE()

#define MATECOMPONENT_ARG_GET_DOUBLE(a)    (MATECOMPONENT_ARG_GET_GENERAL (a, TC_CORBA_double, CORBA_double, NULL))

This macro returns a CORBA_double from inside a MateComponentArg. If the MateComponentArg's type does not match, the behavior is undefined, and may cause faults.

a :

the MateComponentArg to extract the value from.

MATECOMPONENT_ARG_SET_DOUBLE()

#define MATECOMPONENT_ARG_SET_DOUBLE(a,v)  (MATECOMPONENT_ARG_SET_GENERAL (a, v, TC_CORBA_double, CORBA_double, NULL))

This macro sets the value of a to contain v

a :

the MateComponent arg to insert the value into

v :

a CORBA_double.

MATECOMPONENT_ARG_GET_CHAR()

#define MATECOMPONENT_ARG_GET_CHAR(a)      (MATECOMPONENT_ARG_GET_GENERAL (a, TC_CORBA_char, CORBA_char, NULL))

This macro returns a CORBA_char from inside a MateComponentArg, If the MateComponentArg's type does not match, the behavior is undefined, and may cause faults.

a :

the MateComponentArg to extract the value from.

MATECOMPONENT_ARG_SET_CHAR()

#define MATECOMPONENT_ARG_SET_CHAR(a,v)    (MATECOMPONENT_ARG_SET_GENERAL (a, v, TC_CORBA_char, CORBA_char, NULL))

This macro sets the value of a to contain v

a :

the MateComponent arg to insert the value into

v :

a CORBA_char.

MATECOMPONENT_ARG_GET_STRING()

#define MATECOMPONENT_ARG_GET_STRING(a)    ({g_assert ((a)->_type->kind == CORBA_tk_string); *((CORBA_char **)((a)->_value)); })

this macro returns a const CORBA_char * from from inside a MateComponentArg, if the MateComponentArg's type does not match, the behavior is undefined, and may cause faults. The pointer to the string is only valid for the scope of the lifetime of a.

a :

the MateComponentArg to extract the value from.

MATECOMPONENT_ARG_SET_STRING()

#define MATECOMPONENT_ARG_SET_STRING(a,v)  ({g_assert ((a)->_type->kind == CORBA_tk_string); CORBA_free (*(char **)(a)->_value); *((CORBA_char **)((a)->_value)) = CORBA_string_dup ((v)?(v):""); })

This macro sets the value of a to contain a duplicated copy of v

a :

the MateComponent arg to insert the value into

v :

a CORBA_char *.

matecomponent_arg_new ()

MateComponentArg *  matecomponent_arg_new               (MateComponentArgType t);

Create a new MateComponentArg with the specified type the value of the MateComponentArg is initially empty.

t :

the MateComponentArgType eg. TC_CORBA_long

Returns :

the new MateComponentArg

matecomponent_arg_new_from ()

MateComponentArg *  matecomponent_arg_new_from          (MateComponentArgType t,
                                                         gconstpointer data);

Create a new MateComponentArg with the specified type and data

t :

the MateComponentArgType eg. TC_CORBA_long

data :

the data for the MateComponentArg to be created

Returns :

the new MateComponentArg

matecomponent_arg_release ()

void                matecomponent_arg_release           (MateComponentArg *arg);

This frees the memory associated with arg

arg :

the matecomponent arg.

matecomponent_arg_copy ()

MateComponentArg *  matecomponent_arg_copy              (const MateComponentArg *arg);

This function duplicates a by a deep copy

arg :

the matecomponent arg

Returns :

a copy of arg

matecomponent_arg_from_gvalue ()

void                matecomponent_arg_from_gvalue       (MateComponentArg *a,
                                                         const GValue *value);

This maps a GValue value to a MateComponentArg a; a must point to a freshly allocated MateComponentArg eg. such as returned by matecomponent_arg_new

a :

pointer to blank MateComponentArg

value :

GValue to copy

matecomponent_arg_type_from_gtype ()

MateComponentArgType matecomponent_arg_type_from_gtype  (GType t);


matecomponent_arg_to_gvalue ()

void                matecomponent_arg_to_gvalue         (GValue *value,
                                                         const MateComponentArg *arg);

Maps a MateComponentArg to a GtkArg; a must point to a blank GtkArg.

value :

pointer to a blank GValue

arg :

the MateComponentArg to copy

matecomponent_arg_type_to_gtype ()

GType               matecomponent_arg_type_to_gtype     (MateComponentArgType id);

This maps a MateComponentArgType to a GType

id :

the MateComponentArgType

Returns :

the mapped type or 0 on failure

matecomponent_arg_is_equal ()

gboolean            matecomponent_arg_is_equal          (const MateComponentArg *a,
                                                         const MateComponentArg *b,
                                                         CORBA_Environment *opt_ev);

Compares two MateComponentArg's for equivalence; will return TRUE if equivalent for all simple cases. For Object references CORBA sometimes denies 2 object references are equivalent even if they are [ this is a feature_not_bug ].

This function is commutative.

a :

a matecomponent arg

b :

another matecomponent arg

opt_ev :

optional exception environment or NULL.

Returns :

TRUE if a == b

matecomponent_arg_type_is_equal ()

gboolean            matecomponent_arg_type_is_equal     (MateComponentArgType a,
                                                         MateComponentArgType b,
                                                         CORBA_Environment *opt_ev);

This compares two MateComponentArgType's in a and b. The opt_ev is an optional CORBA_Environment for exceptions, or NULL. This function is commutative.

a :

a type code

b :

a type code

opt_ev :

optional exception environment or NULL.

Returns :

TRUE if equal, FALSE if different