MGridforceParams.h

Go to the documentation of this file.
00001 /*
00002  *  MGridforceParams.h
00003  *  
00004  *
00005  *  Created by Robert Brunner on 12/5/07.
00006  *  Copyright 2007 __MyCompanyName__. All rights reserved.
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     gridforceCheckSize = TRUE;
00034   }
00035   
00036   char *gridforceKey;
00037   char *gridforceVfile;
00038   zVector gridforceScale;
00039   char *gridforceFile;
00040   char *gridforceCol;
00041   char *gridforceQcol;
00042   zVector gridforceVOffset;
00043   Bool gridforceCont[3];
00044   Bool gridforceVolts;
00045   Bool gridforceLite;
00046   Bool gridforceCheckSize;
00047   MGridforceParams *next;
00048 };
00049 
00050 class MGridforceParamsList {
00051 public:
00052   MGridforceParamsList() {
00053     clear();
00054   }
00055   
00056   ~MGridforceParamsList() 
00057   {
00058     MGFElem* cur;
00059     while (head != NULL) {
00060       cur = head;
00061       head = cur->nxt;
00062       delete cur;
00063     }
00064     clear();
00065   }
00066   
00067   // The SimParameters bit copy overwrites these values with illegal pointers,
00068   // So thise throws away the garbage and lets everything be reinitialized
00069   // from scratch
00070   void clear() {
00071     head = tail = NULL;
00072     n_elements = 0;
00073   }
00074   
00075   MGridforceParams* find_key(const char* key);  
00076   int index_for_key(const char* key);
00077   MGridforceParams* at_index(int idx);
00078   MGridforceParams* add(const char* key);
00079   
00080   MGridforceParams *get_first() {
00081     if (head == NULL) {
00082       return NULL;
00083     } else return &(head->elem);
00084   }
00085   
00086   void pack_data(MOStream *msg);  
00087   void unpack_data(MIStream *msg);
00088   
00089   // convert from a string to Bool; returns 1(TRUE) 0(FALSE) or -1(if unknown)
00090   static int atoBool(const char *s)
00091   {
00092     if (!strcasecmp(s, "on")) return 1;
00093     if (!strcasecmp(s, "off")) return 0;
00094     if (!strcasecmp(s, "true")) return 1;
00095     if (!strcasecmp(s, "false")) return 0;
00096     if (!strcasecmp(s, "yes")) return 1;
00097     if (!strcasecmp(s, "no")) return 0;
00098     if (!strcasecmp(s, "1")) return 1;
00099     if (!strcasecmp(s, "0")) return 0;
00100     return -1;
00101   }
00102   
00103 private:
00104   class MGFElem {
00105   public:
00106     MGridforceParams elem;
00107     MGFElem* nxt;
00108   };
00109   MGFElem* head;
00110   MGFElem* tail;
00111   int n_elements;
00112 };
00113 
00114 #endif

Generated on Fri Sep 22 01:17:13 2017 for NAMD by  doxygen 1.4.7