Convert gmx_residuetype_t to a non-pointer
authorTeemu Murtola <teemu.murtola@gmail.com>
Thu, 5 Jun 2014 18:44:04 +0000 (21:44 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sun, 15 Jun 2014 18:26:56 +0000 (20:26 +0200)
This uses the agreed format for forward declarations in #1490.
This removes the need to include residuetypes.h in any headers, and can
serve as a simple demonstration of the concept.

Change-Id: Ia82d4f96a1ea97e97e11e9840563f8beebe268c8

13 files changed:
src/gromacs/fileio/pdbio.c
src/gromacs/gmxana/dlist.c
src/gromacs/gmxana/gmx_chi.c
src/gromacs/gmxana/gstat.h
src/gromacs/gmxpreprocess/gen_vsite.c
src/gromacs/gmxpreprocess/pdb2gmx.c
src/gromacs/gmxpreprocess/pdb2top.cpp
src/gromacs/gmxpreprocess/xlate.c
src/gromacs/gmxpreprocess/xlate.h
src/gromacs/topology/atomprop.cpp
src/gromacs/topology/index.cpp
src/gromacs/topology/residuetypes.cpp
src/gromacs/topology/residuetypes.h

index 39b8355b6d7be3f06da8243731574bfaf988da75..3b9cab7cab8f5dcdf3c8a927e37977769faf518c 100644 (file)
@@ -283,7 +283,7 @@ void write_pdbfile_indexed(FILE *out, const char *title,
     int               nlongname = 0;
     int               chainnum, lastchainnum;
     int               lastresind, lastchainresind;
-    gmx_residuetype_t rt;
+    gmx_residuetype_t*rt;
     const char       *p_restype;
     const char       *p_lastrestype;
 
index 90ac8732c9730ec8918819e8afc77a9f905e9bc9..4699d5e11ec8666574c7d3962aa3e24c33b70f11 100644 (file)
@@ -50,7 +50,7 @@
 t_dlist *mk_dlist(FILE *log,
                   t_atoms *atoms, int *nlist,
                   gmx_bool bPhi, gmx_bool bPsi, gmx_bool bChi, gmx_bool bHChi,
-                  int maxchi, int r0, gmx_residuetype_t rt)
+                  int maxchi, int r0, gmx_residuetype_t *rt)
 {
     int       ires, i, j, k, ii;
     t_dihatms atm, prev;
index b0f46c0a0906d0535826a45313430503c7c9a94b..82c7ee3dca16e9c3a5335a497b7027927a539791 100644 (file)
@@ -441,7 +441,7 @@ static int reset_em_all(int nlist, t_dlist dlist[], int nf,
     return j;
 }
 
-static void histogramming(FILE *log, int nbin, gmx_residuetype_t rt,
+static void histogramming(FILE *log, int nbin, gmx_residuetype_t *rt,
                           int nf, int maxchi, real **dih,
                           int nlist, t_dlist dlist[],
                           atom_id index[],
@@ -1354,7 +1354,7 @@ int gmx_chi(int argc, char *argv[])
     gmx_bool           bDo_rt, bDo_oh, bDo_ot, bDo_jc;
     real               dt = 0, traj_t_ns;
     output_env_t       oenv;
-    gmx_residuetype_t  rt;
+    gmx_residuetype_t *rt;
 
     atom_id            isize, *index;
     int                ndih, nactdih, nf;
index 7bfb9a257d04f876d663d1778f34a70e9a9fcbbb..bac6aeb27084522509467428dc20ea32517b1ad9 100644 (file)
 #include "../legacyheaders/oenv.h"
 #include "../commandline/pargs.h"
 #include "../topology/index.h"
-#include "../topology/residuetypes.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+struct gmx_residuetype_t;
+
 /***********************************************
  *
  *     A U T O C O R R E L A T I O N
@@ -398,7 +399,7 @@ gmx_bool has_dihedral(int Dih, t_dlist *dl);
 t_dlist *mk_dlist(FILE *log,
                   t_atoms *atoms, int *nlist,
                   gmx_bool bPhi, gmx_bool bPsi, gmx_bool bChi, gmx_bool bHChi,
-                  int maxchi, int r0, gmx_residuetype_t rt);
+                  int maxchi, int r0, struct gmx_residuetype_t *rt);
 
 void pr_dlist(FILE *fp, int nl, t_dlist dl[], real dt,  int printtype,
               gmx_bool bPhi, gmx_bool bPsi, gmx_bool bChi, gmx_bool bOmega, int maxchi);
index c3cdddb5976215c45a02f8239e03a5ec66a8e9ef..3bf6e6574bf88651585877e2aea1f092c7878bbd 100644 (file)
@@ -510,7 +510,7 @@ static void print_bonds(FILE *fp, int o2n[],
 }
 
 static int get_atype(int atom, t_atoms *at, int nrtp, t_restp rtp[],
-                     gmx_residuetype_t rt)
+                     gmx_residuetype_t *rt)
 {
     int      type;
     gmx_bool bNterm;
@@ -548,7 +548,7 @@ static int vsite_nm2type(const char *name, gpp_atomtype_t atype)
 }
 
 static real get_amass(int atom, t_atoms *at, int nrtp, t_restp rtp[],
-                      gmx_residuetype_t rt)
+                      gmx_residuetype_t *rt)
 {
     real     mass;
     gmx_bool bNterm;
@@ -1572,7 +1572,7 @@ void do_vsites(int nrtp, t_restp rtp[], gpp_atomtype_t atype,
     char            **db;
     int               nvsiteconf, nvsitetop, cmplength;
     gmx_bool          isN, planarN, bFound;
-    gmx_residuetype_t rt;
+    gmx_residuetype_t*rt;
 
     t_vsiteconf      *vsiteconflist;
     /* pointer to a list of CH3/NH3/NH2 configuration entries.
index cf0bc05f2fcfc1d0401cab1326c062447c908be9..5cead8e6c684e0f0d0e0b21adae01473e697ee34 100644 (file)
@@ -516,7 +516,7 @@ void write_posres(char *fn, t_atoms *pdba, real fc)
 static int read_pdball(const char *inf, const char *outf, char *title,
                        t_atoms *atoms, rvec **x,
                        int *ePBC, matrix box, gmx_bool bRemoveH,
-                       t_symtab *symtab, gmx_residuetype_t rt, const char *watres,
+                       t_symtab *symtab, gmx_residuetype_t *rt, const char *watres,
                        gmx_atomprop_t aps, gmx_bool bVerbose)
 /* Read a pdb file. (containing proteins) */
 {
@@ -837,7 +837,8 @@ static int remove_duplicate_atoms(t_atoms *pdba, rvec x[], gmx_bool bVerbose)
     return pdba->nr;
 }
 
-void find_nc_ter(t_atoms *pdba, int r0, int r1, int *r_start, int *r_end, gmx_residuetype_t rt)
+void find_nc_ter(t_atoms *pdba, int r0, int r1, int *r_start, int *r_end,
+                 gmx_residuetype_t *rt)
 {
     int         i;
     const char *p_startrestype;
@@ -1233,7 +1234,7 @@ int gmx_pdb2gmx(int argc, char *argv[])
     t_hackblock      *ah;
     t_symtab          symtab;
     gpp_atomtype_t    atype;
-    gmx_residuetype_t rt;
+    gmx_residuetype_t*rt;
     const char       *top_fn;
     char              fn[256], itp_fn[STRLEN], posre_fn[STRLEN], buf_fn[STRLEN];
     char              molname[STRLEN], title[STRLEN], quote[STRLEN];
index 676ba94c42dd60d9a053067411ea0f4b28093a83..9a688ce2dbe8ea6b08a96e181a8f7f5701bcb2fd 100644 (file)
@@ -442,7 +442,7 @@ void choose_watermodel(const char *wmsel, const char *ffdir,
 }
 
 static int name2type(t_atoms *at, int **cgnr, gpp_atomtype_t atype,
-                     t_restp restp[], gmx_residuetype_t rt)
+                     t_restp restp[], gmx_residuetype_t *rt)
 {
     int         i, j, prevresind, resind, i0, prevcg, cg, curcg;
     char       *name;
@@ -1426,7 +1426,7 @@ void match_atomnames_with_rtp(t_restp restp[], t_hackblock hb[],
 }
 
 #define NUM_CMAP_ATOMS 5
-static void gen_cmap(t_params *psb, t_restp *restp, t_atoms *atoms, gmx_residuetype_t rt)
+static void gen_cmap(t_params *psb, t_restp *restp, t_atoms *atoms, gmx_residuetype_t *rt)
 {
     int         residx, i, j, k;
     const char *ptr;
@@ -1540,7 +1540,7 @@ void pdb2top(FILE *top_file, char *posre_fn, char *molname,
     int              *vsite_type;
     int               i, nmissat;
     int               bts[ebtsNR];
-    gmx_residuetype_t rt;
+    gmx_residuetype_t*rt;
 
     init_plist(plist);
     gmx_residuetype_init(&rt);
index b9400345dd1a851aad6f5cc1dffa659ff27f51d7..28bb1546da615042a78e0e7e7693853c94b3155b 100644 (file)
@@ -138,7 +138,7 @@ static void done_xlatom(int nxlate, t_xlate_atom *xlatom)
 
 void rename_atoms(const char *xlfile, const char *ffdir,
                   t_atoms *atoms, t_symtab *symtab, const t_restp *restp,
-                  gmx_bool bResname, gmx_residuetype_t rt, gmx_bool bReorderNum,
+                  gmx_bool bResname, gmx_residuetype_t *rt, gmx_bool bReorderNum,
                   gmx_bool bVerbose)
 {
     FILE         *fp;
index 9ed45b9b75a5f5579443c8deb7dbcbbd91ba09e1..549aa4563b6bc1682b941752219fdd6fdbd173fa 100644 (file)
 #ifndef GMX_GMXPREPROCESS_XLATE_H
 #define GMX_GMXPREPROCESS_XLATE_H
 
-#include "gromacs/topology/residuetypes.h"
+#include "gromacs/utility/basedefinitions.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+struct gmx_residuetype_t;
+struct t_atoms;
+struct t_symtab;
+
 /* If bResname is true renames atoms based on residue names,
  * otherwise renames atoms based on rtp entry names.
  */
 void rename_atoms(const char *xlfile, const char *ffdir,
-                  t_atoms *atoms, struct t_symtab *symtab, const t_restp *restp,
-                  gmx_bool bResname, gmx_residuetype_t rt, gmx_bool bReorderNum,
+                  struct t_atoms *atoms, struct t_symtab *symtab, const t_restp *restp,
+                  gmx_bool bResname, struct gmx_residuetype_t *rt, gmx_bool bReorderNum,
                   gmx_bool bVerbose);
 
 #ifdef __cplusplus
index 5bba2874597b3b7332326de3b3a096c2c73f3b0c..727bf73884bf6385ebd4693e8fcd9d35414a38b5 100644 (file)
@@ -64,9 +64,9 @@ typedef struct {
 } aprop_t;
 
 typedef struct gmx_atomprop {
-    gmx_bool          bWarned, bWarnVDW;
-    aprop_t           prop[epropNR];
-    gmx_residuetype_t restype;
+    gmx_bool           bWarned, bWarnVDW;
+    aprop_t            prop[epropNR];
+    gmx_residuetype_t *restype;
 } gmx_atomprop;
 
 
@@ -95,7 +95,7 @@ static int dbcmp_len(char *search, char *database)
     return i;
 }
 
-static int get_prop_index(aprop_t *ap, gmx_residuetype_t restype,
+static int get_prop_index(aprop_t *ap, gmx_residuetype_t *restype,
                           char *resnm, char *atomnm,
                           gmx_bool *bExact)
 {
@@ -156,7 +156,7 @@ static int get_prop_index(aprop_t *ap, gmx_residuetype_t restype,
     return j;
 }
 
-static void add_prop(aprop_t *ap, gmx_residuetype_t restype,
+static void add_prop(aprop_t *ap, gmx_residuetype_t *restype,
                      char *resnm, char *atomnm,
                      real p, int line)
 {
index d0afa4658f67603542ad3c573dd930523bf209df..9524f65e7b7a2a4512363d7f6d2b7e938eb5a2f0 100644 (file)
@@ -577,7 +577,7 @@ static void analyse_prot(const char ** restype, t_atoms *atoms,
 
 void analyse(t_atoms *atoms, t_blocka *gb, char ***gn, gmx_bool bASK, gmx_bool bVerb)
 {
-    gmx_residuetype_t rt = NULL;
+    gmx_residuetype_t*rt = NULL;
     char             *resnm;
     atom_id          *aid;
     const char    **  restype;
index 461405b82f4028e44fae24d3a5e0e782cbf24672..26fcff3e0c905a395f9c2b7245afb784a5d7f5af 100644 (file)
@@ -45,7 +45,7 @@
 
 const char gmx_residuetype_undefined[] = "Other";
 
-struct gmx_residuetype
+struct gmx_residuetype_t
 {
     int      n;
     char **  resname;
@@ -53,12 +53,12 @@ struct gmx_residuetype
 };
 
 int
-gmx_residuetype_init(gmx_residuetype_t *prt)
+gmx_residuetype_init(gmx_residuetype_t **prt)
 {
     FILE                 *  db;
     char                    line[STRLEN];
     char                    resname[STRLEN], restype[STRLEN], dum[STRLEN];
-    struct gmx_residuetype *rt;
+    gmx_residuetype_t      *rt;
 
     snew(rt, 1);
     *prt = rt;
@@ -89,7 +89,7 @@ gmx_residuetype_init(gmx_residuetype_t *prt)
 }
 
 int
-gmx_residuetype_destroy(gmx_residuetype_t rt)
+gmx_residuetype_destroy(gmx_residuetype_t *rt)
 {
     int i;
 
@@ -109,7 +109,7 @@ gmx_residuetype_destroy(gmx_residuetype_t rt)
  * p_restype is set to a pointer to the type name, or 'Other' if we did not find it.
  */
 int
-gmx_residuetype_get_type(gmx_residuetype_t rt, const char * resname, const char ** p_restype)
+gmx_residuetype_get_type(gmx_residuetype_t *rt, const char * resname, const char ** p_restype)
 {
     int    i, rc;
 
@@ -125,7 +125,7 @@ gmx_residuetype_get_type(gmx_residuetype_t rt, const char * resname, const char
 }
 
 int
-gmx_residuetype_add(gmx_residuetype_t rt, const char *newresname, const char *newrestype)
+gmx_residuetype_add(gmx_residuetype_t *rt, const char *newresname, const char *newrestype)
 {
     int           found;
     const char *  p_oldtype;
@@ -151,7 +151,7 @@ gmx_residuetype_add(gmx_residuetype_t rt, const char *newresname, const char *ne
 }
 
 int
-gmx_residuetype_get_alltypes(gmx_residuetype_t    rt,
+gmx_residuetype_get_alltypes(gmx_residuetype_t   *rt,
                              const char ***       p_typenames,
                              int *                ntypes)
 {
@@ -183,7 +183,7 @@ gmx_residuetype_get_alltypes(gmx_residuetype_t    rt,
 }
 
 gmx_bool
-gmx_residuetype_is_protein(gmx_residuetype_t rt, const char *resnm)
+gmx_residuetype_is_protein(gmx_residuetype_t *rt, const char *resnm)
 {
     gmx_bool    rc;
     const char *p_type;
@@ -201,7 +201,7 @@ gmx_residuetype_is_protein(gmx_residuetype_t rt, const char *resnm)
 }
 
 gmx_bool
-gmx_residuetype_is_dna(gmx_residuetype_t rt, const char *resnm)
+gmx_residuetype_is_dna(gmx_residuetype_t *rt, const char *resnm)
 {
     gmx_bool    rc;
     const char *p_type;
@@ -219,7 +219,7 @@ gmx_residuetype_is_dna(gmx_residuetype_t rt, const char *resnm)
 }
 
 gmx_bool
-gmx_residuetype_is_rna(gmx_residuetype_t rt, const char *resnm)
+gmx_residuetype_is_rna(gmx_residuetype_t *rt, const char *resnm)
 {
     gmx_bool    rc;
     const char *p_type;
@@ -238,7 +238,7 @@ gmx_residuetype_is_rna(gmx_residuetype_t rt, const char *resnm)
 
 /* Return the size of the arrays */
 int
-gmx_residuetype_get_size(gmx_residuetype_t rt)
+gmx_residuetype_get_size(gmx_residuetype_t *rt)
 {
     return rt->n;
 }
@@ -248,7 +248,7 @@ gmx_residuetype_get_size(gmx_residuetype_t rt)
  * otherwise -1.
  */
 int
-gmx_residuetype_get_index(gmx_residuetype_t rt, const char *resnm)
+gmx_residuetype_get_index(gmx_residuetype_t *rt, const char *resnm)
 {
     int i, rc;
 
@@ -264,7 +264,7 @@ gmx_residuetype_get_index(gmx_residuetype_t rt, const char *resnm)
 /* Return the name of the residuetype with the given index, or
  * NULL if not found. */
 const char *
-gmx_residuetype_get_name(gmx_residuetype_t rt, int index)
+gmx_residuetype_get_name(gmx_residuetype_t *rt, int index)
 {
     if (index >= 0 && index < rt->n)
     {
index 82c24e8b0b75ca37c32f8f08b9554e32687113cc..f569e008f96ff3b64b585f299373007e81ae6869 100644 (file)
@@ -42,42 +42,42 @@ extern "C"
 {
 #endif
 
-typedef struct gmx_residuetype *gmx_residuetype_t;
+typedef struct gmx_residuetype_t gmx_residuetype_t;
 
 int
-gmx_residuetype_init(gmx_residuetype_t *rt);
+gmx_residuetype_init(gmx_residuetype_t **rt);
 
 int
-gmx_residuetype_destroy(gmx_residuetype_t rt);
+gmx_residuetype_destroy(gmx_residuetype_t *rt);
 
 int
-gmx_residuetype_get_type(gmx_residuetype_t rt, const char *resname, const char **p_restype);
+gmx_residuetype_get_type(gmx_residuetype_t *rt, const char *resname, const char **p_restype);
 
 int
-gmx_residuetype_add(gmx_residuetype_t rt, const char *newresname, const char *newrestype);
+gmx_residuetype_add(gmx_residuetype_t *rt, const char *newresname, const char *newrestype);
 
 int
-gmx_residuetype_get_alltypes(gmx_residuetype_t    rt,
+gmx_residuetype_get_alltypes(gmx_residuetype_t   *rt,
                              const char        ***p_typenames,
                              int                 *ntypes);
 
 gmx_bool
-gmx_residuetype_is_protein(gmx_residuetype_t rt, const char *resnm);
+gmx_residuetype_is_protein(gmx_residuetype_t *rt, const char *resnm);
 
 gmx_bool
-gmx_residuetype_is_dna(gmx_residuetype_t rt, const char *resnm);
+gmx_residuetype_is_dna(gmx_residuetype_t *rt, const char *resnm);
 
 gmx_bool
-gmx_residuetype_is_rna(gmx_residuetype_t rt, const char *resnm);
+gmx_residuetype_is_rna(gmx_residuetype_t *rt, const char *resnm);
 
 int
-gmx_residuetype_get_size(gmx_residuetype_t rt);
+gmx_residuetype_get_size(gmx_residuetype_t *rt);
 
 int
-gmx_residuetype_get_index(gmx_residuetype_t rt, const char *resnm);
+gmx_residuetype_get_index(gmx_residuetype_t *rt, const char *resnm);
 
 const char *
-gmx_residuetype_get_name(gmx_residuetype_t rt, int index);
+gmx_residuetype_get_name(gmx_residuetype_t *rt, int index);
 
 #ifdef __cplusplus
 }