Map Utilization (09/05/02)

CRHM

Map Utilization.

    The STL container classes map and multimap are used extensively in CHRM for assembling the CRHM model and keeping track of module names and object addresses.  See GlobalCommon.h for the definitions of the typedefs  used by the program.

    When linking modules together a multimap is used to hold module and variable/parameter names.  It is defined as follows.

typedef String KeyType2;

typedef pair<KeyType2, KeyType2> Pairstr;

typedef multimap<KeyType2, KeyType2> Mapstr;

  1. The first item of the pair is the name of the module using the variable from another module.
  2. The second item of the pair is the name of the source module concatenated with the variable name.

An example is pair<"pbsm", "obs hru_t">.  Note that a single space is used as the separator in the second item.

 

    When keeping track of module object addresses a map is used to hold the source module name concatenated with the variable name and the address of the object.   It is defined as follows.

typedef string KeyType;

typedef ClassVar *Var;

typedef ClassPar *Par;

typedef pair<KeyType, Var> PairVar;

typedef pair<KeyType, Par> PairPar;

typedef map<KeyType, Var> MapVar;

typedef map<KeyType, Par, Classless<KeyType> > MapPar;

 

  1. The first item of the pair is the source module name concatenated with the variable name.
  2. The second item of the pair is the address of the object.

An example is pair< "obs hru_t", hru_t>.  Note that a single space is used as the separator in the first item.

    When keeping track of dimensions a map is used to hold the dimension name and its size.  It is defined as follows.

typedef long Dim;

typedef pair<KeyType, Dim> PairDim;

typedef map<KeyType, Dim> MapDim;

  1. The first item of the pair is the name of the dimension.
  2. The second item of the pair is the size of the dimension.

An example is pair< "NHRU", 5>.