Show
Ignore:
Timestamp:
05/11/08 12:53:42 (8 months ago)
Author:
rjrw
Message:

Change molecule structure to class

Make molecular column table easier to navigate (after Nick Abel's
suggestion).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/newmole/source/mole_species.cpp

    r2027 r2042  
    5050#include <functional> 
    5151 
    52 class MoleCmp : public binary_function<const struct molecule *,const struct molecule *,bool> 
     52class MoleCmp : public binary_function<const molecule *,const molecule *,bool> 
    5353{ 
    5454public: 
    55         bool operator()(const struct molecule *mol1, const struct molecule *mol2) const 
     55        bool operator()(const molecule *mol1, const molecule *mol2) const 
    5656        { 
    5757                for (long nelem=LIMELM-1; nelem >= ipHYDROGEN; nelem--)  
    5858                { 
    5959                        if (mol1->nElem[nelem] > mol2->nElem[nelem]) 
     60                        { 
    6061                                return false; 
     62                        } 
    6163                        else if (mol1->nElem[nelem] < mol2->nElem[nelem]) 
     64                        { 
    6265                                return true;             
     66                        } 
    6367                }  
    6468                return strcmp(mol1->label,mol2->label) < 0; 
     
    7478        long int i, 
    7579                nelem; 
    76         struct molecule *sp; 
     80        molecule *sp; 
    7781        static realnum one=1.0; 
    7882        static bool lgmole_Init_called=false; 
     
    411415#include <string.h> 
    412416#include <ctype.h> 
    413 STATIC struct molecule *newspecies( 
     417STATIC molecule *newspecies( 
    414418        const char label[7],  
    415419        enum spectype type,  
     
    421425        char mylab[7], thisel[3], *s; 
    422426        long int i, n, nelem, nel; 
    423         struct molecule *mol; 
     427        molecule *mol; 
    424428        struct chem_element_s *el; 
    425429 
    426430        DEBUG_ENTRY("newspecies()"); 
    427431 
    428         mol = (struct molecule *) MALLOC(sizeof(struct molecule)); 
     432        mol = (molecule *) MALLOC(sizeof(molecule)); 
    429433 
    430434        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
     
    568572        return mol; 
    569573} 
    570 STATIC bool isactive(struct molecule *p) 
     574STATIC bool isactive(molecule *p) 
    571575{ 
    572576        DEBUG_ENTRY("isactive()"); 
    573577        return p->state == MOLE_ACTIVE; 
    574578} 
    575 STATIC bool ispassive(struct molecule *p) 
     579STATIC bool ispassive(molecule *p) 
    576580{ 
    577581 
     
    580584} 
    581585 
    582 struct molecule *findspecies(const char buf[]) 
     586molecule *findspecies(const char buf[]) 
    583587{ 
    584588        molecule_i p; 
     
    745749{ 
    746750        long int nelem; 
    747         struct molecule *mol1=*(struct molecule **)m1, *mol2=*(struct molecule **)m2; 
     751        molecule *mol1=*(molecule **)m1, *mol2=*(molecule **)m2; 
    748752 
    749753        for (nelem=LIMELM-1; nelem >= ipHYDROGEN; nelem--)  
     
    844848                return; 
    845849        } 
    846         groupspecies = (struct molecule **) MALLOC(mole.num_calc*sizeof(struct molecule *)); 
     850        groupspecies = (molecule **) MALLOC(mole.num_calc*sizeof(molecule *)); 
    847851        for (i=0,j=0;i<mole.num_calc;i++)  
    848852        { 
     
    862866        } 
    863867        mole.num_compacted = j; 
    864         groupspecies = (struct molecule **) REALLOC((void *)groupspecies, 
    865                 mole.num_calc*sizeof(struct molecule *)); 
     868        groupspecies = (molecule **) REALLOC((void *)groupspecies, 
     869                mole.num_calc*sizeof(molecule *)); 
    866870 
    867871        for (i=0;i<mole.num_calc;i++)