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 "strlib.h"
13 #include "common.h"
14 #include "Vector.h"
15 #include "InfoStream.h"
16 #include "MStream.h"
17 
18 #define MGRIDFORCEPARAMS_DEFAULTKEY "BaseGridForceParams"
19 
21 public:
23  gridforceKey = 0;
24  gridforceVfile = 0;
26  gridforceFile = 0;
27  gridforceCol = 0;
28  gridforceQcol = 0;
34  }
35 
36  char *gridforceKey;
40  char *gridforceCol;
48 };
49 
51 public:
53  clear();
54  }
55 
57  {
58  MGFElem* cur;
59  while (head != NULL) {
60  cur = head;
61  head = cur->nxt;
62  delete cur;
63  }
64  clear();
65  }
66 
67  // The SimParameters bit copy overwrites these values with illegal pointers,
68  // So thise throws away the garbage and lets everything be reinitialized
69  // from scratch
70  void clear() {
71  head = tail = NULL;
72  n_elements = 0;
73  }
74 
75  MGridforceParams* find_key(const char* key);
76  int index_for_key(const char* key);
77  MGridforceParams* at_index(int idx);
78  MGridforceParams* add(const char* key);
79 
81  if (head == NULL) {
82  return NULL;
83  } else return &(head->elem);
84  }
85 
86  void pack_data(MOStream *msg);
87  void unpack_data(MIStream *msg);
88 
89  // convert from a string to Bool; returns 1(TRUE) 0(FALSE) or -1(if unknown)
90  static int atoBool(const char *s)
91  {
92  if (!strcasecmp(s, "on")) return 1;
93  if (!strcasecmp(s, "off")) return 0;
94  if (!strcasecmp(s, "true")) return 1;
95  if (!strcasecmp(s, "false")) return 0;
96  if (!strcasecmp(s, "yes")) return 1;
97  if (!strcasecmp(s, "no")) return 0;
98  if (!strcasecmp(s, "1")) return 1;
99  if (!strcasecmp(s, "0")) return 0;
100  return -1;
101  }
102 
103 private:
104  class MGFElem {
105  public:
106  MGridforceParams elem;
107  MGFElem* nxt;
108  };
109  MGFElem* head;
110  MGFElem* tail;
111  int n_elements;
112 };
113 
114 #endif
Definition: Vector.h:64
#define FALSE
Definition: common.h:116
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:131
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:117