NAMD
MGridforceParams.h
Go to the documentation of this file.
1 /*
2  * MGridforceParams.h
3  *
4  *
5  * Created by Robert Brunner on 12/5/07.
6  * Copyright 2007 __MyCompanyName__. All rights reserved.
7  *
8  */
9 #ifndef MGRIDFORCEPARAMS_H
10 #define MGRIDFORCEPARAMS_H
11 
12 #include "common.h"
13 #include "Vector.h"
14 #include <string.h>
15 
16 class MIStream;
17 class MOStream;
18 
19 #define MGRIDFORCEPARAMS_DEFAULTKEY "BaseGridForceParams"
20 
22 public:
24  gridforceKey = 0;
25  gridforceVfile = 0;
27  gridforceFile = 0;
28  gridforceCol = 0;
29  gridforceQcol = 0;
35  }
36 
37  char *gridforceKey;
41  char *gridforceCol;
49 };
50 
52 public:
54  clear();
55  }
56 
58  {
59  MGFElem* cur;
60  while (head != NULL) {
61  cur = head;
62  head = cur->nxt;
63  delete cur;
64  }
65  clear();
66  }
67 
68  // The SimParameters bit copy overwrites these values with illegal pointers,
69  // So thise throws away the garbage and lets everything be reinitialized
70  // from scratch
71  void clear() {
72  head = tail = NULL;
73  n_elements = 0;
74  }
75 
76  MGridforceParams* find_key(const char* key);
77  int index_for_key(const char* key);
78  MGridforceParams* at_index(int idx);
79  MGridforceParams* add(const char* key);
80 
82  if (head == NULL) {
83  return NULL;
84  } else return &(head->elem);
85  }
86 
87  void pack_data(MOStream *msg);
88  void unpack_data(MIStream *msg);
89 
90  // convert from a string to Bool; returns 1(TRUE) 0(FALSE) or -1(if unknown)
91  static int atoBool(const char *s)
92  {
93  if (!strcasecmp(s, "on")) return 1;
94  if (!strcasecmp(s, "off")) return 0;
95  if (!strcasecmp(s, "true")) return 1;
96  if (!strcasecmp(s, "false")) return 0;
97  if (!strcasecmp(s, "yes")) return 1;
98  if (!strcasecmp(s, "no")) return 0;
99  if (!strcasecmp(s, "1")) return 1;
100  if (!strcasecmp(s, "0")) return 0;
101  return -1;
102  }
103 
104 private:
105  class MGFElem {
106  public:
107  MGridforceParams elem;
108  MGFElem* nxt;
109  };
110  MGFElem* head;
111  MGFElem* tail;
112  int n_elements;
113 };
114 
115 #endif
Definition: Vector.h:72
#define FALSE
Definition: common.h:127
MGridforceParams * get_first()
int index_for_key(const char *key)
static int atoBool(const char *s)
MGridforceParams * find_key(const char *key)
int Bool
Definition: common.h:142
void unpack_data(MIStream *msg)
MGridforceParams * add(const char *key)
MGridforceParams * next
void pack_data(MOStream *msg)
MGridforceParams * at_index(int idx)
#define TRUE
Definition: common.h:128