struct t_trxframe { %TypeHeaderCode #include #include "vec.h" %End int flags; int not_ok; bool bDouble; int natoms; double t0; double tf; double tpf; double tppf; bool bTitle; const char *title; bool bStep; int step; bool bTime; double time; bool bLambda; bool bFepState; double lambda; int fep_state; bool bAtoms; // TODO /*void *atoms;*/ bool bPrec; double prec; bool bX; rvec *x { %GetCode rvecs *arr = new rvecs(sipCpp->x, sipCpp->natoms); sipPy = sipConvertFromNewType(arr, sipType_rvecs, NULL); %End %SetCode %End }; bool bV; rvec *v { %GetCode rvecs *arr = new rvecs(sipCpp->v, sipCpp->natoms); sipPy = sipConvertFromNewType(arr, sipType_rvecs, NULL); %End %SetCode %End }; bool bF; rvec *f { %GetCode rvecs *arr = new rvecs(sipCpp->f, sipCpp->natoms); sipPy = sipConvertFromNewType(arr, sipType_rvecs, NULL); %End %SetCode %End }; bool bBox; matrix box { %GetCode Matrix *mat = new Matrix(sipCpp->box); sipPy = sipConvertFromNewType(mat, sipType_Matrix, NULL); %End %SetCode %End }; bool bPBC; int ePBC; // TODO /*t_gmxvmdplugin* *vmdplugin; */ }; struct t_pbc { %TypeHeaderCode #include #include "vec.h" %End int ePBC; int ndim_ePBC; int ePBCDX; int dim; matrix box { %GetCode Matrix *mat = new Matrix(sipCpp->box); sipPy = sipConvertFromNewType(mat, sipType_Matrix, NULL); %End %SetCode %End }; rvec fbox_diag { %GetCode py_rvec *vec = new py_rvec(sipCpp->fbox_diag); sipPy = sipConvertFromNewType(vec, sipType_py_rvec, NULL); %End %SetCode %End }; rvec hbox_diag { %GetCode py_rvec *vec = new py_rvec(sipCpp->fbox_diag); sipPy = sipConvertFromNewType(vec, sipType_py_rvec, NULL); %End %SetCode %End }; rvec mhbox_diag { %GetCode py_rvec *vec = new py_rvec(sipCpp->mhbox_diag); sipPy = sipConvertFromNewType(vec, sipType_py_rvec, NULL); %End %SetCode %End }; double max_cutoff2; bool bLimitDistance; double limit_distance2; int ntric_vec; /*ivec tric_shift[MAX_NTRICVEC];*/ /*rvec tric_vec[MAX_NTRICVEC];*/ }; class TrajectoryAnalysisModuleData /NoDefaultCtors/ { %TypeHeaderCode #include using namespace gmx; %End public: virtual void finish() = 0; }; class TrajectoryAnalysisModule { %TypeHeaderCode #include using namespace gmx; %End public: virtual void initOptions(Options *options, TrajectoryAnalysisSettings *settings) = 0; virtual void optionsFinished(Options *options, TrajectoryAnalysisSettings *settings); virtual void initAnalysis(const TrajectoryAnalysisSettings &settings, const TopologyInformation &top) = 0; virtual void initAfterFirstFrame(const TrajectoryAnalysisSettings &settings, const t_trxframe &fr); // virtual TrajectoryAnalysisModuleDataPointer startFrames (const AnalysisDataParallelOptions &opt, const SelectionCollection &selections); virtual void analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc, TrajectoryAnalysisModuleData *pdata ) = 0; virtual void finishFrames(TrajectoryAnalysisModuleData *pdata); virtual void finishAnalysis(int nframes) = 0; virtual void writeOutput() = 0; const char* name() const; const char* description() const; int datasetCount() const; protected: TrajectoryAnalysisModule(const char *name, const char *description); private: TrajectoryAnalysisModule(const TrajectoryAnalysisModule &other); }; %Exception gmx::InconsistentInputError(SIP_Exception) { %TypeHeaderCode #include using namespace std; %End %RaiseCode printf("lALLA\n"); const char *detail = sipExceptionRef.what(); SIP_BLOCK_THREADS PyErr_SetString(sipException_gmx_InconsistentInputError, detail); SIP_UNBLOCK_THREADS %End }; class TrajectoryAnalysisCommandLineRunner { %TypeHeaderCode #include %End public: TrajectoryAnalysisCommandLineRunner(TrajectoryAnalysisModule *module); int run(SIP_PYLIST) throw (gmx::InconsistentInputError); %MethodCode int argc = PyList_GET_SIZE(a0); char **argv = new char *[argc + 1]; // Convert the list. for (int a = 0; a < argc; ++a) { PyObject *arg_obj = PyList_GET_ITEM(a0, a); const char *arg = sipString_AsLatin1String(&arg_obj); if (arg) { arg = strdup(arg); Py_DECREF(arg_obj); } else { arg = "unknown"; } argv[a] = const_cast(arg); } argv[argc] = NULL; try { sipCpp->run(argc, argv); } catch (gmx::InconsistentInputError &e) { sipIsErr = 1; PyErr_SetString(sipException_gmx_InconsistentInputError, e.what()); } %End private: TrajectoryAnalysisCommandLineRunner(const TrajectoryAnalysisCommandLineRunner &other); };