📄 ghmm_convertxmltoc.cpp
字号:
/* * * created: 26 Feb 2002 by Wasinee Rungsarityotin * authors: Wasinee Rungsarityotin (rungsari@molgen.mpg.de) * file : $Source: /cvsroot/ghmm/ghmm/ghmm++/GHMM_convertXMLtoC.cpp,v $ * $Id: GHMM_convertXMLtoC.cpp,v 1.4 2003/11/07 22:17:37 wasinee Exp $ * revision date : $Date: 2003/11/07 22:17:37 $ _Copyright (C) 1998-2001, ZAIK/ZPR, Universit鋞 zu K鰈n _ _This program is free software; you can redistribute it and/or modify _it under the terms of the GNU General Public License as published by _the Free Software Foundation; either version 2 of the License, or _(at your option) any later version. _ _This program is distributed in the hope that it will be useful, _but WITHOUT ANY WARRANTY; without even the implied warranty of _MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the _GNU General Public License for more details. _ _You should have received a copy of the GNU General Public License _along with this program; if not, write to the Free Software _Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA _ */#include <stdio.h>#include "ghmm/ghmm.h"#include "ghmm++/GHMM.h"#include "ghmm++/GHMM_ContinuousModel.h"#include "ghmm++/GHMM_GMLDoc.h"#include "ghmm++/GHMM_convertXMLtoC.h"// #include "ghmm++/templatetest.h"#ifdef HAVE_NAMESPACESusing namespace std;#endif/** This function is compiled as a C-function ( no C++ "name-mangled" ) so that we can read data from an XML-file into a C "struct", ( struct model and struct smodel ) @return Return a pointer to struct model_t which provides access to a C struct whose type must be forced at run-time by a user. Its type-tag is stored in a member variable "model_id" of model_t.*/model_t *graphmldoc_cwrapper(char *filename){ /* GHMM_GraphMLDoc doc; */ GHMM_GraphMLDoc doc; GHMM_SWDiscreteModel *dmo; GHMM_ContinuousModel *cmo; model_t *model_pt; void *tmpvoid; if ( doc.open(filename, "r") < 0 ) return NULL; doc.readDocument(); doc.close(); if ( (tmpvoid = calloc( 1, sizeof(model_t))) != NULL ) { model_pt = (model_t*) tmpvoid; } else { fprintf(stderr, "Cannot allocate memory\n"); model_pt = NULL; /* cannot allocate memory*/ return model_pt; } if ( doc.getDiscreteModel() != NULL ) { model_pt->model_id = DISCRETE; dmo = doc.getDiscreteModel(); model_pt->model_pt = (void*) sdmodel_copy((const sdmodel*) dmo->c_model); delete dmo; } else { fprintf(stderr, "XML format for continuous model not supported\n"); model_pt = NULL; //model_pt->model_id = CONTINUOUS; //cmo = doc.getContinuousModel(); // // Make a new copy so that we can free the pointer to a C++ object. // //model_pt->model_pt = (void*) smodel_copy((const smodel*) cmo->c_model); //delete dmo; } return model_pt;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -