BltModule.h

Go to the documentation of this file.
00001 /*****************************************************************
00002 |
00003 |   BlueTune - Module Interface
00004 |
00005 |   (c) 2002-2006 Gilles Boccon-Gibod
00006 |   Author: Gilles Boccon-Gibod (bok@bok.net)
00007 |
00008  ****************************************************************/
00013 #ifndef _BLT_MODULE_H_
00014 #define _BLT_MODULE_H_
00015 
00030 /*----------------------------------------------------------------------
00031 |   includes
00032 +---------------------------------------------------------------------*/
00033 #include "Atomix.h"
00034 #include "BltTypes.h"
00035 #include "BltCore.h"
00036 
00037 /*----------------------------------------------------------------------
00038 |   types
00039 +---------------------------------------------------------------------*/
00044 typedef enum {
00048     BLT_MODULE_PARAMETERS_TYPE_MEDIA_NODE_CONSTRUCTOR
00049 } BLT_ModuleParametersType;
00050 
00054 typedef unsigned char BLT_ModuleId[16];
00055 
00059 typedef struct {
00060     BLT_CString  name;
00061     BLT_ModuleId id;
00062     BLT_Flags    flags;
00063 } BLT_ModuleInfo;
00064 
00069 typedef struct {
00070     /* interfaces */
00071     ATX_IMPLEMENTS(BLT_Module);
00072     ATX_IMPLEMENTS(ATX_Referenceable);
00073 
00074     /* members */
00075     BLT_Cardinal   reference_count;
00076     BLT_ModuleInfo info;
00077 } BLT_BaseModule;
00078 
00079 /*----------------------------------------------------------------------
00080 |   constants
00081 +---------------------------------------------------------------------*/
00082 #define BLT_MODULE_PROBE_MATCH_DEFAULT 0
00083 #define BLT_MODULE_PROBE_MATCH_MIN     1
00084 #define BLT_MODULE_PROBE_MATCH_LOW     64
00085 #define BLT_MODULE_PROBE_MATCH_MEDIUM  128
00086 #define BLT_MODULE_PROBE_MATCH_HIGH    192
00087 #define BLT_MODULE_PROBE_MATCH_MAX     253
00088 #define BLT_MODULE_PROBE_MATCH_EXACT   254
00089 #define BLT_MODULE_PROBE_MATCH_FORCE   255
00090 
00091 /*----------------------------------------------------------------------
00092 |   error codes
00093 +---------------------------------------------------------------------*/
00094 #define BLT_ERROR_NO_MATCHING_MODULE (BLT_ERROR_BASE_MODULE - 0)
00095 
00096 /*----------------------------------------------------------------------
00097 |   BLT_Module interface
00098 +---------------------------------------------------------------------*/
00099 ATX_BEGIN_INTERFACE_DEFINITION(BLT_Module)
00107     BLT_Result (*GetInfo)(BLT_Module* self, BLT_ModuleInfo* info);
00108 
00118     BLT_Result (*Attach)(BLT_Module* self, BLT_Core* core);
00119 
00129     BLT_Result (*CreateInstance)(BLT_Module*              self,
00130                                  BLT_Core*                core,
00131                                  BLT_ModuleParametersType parameters_type,
00132                                  BLT_AnyConst             parameters,
00133                                  const ATX_InterfaceId*   interface_id,
00134                                  ATX_Object**             object);
00135 
00150     BLT_Result (*Probe)(BLT_Module*              self,
00151                         BLT_Core*                core,
00152                         BLT_ModuleParametersType parameters_type,
00153                         BLT_AnyConst             parameters,
00154                         BLT_Cardinal*            match);
00155 ATX_END_INTERFACE_DEFINITION
00156 
00157 /*----------------------------------------------------------------------
00158 |   convenience macros
00159 +---------------------------------------------------------------------*/
00160 #define BLT_Module_GetInfo(object, info) \
00161 ATX_INTERFACE(object)->GetInfo(object, info)
00162 
00163 #define BLT_Module_Attach(object, core) \
00164 ATX_INTERFACE(object)->Attach(object, core)
00165 
00166 #define BLT_Module_CreateInstance(object, core, parameters_type, parameters, interface_id, new_object) \
00167 ATX_INTERFACE(object)->CreateInstance(object,               \
00168                                       core,                 \
00169                                       parameters_type,      \
00170                                       parameters,           \
00171                                       interface_id,         \
00172                                       new_object)
00173 
00174 #define BLT_Module_Probe(object, core, type, query, match) \
00175 ATX_INTERFACE(object)->Probe(object, core, type, query, match)
00176 
00177 /*----------------------------------------------------------------------
00178 |   base methods
00179 +---------------------------------------------------------------------*/
00180 #if defined(__cplusplus)
00181 extern "C" {
00182 #endif
00183 
00184 BLT_Result
00185 BLT_BaseModule_Construct(BLT_BaseModule* self, 
00186                          BLT_CString     name, 
00187                          BLT_ModuleId    id,
00188                          BLT_Flags       flags);
00189 
00190 BLT_Result
00191 BLT_BaseModule_Destruct(BLT_BaseModule* self);
00192 
00193 BLT_Result
00194 BLT_BaseModule_Create(BLT_CString                name, 
00195                       BLT_ModuleId               id,
00196                       BLT_Flags                  flags,
00197                       const BLT_ModuleInterface* module_interface,
00198                       const ATX_ReferenceableInterface* referenceable_interface,
00199                       BLT_Module**               object);
00200 
00201 BLT_Result
00202 BLT_BaseModule_Destroy(BLT_BaseModule* self);
00203 
00204 BLT_DIRECT_METHOD
00205 BLT_BaseModule_GetInfo(BLT_Module* self, BLT_ModuleInfo* info);
00206 
00207 BLT_DIRECT_METHOD
00208 BLT_BaseModule_Attach(BLT_Module* self, BLT_Core* core);
00209 
00210 #if defined (__cplusplus)
00211 }
00212 #endif
00213 
00214 /*----------------------------------------------------------------------
00215 |   template macros
00216 +---------------------------------------------------------------------*/
00217 #define BLT_MODULE_IMPLEMENT_SIMPLE_CONSTRUCTOR(_module_class,      \
00218                                                 _module_name,       \
00219                                                 _module_flags)      \
00220 static BLT_Result                                                   \
00221 _module_class##_Create(BLT_Module** object)                         \
00222 {                                                                   \
00223     _module_class* module;                                          \
00224                                                                     \
00225     /* allocate memory for the object */                            \
00226     module = (_module_class*)                                       \
00227         ATX_AllocateZeroMemory(sizeof(_module_class));              \
00228                                                                     \
00229     /* construct the inherited object */                            \
00230     BLT_BaseModule_Construct(&ATX_BASE(module, BLT_BaseModule),     \
00231                              _module_name,                          \
00232                              NULL,                                  \
00233                              _module_flags);                        \
00234                                                                     \
00235     /* setup interfaces */                                          \
00236     ATX_SET_INTERFACE_EX(module, _module_class,                     \
00237                         BLT_BaseModule, BLT_Module);                \
00238     ATX_SET_INTERFACE_EX(module, _module_class,                     \
00239                          BLT_BaseModule, ATX_Referenceable);        \
00240     *object = &ATX_BASE_EX(module, BLT_BaseModule, BLT_Module);     \
00241     return BLT_SUCCESS;                                             \
00242 }
00243 
00246 #endif /* _BLT_MODULE_H_ */
00247 
00248 
00249 
00250