13 |
|
if( next != NULL ) delete next; |
14 |
|
} |
15 |
|
|
16 |
+ |
void LinkedMolStamp::add( LinkedMolStamp* newbie ){ |
17 |
+ |
|
18 |
+ |
if( next != NULL ) next->add( newbie ); |
19 |
+ |
else{ |
20 |
+ |
next = newbie; |
21 |
+ |
next->setPrev( this ); |
22 |
+ |
} |
23 |
+ |
} |
24 |
+ |
|
25 |
|
MoleculeStamp* LinkedMolStamp::match( char* id ){ |
26 |
|
|
27 |
|
if( mol_stamp != NULL ){ |
28 |
< |
|
29 |
< |
if(!strcmp( mol_stamp->getID(), id )) return mol_stamp; |
30 |
< |
|
31 |
< |
if( next != NULL ) return next->match( id ); |
28 |
> |
if(!strcmp( mol_stamp->getID(), id )){ |
29 |
> |
|
30 |
> |
// make sure we aren't hiding somebody else with the same name |
31 |
> |
if(next != NULL ){ |
32 |
> |
if( next->match( id ) != NULL){ |
33 |
> |
sprintf( painCave.errMsg, |
34 |
> |
"Molecule Stamp Error. Two separate of declarations of " |
35 |
> |
"%s present.\n", |
36 |
> |
id ); |
37 |
> |
painCave.isFatal = 1; |
38 |
> |
simError(); |
39 |
> |
#ifdef IS_MPI |
40 |
> |
if( painCave.isEventLoop ){ |
41 |
> |
if( worldRank == 0 ) mpiInterfaceExit(); |
42 |
> |
} |
43 |
> |
#endif //is_mpi |
44 |
> |
} |
45 |
> |
else return mol_stamp; |
46 |
> |
} |
47 |
> |
else return mol_stamp; |
48 |
> |
} |
49 |
|
} |
50 |
|
|
51 |
+ |
if( next != NULL ) return next->match( id ); |
52 |
+ |
|
53 |
|
return NULL; |
54 |
|
} |
55 |
|
|
56 |
+ |
LinkedMolStamp* LinkedMolStamp::extract( char* id ){ |
57 |
+ |
|
58 |
+ |
if( mol_stamp != NULL ){ |
59 |
+ |
if(!strcmp( mol_stamp->getID(), id )){ |
60 |
+ |
|
61 |
+ |
// make sure we aren't hiding somebody else with the same name |
62 |
+ |
if(next != NULL ){ |
63 |
+ |
if( next->match( id ) != NULL){ |
64 |
+ |
sprintf( painCave.errMsg, |
65 |
+ |
"Molecule Stamp Error. Two separate of declarations of " |
66 |
+ |
"%s present.\n", |
67 |
+ |
id ); |
68 |
+ |
painCave.isFatal = 1; |
69 |
+ |
simError(); |
70 |
+ |
#ifdef IS_MPI |
71 |
+ |
if( painCave.isEventLoop ){ |
72 |
+ |
if( worldRank == 0 ) mpiInterfaceExit(); |
73 |
+ |
} |
74 |
+ |
#endif //is_mpi |
75 |
+ |
} |
76 |
+ |
} |
77 |
+ |
|
78 |
+ |
prev->setNext( next ); |
79 |
+ |
if( next != NULL ) next->setPrev( prev ); |
80 |
+ |
return this; |
81 |
+ |
} |
82 |
+ |
} |
83 |
+ |
|
84 |
+ |
if( next != NULL ) return next->extract( id ); |
85 |
+ |
|
86 |
+ |
return NULL; |
87 |
+ |
} |
88 |
+ |
|
89 |
|
MakeStamps::MakeStamps(){ |
90 |
|
|
91 |
|
int i; |
92 |
|
|
93 |
|
my_mols = new LinkedMolStamp*[hash_size]; |
94 |
|
for( i=0; i<hash_size; i++ ){ |
95 |
< |
my_mols[i] = NULL; |
95 |
> |
my_mols[i] = new LinkedMolStamp(); |
96 |
|
} |
97 |
|
|
98 |
|
} |
137 |
|
return key; |
138 |
|
} |
139 |
|
|
140 |
< |
MoleculeStamp* MakeStamps::getMolecule( char* the_id ){ |
140 |
> |
LinkedMolStamp* MakeStamps::extractMolStamp( char* the_id ){ |
141 |
|
int key; |
142 |
|
|
143 |
|
key = hash( the_id ); |
144 |
|
if( my_mols[key] != NULL ){ |
145 |
< |
return my_mols[key]->match( the_id ); |
145 |
> |
return my_mols[key]->extract( the_id ); |
146 |
|
} |
147 |
|
|
148 |
|
return NULL; |
157 |
|
|
158 |
|
linked_mol = new LinkedMolStamp; |
159 |
|
linked_mol->setStamp( the_stamp ); |
99 |
– |
linked_mol->setNext( my_mols[key] ); |
160 |
|
|
161 |
< |
my_mols[key] = linked_mol; |
161 |
> |
my_mols[key]->add( linked_mol ); |
162 |
> |
|
163 |
|
} |
164 |
|
|
165 |
|
|