Struct containing a Map in a Map? (C++/STL)
- by karok
I was wondering if it was possible to create a struct containing a number of variables and a map in a map.
What I have at the moment:
typedef std::map<std::string,double> lawVariables;
struct ObjectCustomData {
std::string objectType;
bool global_lock;
std::map<std::string, lawVariables> lawData;
};
This struct is then passed on to another function as a single data block for that object.
The structure setup is as follows:
Each object has a data block that contains: its ObjectType, a bool for a lock, and a varying number of "laws" that could look like this:
law1 -> var_a = 39.3;
-> var_g = 8.1;
law8 -> var_r = 83.1;
-> var_y = 913.3;
-> var_a = 9.81;
Firstly, I'm unsure whether I should be using a Map within a Map and secondly even if this would be valid, I'm unsure how to fill it with data and how to recall it afterwards. I looked at maps because then I can search (on a name) if a certain object has a certain law, and if that law has certain variables.
(sorry for the first messy post appearance, hope this is better :) )