Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "ltkc_platform.h"
00023 #include "ltkc_base.h"
00024
00025
00026
00027
00028
00029 LLRP_tSTypeRegistry *
00030 LLRP_TypeRegistry_construct (void)
00031 {
00032 LLRP_tSTypeRegistry * pTypeRegistry;
00033
00034 pTypeRegistry = (LLRP_tSTypeRegistry *) malloc(sizeof *pTypeRegistry);
00035 if(NULL == pTypeRegistry)
00036 {
00037 return pTypeRegistry;
00038 }
00039
00040 memset(pTypeRegistry, 0, sizeof *pTypeRegistry);
00041
00042 return pTypeRegistry;
00043 }
00044
00045
00046 void
00047 LLRP_TypeRegistry_destruct (
00048 LLRP_tSTypeRegistry * pTypeRegistry)
00049 {
00050 memset(pTypeRegistry, 0, sizeof *pTypeRegistry);
00051 free(pTypeRegistry);
00052 }
00053
00054
00055 LLRP_tResultCode
00056 LLRP_TypeRegistry_enroll (
00057 LLRP_tSTypeRegistry * pTypeRegistry,
00058 const LLRP_tSTypeDescriptor * pTypeDescriptor)
00059 {
00060 if(NULL == pTypeDescriptor->pVendorDescriptor)
00061 {
00062 if(1023u < pTypeDescriptor->TypeNum)
00063 {
00064 return LLRP_RC_EnrollBadTypeNumber;
00065 }
00066
00067
00068
00069
00070 if(pTypeDescriptor->bIsMessage)
00071 {
00072 pTypeRegistry->apStdMessageTypeDescriptors[
00073 pTypeDescriptor->TypeNum] = pTypeDescriptor;
00074 }
00075 else
00076 {
00077 pTypeRegistry->apStdParameterTypeDescriptors[
00078 pTypeDescriptor->TypeNum] = pTypeDescriptor;
00079 }
00080 }
00081 else
00082 {
00083
00084
00085
00086 if(pTypeDescriptor->bIsMessage)
00087 {
00088 unsigned int ix;
00089
00090 ix = pTypeRegistry->nCustMessageTypeDescriptors++;
00091 pTypeRegistry->apCustMessageTypeDescriptors[ix] =
00092 pTypeDescriptor;
00093 }
00094 else
00095 {
00096 unsigned int ix;
00097
00098 ix = pTypeRegistry->nCustParameterTypeDescriptors++;
00099 pTypeRegistry->apCustParameterTypeDescriptors[ix] =
00100 pTypeDescriptor;
00101 }
00102 }
00103
00104 return LLRP_RC_OK;
00105 }
00106
00107
00108 const LLRP_tSTypeDescriptor *
00109 LLRP_TypeRegistry_lookupMessage (
00110 const LLRP_tSTypeRegistry * pTypeRegistry,
00111 unsigned int MessageTypeNum)
00112 {
00113 if(1023u < MessageTypeNum)
00114 {
00115 return NULL;
00116 }
00117
00118 return pTypeRegistry->apStdMessageTypeDescriptors[MessageTypeNum];
00119 }
00120
00121
00122 const LLRP_tSTypeDescriptor *
00123 LLRP_TypeRegistry_lookupParameter (
00124 const LLRP_tSTypeRegistry * pTypeRegistry,
00125 unsigned int ParameterTypeNum)
00126 {
00127 if(1023u < ParameterTypeNum)
00128 {
00129 return NULL;
00130 }
00131
00132 return pTypeRegistry->apStdParameterTypeDescriptors[ParameterTypeNum];
00133 }
00134
00135
00136 const LLRP_tSTypeDescriptor *
00137 LLRP_TypeRegistry_lookupCustomMessage (
00138 const LLRP_tSTypeRegistry * pTypeRegistry,
00139 unsigned int VendorID,
00140 unsigned int MessageSubTypeNum)
00141 {
00142 const LLRP_tSTypeDescriptor *pTypeDescriptor;
00143 unsigned int ix;
00144
00145 for(ix = 0; ix < pTypeRegistry->nCustMessageTypeDescriptors; ix++)
00146 {
00147 pTypeDescriptor = pTypeRegistry->apCustMessageTypeDescriptors[ix];
00148 if(VendorID == pTypeDescriptor->pVendorDescriptor->VendorID &&
00149 MessageSubTypeNum == pTypeDescriptor->TypeNum)
00150 {
00151 return pTypeDescriptor;
00152 }
00153 }
00154
00155 return NULL;
00156 }
00157
00158
00159 const LLRP_tSTypeDescriptor *
00160 LLRP_TypeRegistry_lookupCustomParameter (
00161 const LLRP_tSTypeRegistry * pTypeRegistry,
00162 unsigned int VendorID,
00163 unsigned int ParameterSubTypeNum)
00164 {
00165 const LLRP_tSTypeDescriptor *pTypeDescriptor;
00166 unsigned int ix;
00167
00168 for(ix = 0; ix < pTypeRegistry->nCustParameterTypeDescriptors; ix++)
00169 {
00170 pTypeDescriptor = pTypeRegistry->apCustParameterTypeDescriptors[ix];
00171 if(VendorID == pTypeDescriptor->pVendorDescriptor->VendorID &&
00172 ParameterSubTypeNum == pTypeDescriptor->TypeNum)
00173 {
00174 return pTypeDescriptor;
00175 }
00176 }
00177
00178 return NULL;
00179 }
00180
00181
00182 const LLRP_tSTypeDescriptor *
00183 LLRP_TypeRegistry_lookupByName (
00184 const LLRP_tSTypeRegistry * pTypeRegistry,
00185 const char * pElementName)
00186 {
00187 unsigned int i;
00188 const LLRP_tSTypeDescriptor *pTypeDescriptor;
00189
00190 for(i = 0; i < 1024u; i++)
00191 {
00192 pTypeDescriptor = pTypeRegistry->apStdMessageTypeDescriptors[i];
00193 if(NULL == pTypeDescriptor)
00194 {
00195 continue;
00196 }
00197
00198 if(0 == strcmp(pTypeDescriptor->pName, pElementName))
00199 {
00200 return pTypeDescriptor;
00201 }
00202 }
00203
00204 for(i = 0; i < 1024u; i++)
00205 {
00206 pTypeDescriptor = pTypeRegistry->apStdParameterTypeDescriptors[i];
00207 if(NULL == pTypeDescriptor)
00208 {
00209 continue;
00210 }
00211
00212 if(0 == strcmp(pTypeDescriptor->pName, pElementName))
00213 {
00214 return pTypeDescriptor;
00215 }
00216 }
00217
00218
00219
00220
00221 return NULL;
00222 }
00223