Gadget
addresskeeper.h
Go to the documentation of this file.
1 #ifndef addresskeeper_h
2 #define addresskeeper_h
3 
4 #include "gadget.h"
5 
11 public:
15  AddressKeeper() { addr = 0; name = 0; };
20  AddressKeeper(const AddressKeeper& initial)
21  : addr(initial.addr), name(new char[strlen(initial.name) + 1])
22  { strcpy(name, initial.name); };
27  if (name != 0)
28  delete[] name;
29  name = 0;
30  };
35  void operator = (double* address) { addr = address; };
40  void operator = (double& value) { addr = &value; };
46  int operator == (const double& value) { return (addr == &value); };
52  int operator == (const double* address) { return (addr == address); };
57  void operator = (const char* str) {
58  if (name != 0)
59  delete[] name;
60  name = new char[strlen(str) + 1];
61  strcpy(name, str);
62  delete[] str;
63  };
68  void operator = (const AddressKeeper a) {
69  if (name != 0)
70  delete[] name;
71  name = new char[strlen(a.name) + 1];
72  strcpy(name, a.name);
73  addr = a.addr;
74  };
79  const char* getName() const { return name; };
83  double* addr; //JMB shouldnt this be private??
84 private:
88  char* name;
89 };
90 
91 #endif
This is the class used to store the name, and memory adddress, of the variables used in the model sim...
Definition: addresskeeper.h:10
AddressKeeper(const AddressKeeper &initial)
This is the AddressKeeper constructor that creates a copy of an existing AddressKeeper.
Definition: addresskeeper.h:20
int operator==(const double &value)
This operator will check to see if the address for the AddressKeeper is equal to an existing address.
Definition: addresskeeper.h:46
double * addr
This is the memory address where the value of the variable is stored.
Definition: addresskeeper.h:79
~AddressKeeper()
This is the default AddressKeeper destructor.
Definition: addresskeeper.h:26
AddressKeeper()
This is the default AddressKeeper constructor.
Definition: addresskeeper.h:15
const char * getName() const
This will return a null terminated text string containing the name of the stored variable.
Definition: addresskeeper.h:79
void operator=(double *address)
This operator will set the address of the AddressKeeper equal to an existing address.
Definition: addresskeeper.h:35