ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/types/CutoffGroupStamp.cpp
Revision: 1883
Committed: Mon Dec 13 22:30:27 2004 UTC (19 years, 7 months ago) by tim
File size: 2588 byte(s)
Log Message:
MPI version is built

File Contents

# Content
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <iostream>
5
6 #include "types/CutoffGroupStamp.hpp"
7
8 char CutoffGroupStamp::errMsg[500];
9
10 CutoffGroupStamp::CutoffGroupStamp(){
11
12 unhandled = NULL;
13 have_members = 0;
14 have_extras = 0;
15 n_members = 0;
16 which = 0;
17
18 }
19
20 CutoffGroupStamp::~CutoffGroupStamp(){
21 if( unhandled != NULL ) delete unhandled;
22
23 free(members);
24
25 }
26
27 char* CutoffGroupStamp::assignString( char* lhs, char* rhs ){
28
29 if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs );
30 else unhandled->add( lhs, rhs );
31 have_extras = 1;
32 return NULL;
33
34 }
35
36 char* CutoffGroupStamp::assignDouble( char* lhs, double rhs ){
37 if( !strcmp( lhs, "nMembers" ) ){
38 n_members = (int)rhs;
39
40 if( have_members ){
41 sprintf( errMsg,
42 "CutoffGroupStamp error, nMembers already declared"
43 " for this CutoffGroup.\n");
44 return strdup( errMsg );
45 }
46 have_members = 1;
47 members = (int *) calloc(n_members, sizeof(int));
48 }
49 else {
50 if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs );
51 else unhandled->add( lhs, rhs );
52 have_extras = 1;
53 }
54 return NULL;
55 }
56
57 char* CutoffGroupStamp::assignInt( char* lhs, int rhs ){
58 if( !strcmp( lhs, "nMembers" ) ){
59 n_members = rhs;
60
61 if( have_members ){
62 sprintf( errMsg,
63 "CutoffGroupStamp error, nMembers already declared for"
64 " this CutoffGroup.\n");
65 return strdup( errMsg );
66 }
67 have_members = 1;
68 members = (int *) calloc(n_members, sizeof(int));
69 }
70 else {
71 if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs );
72 else unhandled->add( lhs, rhs );
73 have_extras = 1;
74 }
75 return NULL;
76 }
77
78 char* CutoffGroupStamp::addMember( int atomIndex ){
79
80 if( have_members && which < n_members ) {
81 members[which] = atomIndex;
82 which++;
83 } else {
84 if( have_members ){
85 sprintf( errMsg, "CutoffGroupStamp error, %d out of nMembers range",
86 which );
87 return strdup( errMsg );
88 }
89 else return strdup("CutoffGroupStamp error, nMembers not given before"
90 " member list declaration." );
91 }
92 return NULL;
93 }
94
95 char* CutoffGroupStamp::checkMe( void ){
96
97 short int no_member;
98
99 if( !have_members ){
100 return strdup( "CutoffGroupStamp error. CutoffGroup contains no members." );
101 }
102
103 if (which < n_members) {
104 sprintf( errMsg,
105 "CutoffGroupStamp error. Not all of the members were"
106 " declared for this CutoffGroup.");
107 return strdup( errMsg );
108 }
109
110 return NULL;
111
112 }