⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sbobject.cpp

📁 Open VXI. This is a open source.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{  return SBobjectShutDown (log);}/** * Create a new object service handle * * @param resources  A pointer to a structure containing all the interfaces *                   that may be required by the object resource * * @result VXIobj_RESULT_SUCCESS on success  */SBOBJECT_API VXIobjResult SBobjectCreateResource(SBobjectResources   *resources,				    VXIobjectInterface **object){  static const wchar_t func[] = L"SBobjectCreateResource";  VXIlogInterface *log = NULL;  if (( resources ) && ( resources->log )) {    log = resources->log;    log->Diagnostic (log, gblDiagLogBase + LOG_API, func,		     L"entering: 0x%p, 0x%p", resources, object);  }  VXIobjResult rc = VXIobj_RESULT_SUCCESS;  if (gblInitialized == false) {    rc = VXIobj_RESULT_FATAL_ERROR;    if ( log )      log->Diagnostic (log, gblDiagLogBase + LOG_API, func,		       L"exiting: returned %d, 0x%p", 		       rc, (object ? *object : NULL));    return rc;  }  if (( ! log ) || ( ! resources ) || ( ! object )) {    rc = VXIobj_RESULT_INVALID_ARGUMENT;    if ( log )      log->Diagnostic (log, gblDiagLogBase + LOG_API, func,		       L"exiting: returned %d, 0x%p", 		       rc, (object ? *object : NULL));    return rc;  }  *object = NULL;  // Get a new interface instance  SBobjectInterface *newObject = new SBobjectInterface;  if (newObject == false) {    rc = VXIobj_RESULT_OUT_OF_MEMORY;    log->Diagnostic (log, gblDiagLogBase + LOG_API, func,		     L"exiting: returned %d, 0x%p", rc, *object);    return rc;  }  memset (newObject, 0, sizeof (SBobjectInterface));  // Initialize the function pointers  newObject->object.GetVersion            = SBobjectGetVersion;  newObject->object.GetImplementationName = SBobjectGetImplementationName;  newObject->object.Execute               = SBobjectExecute;  newObject->object.Validate              = SBobjectValidate;  // Initialize data members  newObject->resources = resources;  newObject->diagLogBase = gblDiagLogBase;  // Return the object  if ( rc != VXIobj_RESULT_SUCCESS ) {    if ( newObject )      delete newObject;  } else {    *object = &(newObject->object);  }  log->Diagnostic (log, gblDiagLogBase + LOG_API, func, 		   L"exiting: returned %d, 0x%p", rc, *object);  return rc;}OSBOBJECT_API VXIobjResult OSBobjectCreateResource(OSBobjectResources  *resources,				     VXIobjectInterface **object){  return SBobjectCreateResource ((SBobjectResources *) resources, object);}/** * Destroy the interface and free internal resources. Once this is *  called, the resource interfaces passed to SBobjectCreateResource( ) *  may be released as well. * * @result VXIobj_RESULT_SUCCESS on success  */SBOBJECT_API VXIobjResult SBobjectDestroyResource(VXIobjectInterface **object){  VXIobjResult rc = VXIobj_RESULT_SUCCESS;  static const wchar_t func[] = L"SBobjectDestroyResource";  // Can't log yet, don't have a log handle  if (gblInitialized == false)    return VXIobj_RESULT_FATAL_ERROR;  if ((object == NULL) || (*object == NULL))    return VXIobj_RESULT_INVALID_ARGUMENT;  // Get the real underlying interface  SBobjectInterface *sbObject = (SBobjectInterface *) *object;  VXIlogInterface *log = sbObject->resources->log;  log->Diagnostic (log, gblDiagLogBase + LOG_API, func, 		   L"entering: 0x%p (0x%p)", object, *object);  // Delete the object  delete sbObject;  *object = NULL;  log->Diagnostic (log, gblDiagLogBase + LOG_API, func,		   L"exiting: returned %d", rc);  return rc;}OSBOBJECT_API VXIobjResult OSBobjectDestroyResource(VXIobjectInterface **object){  return SBobjectDestroyResource (object);}/** * @name GetVersion * @memo Get the VXI interface version implemented * * @return  VXIint32 for the version number. The high high word is  *          the major version number, the low word is the minor version  *          number, using the native CPU/OS byte order. The current *          version is VXI_CURRENT_VERSION as defined in VXItypes.h. */ extern "C"VXIint32 SBobjectGetVersion(void){  return VXI_CURRENT_VERSION;}/** * @name GetImplementationName * @memo Get the name of the implementation * * @return  Implementation defined string that must be different from *          all other implementations. The recommended name is one *          where the interface name is prefixed by the implementator's *          Internet address in reverse order, such as com.xyz.rec for *          VXIobject from xyz.com. This is similar to how VoiceXML 1.0 *          recommends defining application specific error types. */extern "C"const VXIchar* SBobjectGetImplementationName(void){  return SBOBJECT_IMPLEMENTATION_NAME;}/** * Execute an object * * @param properties  [IN] Map containing properties and attributes for *                      the <object> as specified above. * @param parameters  [IN] Map containing parameters for the <object> as *                      specified by the VoiceXML <param> tag. The keys *                      of the map correspond to the parameter name ("name" *                      attribute) while the value of each key corresponds *                      to a VXIValue based type. * *                      For each parameter, any ECMAScript expressions are *                      evaluated by the interpreter. Then if the "valuetype" *                      attribute is set to "ref" the parameter value is *                      packaged into a VXIMap with three properties: * *                      OBJECT_VALUE:       actual parameter value *                      OBJECT_VALUETYPE:   "valuetype" attribute value *                      OBJECT_TYPE:        "type" attribute value * *                      Otherwise a primitive VXIValue based type will *                      be used to specify the value. * @param result      [OUT] Return value for the <object> execution, this *                      is allocated on success, the caller is responsible *                      for destroying the returned value by calling  *                      VXIValueDestroy( ). The object's field variable *                      will be set to this value. * * @return        VXIobj_RESULT_SUCCESS on success, *                VXIobj_RESULT_NON_FATAL_ERROR on error,  *                VXIobj_RESULT_UNSUPPORTED for unsupported object types *                 (this will cause interpreter to throw the correct event) */extern "C"VXIobjResult SBobjectExecute(struct VXIobjectInterface *pThis,			     const VXIMap              *properties,			     const VXIMap              *parameters,			     VXIValue                 **result){  static const wchar_t func[] = L"SBobjectExecute";  GET_SBOBJECT (pThis, sbObject, log, rc);  log->Diagnostic (log, sbObject->diagLogBase + LOG_API,		   func, L"entering: 0x%p, 0x%p, 0x%p, 0x%p", 		   pThis, properties, parameters, result);  if(properties == NULL) return VXIobj_RESULT_INVALID_ARGUMENT;  // Get the name of the object to execute  const VXIValue *val = VXIMapGetProperty(properties, OBJECT_CLASS_ID);  if(val == NULL) return VXIobj_RESULT_INVALID_PROP_VALUE;  const VXIchar *classID = VXIStringCStr((VXIString *)val);  // Handle the object  if (::wcscmp(classID, L"com.speechworks.diag") == 0) {    //    // Sample diagnostic logging object.    //     rc = ProcessComSpeechworksDiagObject(pThis, parameters, true, result);    if(rc != VXIobj_RESULT_SUCCESS) rc = VXIobj_RESULT_NON_FATAL_ERROR;  }   else if (::wcscmp(classID, L"com.speechworks.echo") == 0) {    //    // Sample object echoing back all attributes    //     rc = ProcessComSpeechworksEchoObject(pThis, properties, true, result);    if(rc != VXIobj_RESULT_SUCCESS) rc = VXIobj_RESULT_NON_FATAL_ERROR;  }   else {    //    // Unsupported object    //    rc = VXIobj_RESULT_UNSUPPORTED;  }  log->Diagnostic(log, sbObject->diagLogBase + LOG_API,		          func, L"exiting: returned %d", rc);  return rc;}/** * Validate an object, performing validity checks without execution * * @param properties  [IN] Map containing properties and attributes for *                      the <object> as specified in the VoiceXML *                      specification except that "expr" and "cond" are *                      always omitted (are handled by the interpreter). * @param parameters  [IN] Map containing parameters for the <object> as *                      specified by the VoiceXML <param> tag. The keys *                      of the map correspond to the parameter name ("name" *                      attribute) while the value of each key corresponds *                      to a VXIValue based type. See Execute( ) above  *                      for details. * * @return        VXIobj_RESULT_SUCCESS on success, *                VXIobj_RESULT_NON_FATAL_ERROR on error,  *                VXIobj_RESULT_UNSUPPORTED for unsupported object types *                 (this will cause interpreter to throw the correct event) */extern "C"VXIobjResult SBobjectValidate(struct VXIobjectInterface *pThis,			      const VXIMap              *properties,			      const VXIMap              *parameters){  static const wchar_t func[] = L"SBobjectValidate";  GET_SBOBJECT (pThis, sbObject, log, rc);  log->Diagnostic (log, sbObject->diagLogBase + LOG_API,		   func, L"entering: 0x%p, 0x%p, 0x%p", 		   pThis, properties, parameters);  if(properties == NULL) return VXIobj_RESULT_INVALID_ARGUMENT;  // Get the name of the object to execute  const VXIValue *val = VXIMapGetProperty(properties, OBJECT_CLASS_ID);  if(val == NULL) return VXIobj_RESULT_INVALID_PROP_VALUE;  const VXIchar *classID = VXIStringCStr((VXIString *)val);  // Handle the object  if (::wcscmp(classID, L"com.speechworks.diag") == 0) {    //    // Sample diagnostic logging object.    //     rc = ProcessComSpeechworksDiagObject(pThis, parameters, false, NULL);    if(rc != VXIobj_RESULT_SUCCESS) rc = VXIobj_RESULT_NON_FATAL_ERROR;  }  else if (::wcscmp(classID, L"com.speechworks.echo") == 0) {    //    // Sample object echoing back all attributes    //     rc = ProcessComSpeechworksEchoObject(pThis, properties, false, NULL);    if(rc != VXIobj_RESULT_SUCCESS) rc = VXIobj_RESULT_NON_FATAL_ERROR;  }   else {    //    // Unsupported object    //    rc = VXIobj_RESULT_UNSUPPORTED;  }  log->Diagnostic(log, sbObject->diagLogBase + LOG_API,		          func, L"exiting: returned %d", rc);  return rc;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -