00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef MGRIDFORCEPARAMS_H
00010 #define MGRIDFORCEPARAMS_H
00011
00012 #include "strlib.h"
00013 #include "common.h"
00014 #include "Vector.h"
00015 #include "InfoStream.h"
00016 #include "MStream.h"
00017
00018 #define MGRIDFORCEPARAMS_DEFAULTKEY "BaseGridForceParams"
00019
00020 class MGridforceParams {
00021 public:
00022 MGridforceParams() {
00023 gridforceKey = 0;
00024 gridforceVfile = 0;
00025 gridforceScale = Vector(0);
00026 gridforceFile = 0;
00027 gridforceCol = 0;
00028 gridforceQcol = 0;
00029 gridforceVOffset = Vector(0);
00030 gridforceCont[0] = gridforceCont[1] = gridforceCont[2] = FALSE;
00031 gridforceVolts = FALSE;
00032 gridforceLite = FALSE;
00033 }
00034
00035 char *gridforceKey;
00036 char *gridforceVfile;
00037 zVector gridforceScale;
00038 char *gridforceFile;
00039 char *gridforceCol;
00040 char *gridforceQcol;
00041 zVector gridforceVOffset;
00042 Bool gridforceCont[3];
00043 Bool gridforceVolts;
00044 Bool gridforceLite;
00045 MGridforceParams *next;
00046 };
00047
00048 class MGridforceParamsList {
00049 public:
00050 MGridforceParamsList() {
00051 clear();
00052 }
00053
00054 ~MGridforceParamsList()
00055 {
00056 MGFElem* cur;
00057 while (head != NULL) {
00058 cur = head;
00059 head = cur->nxt;
00060 delete cur;
00061 }
00062 clear();
00063 }
00064
00065
00066
00067
00068 void clear() {
00069 head = tail = NULL;
00070 n_elements = 0;
00071 }
00072
00073 MGridforceParams* find_key(const char* key);
00074 int index_for_key(const char* key);
00075 MGridforceParams* add(const char* key);
00076
00077 MGridforceParams *get_first() {
00078 if (head == NULL) {
00079 return NULL;
00080 } else return &(head->elem);
00081 }
00082
00083 void pack_data(MOStream *msg);
00084 void unpack_data(MIStream *msg);
00085
00086
00087 static int atoBool(const char *s)
00088 {
00089 if (!strcasecmp(s, "on")) return 1;
00090 if (!strcasecmp(s, "off")) return 0;
00091 if (!strcasecmp(s, "true")) return 1;
00092 if (!strcasecmp(s, "false")) return 0;
00093 if (!strcasecmp(s, "yes")) return 1;
00094 if (!strcasecmp(s, "no")) return 0;
00095 if (!strcasecmp(s, "1")) return 1;
00096 if (!strcasecmp(s, "0")) return 0;
00097 return -1;
00098 }
00099
00100 private:
00101 class MGFElem {
00102 public:
00103 MGridforceParams elem;
00104 MGFElem* nxt;
00105 };
00106 MGFElem* head;
00107 MGFElem* tail;
00108 int n_elements;
00109 };
00110
00111 #endif