00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GLOBUS_OBJECT_H
00019 #define GLOBUS_OBJECT_H
00020
00021
00022 #include "globus_types.h"
00023
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027
00028
00029
00030
00031
00032
00033
00034 typedef void (*globus_object_copy_func_t) (void * src_instance_data,
00035 void ** dst_instance_data);
00036
00037 typedef void (*globus_object_destructor_func_t) (void * instance_data);
00038
00039 typedef struct globus_object_type_s {
00040 const struct globus_object_type_s * const parent_type;
00041 globus_object_copy_func_t const copy_func;
00042 globus_object_destructor_func_t const destructor;
00043 void * const class_data;
00044 } globus_object_type_t;
00045
00046 typedef struct globus_object_s {
00047 const globus_object_type_t * type;
00048 struct globus_object_s * parent_object;
00049 void * instance_data;
00050 int ref_count;
00051 } globus_object_t;
00052
00053 typedef char * (*globus_object_printable_string_func_t)
00054 (globus_object_t * error);
00055
00056
00057
00058
00059
00060
00061 extern globus_object_t *
00062 globus_object_construct (const globus_object_type_t * create_type);
00063
00064
00065
00066 extern globus_object_t *
00067 globus_object_initialize_base (globus_object_t * object);
00068
00069 extern globus_object_t *
00070 globus_object_construct_base ();
00071
00072 #define globus_object_static_initializer(object_type, \
00073 parent_prototype) \
00074 { \
00075 (object_type), \
00076 (parent_prototype), \
00077 ((void *) NULL), \
00078 1 \
00079 }
00080
00081 extern globus_object_t *
00082 globus_object_copy (const globus_object_t * object);
00083
00084
00085
00086 void
00087 globus_object_reference(globus_object_t * object);
00088
00089 extern void
00090 globus_object_free (globus_object_t * object);
00091
00092
00093
00094 #define globus_object_type_static_initializer(parent_type, \
00095 copy_func, \
00096 destructor, \
00097 class_data) \
00098 { \
00099 (parent_type), \
00100 (copy_func), \
00101 (destructor), \
00102 (class_data) \
00103 }
00104
00105 #define globus_object_printable_type_static_initializer(pt,cf,df,s) \
00106 globus_object_type_static_initializer((pt),(cf),(df),(void *)(s))
00107
00108 extern globus_object_t *
00109 globus_object_initialize_printable (globus_object_t * object);
00110
00111 extern globus_object_t *
00112 globus_object_construct_printable ();
00113
00114
00115
00116
00117
00118
00119 extern const globus_object_type_t GLOBUS_OBJECT_TYPE_BASE_DEFINITION;
00120 #define GLOBUS_OBJECT_TYPE_BASE (&GLOBUS_OBJECT_TYPE_BASE_DEFINITION)
00121
00122 extern const globus_object_type_t
00123 GLOBUS_OBJECT_TYPE_PRINTABLE_DEFINITION;
00124 #define GLOBUS_OBJECT_TYPE_PRINTABLE \
00125 (&GLOBUS_OBJECT_TYPE_PRINTABLE_DEFINITION)
00126
00127
00128
00129
00130
00131 extern globus_object_t GLOBUS_OBJECT_BASE_STATIC_PROTOTYPE;
00132 #define GLOBUS_OBJECT_BASE_PROTOTYPE (&GLOBUS_OBJECT_BASE_STATIC_PROTOTYPE)
00133
00134 extern globus_object_t
00135 GLOBUS_OBJECT_PRINTABLE_STATIC_PROTOTYPE;
00136 #define GLOBUS_OBJECT_PRINTABLE_PROTOTYPE \
00137 (&GLOBUS_OBJECT_PRINTABLE_STATIC_PROTOTYPE)
00138
00139
00140
00141
00142
00143 extern const globus_object_type_t *
00144 globus_object_get_type (const globus_object_t * object);
00145
00146
00147
00148 extern const globus_object_type_t *
00149 globus_object_type_get_parent_type (const globus_object_type_t * type);
00150
00151
00152
00153 extern globus_bool_t
00154 globus_object_is_static (const globus_object_t * object);
00155
00156
00157
00158
00159 extern void *
00160 globus_object_type_get_class_data (const globus_object_type_t * type);
00161
00162
00163
00164 extern globus_bool_t
00165 globus_object_type_match (const globus_object_type_t * subtype,
00166 const globus_object_type_t * supertype);
00167
00168
00169
00170 extern globus_object_t *
00171 globus_object_upcast (globus_object_t * object,
00172 const globus_object_type_t * desired_type);
00173
00174
00175
00176
00177
00178
00179 extern void
00180 globus_object_set_local_instance_data (globus_object_t * object,
00181 void * instance_data);
00182
00183
00184 extern void *
00185 globus_object_get_local_instance_data (const globus_object_t * object);
00186
00187
00188
00189
00190 extern char *
00191 globus_object_printable_to_string (globus_object_t * object);
00192
00193 extern globus_object_printable_string_func_t
00194 globus_object_printable_get_string_func (globus_object_t * object);
00195
00196 #include "globus_module.h"
00197
00198 extern globus_module_descriptor_t globus_i_object_module;
00199
00200 #define GLOBUS_OBJECT_MODULE (&globus_i_object_module)
00201
00202 #ifdef __cplusplus
00203 }
00204 #endif
00205 #endif