I have a namespace and an enum in it:
Basically that are ID's describing classes. I need that while serializing object data to push it over network to indicate the types.
EntityManagerStatus = 1000,
MissionDescription = 1010,
GeneralEntityData = 1020,
ImCmdQueue = 1030
That classes are loaded from dll's.
Now that I want to do is to expand that enum dynamically while loading an new dll.
I guess that's not possible, isn't it?
How would you work around that, so you still got such global identifiers which could expanded dynamically?
Thanks for your ideas!
Unfortunately not, since enums are determined at compile time. I would store the values in a map instead. something like this perhaps -
std::map< std::string, int > User_types;
User_types.insert( std::make_pair< std::string, int >( "EntityManagerStatus", 1000 ) );
User_types.insert( std::make_pair< std::string, int >( "MissionDescription", 1010 ) );
User_types.insert( std::make_pair< std::string, int >( "GeneralEntityData", 1020 ) );
Sounds reasonable so far.
assuming I need both a) int->string as well as b) string->int.
For the above map a) O(n) and b) has O(log n).
other options that come to my mind are 2 separate maps, so a) and b) have O(log n) but the expense to attend 2 containers and hold them in a consistence state.
Or a vector<string> that would get me O(1) for a) and O(n) for b)
Are there other options?