当前位置: 首页>>代码示例>>C++>>正文


C++ VMDApp::plugin_dlopen方法代码示例

本文整理汇总了C++中VMDApp::plugin_dlopen方法的典型用法代码示例。如果您正苦于以下问题:C++ VMDApp::plugin_dlopen方法的具体用法?C++ VMDApp::plugin_dlopen怎么用?C++ VMDApp::plugin_dlopen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VMDApp的用法示例。


在下文中一共展示了VMDApp::plugin_dlopen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: text_cmd_plugin

int text_cmd_plugin(ClientData cd, Tcl_Interp *interp, int argc,
                     const char *argv[]) {

  VMDApp *app = (VMDApp *)cd;
  if (!app) 
    return TCL_ERROR;

  // plugin dlopen <filename>
  if (argc == 3 && !strupncmp(argv[1], "dlopen", CMDLEN)) {
    int rc = app->plugin_dlopen(argv[2]);
    if (rc < 0) {
      Tcl_AppendResult(interp, "Unable to dlopen plugin file ", argv[2], NULL);
      return TCL_ERROR;
    } 
    Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
    return TCL_OK;
  }
  // plugin update  -- updates list of plugins
  if (argc == 2 && !strupncmp(argv[1], "update", CMDLEN)) {
    app->plugin_update();
    return TCL_OK;
  }

  // plugin list [type]: returns list of category/name pairs.  If optional
  // type is specified, return only plugins of that type.
  if ((argc == 2 || argc == 3) && !strupncmp(argv[1], "list", CMDLEN)) {
    const char *type = NULL;
    if (argc == 3)
      type = argv[2];
    
    PluginList pluginlist;
    app->list_plugins(pluginlist, type);
    const int num = pluginlist.num();
    Tcl_Obj *result = Tcl_NewListObj(0, NULL);
    for (int i=0; i<num; i++) {
      vmdplugin_t *p = pluginlist[i];
      Tcl_Obj *listelem = Tcl_NewListObj(0, NULL);
      Tcl_ListObjAppendElement(interp, listelem, Tcl_NewStringObj(p->type,-1));
      Tcl_ListObjAppendElement(interp, listelem, Tcl_NewStringObj(p->name,-1));
      Tcl_ListObjAppendElement(interp, result, listelem);
    }
    Tcl_SetObjResult(interp, result);
    return TCL_OK;
  }
  // plugin info <type> <name> <varname>
  // Puts plugin information for the specified plugin into the array variable
  // specified by varname.  The following array keys will be used: type,
  // name, author, majorversion, minorversion, reentrant.
  // returns 1 if plugin information was found, or 0 if no plugin information
  // is available for that type and name.
  if (argc == 5 && !strupncmp(argv[1], "info", CMDLEN)) {
    vmdplugin_t *p = app->get_plugin(argv[2], argv[3]);
    if (!p) {
      Tcl_SetResult(interp, (char *) "0", TCL_STATIC);
      return TCL_OK;
    }
    char major[32], minor[32], reentrant[32];
    sprintf(major, "%d", p->majorv);
    sprintf(minor, "%d", p->minorv);
    sprintf(reentrant, "%d", p->is_reentrant);

    if (!Tcl_SetVar2(interp,argv[4], "type", p->type, TCL_LEAVE_ERR_MSG) ||
        !Tcl_SetVar2(interp,argv[4], "name", p->name, TCL_LEAVE_ERR_MSG) ||
        !Tcl_SetVar2(interp,argv[4], "author", p->author, TCL_LEAVE_ERR_MSG)  ||
        !Tcl_SetVar2(interp,argv[4], "majorversion", major, TCL_LEAVE_ERR_MSG) ||
        !Tcl_SetVar2(interp,argv[4], "minorversion", minor, TCL_LEAVE_ERR_MSG) ||
        !Tcl_SetVar2(interp,argv[4], "reentrant", reentrant, TCL_LEAVE_ERR_MSG)) {
      Tcl_AppendResult(interp, "Unable to return plugin information in variable ", argv[4], NULL);
      return TCL_ERROR;
    }
    Tcl_SetResult(interp, (char *) "1", TCL_STATIC);
    return TCL_OK;
  }
  Tcl_AppendResult(interp, "Usage: \n\tplugin dlopen <filename> -- Load plugins from a dynamic library\n",
      "\tplugin update -- Update the list of plugins in the GUI\n",
      "\tplugin list [<plugin type>] -- List all plugins of the given type\n", 
      "\tplugin info <type> <name> <arrayname> -- Store info about plugin in array\n",
      NULL);
  return TCL_ERROR;
}
开发者ID:Eigenstate,项目名称:vmd-python,代码行数:80,代码来源:cmd_plugin.C


注:本文中的VMDApp::plugin_dlopen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。