I have an external Parameter class
I need to define as global objects (instances) inside different namespaces. I insert a pointer to each instance of the class to a map.
the problem:
not all parameter names are unique and I need a unique name as key to each instance, can I get the namespace hierarchy of the object name as prefix for his name?
RegisteredGlobalObject.cpp:
RegisteredGlobalObject::RegisteredGlobalObject(const string& uid, int val) {
m_mapUidToParamPair[uid] = val;
}
ParamsDef.h:
namespace base {
namespace vpeservice {
extern RegisteredGlobalObject int_64_param;
} // namespace vpeservice
namespace otherservice {
extern RegisteredGlobalObject int_64_param;
} // namespace otherservice
} // namespace base
ParamsDef.cpp:
namespace base {
namespace vpeservice {
RegisteredGlobalObject int_64_param(getInstatnceDefenitionPlaceStr()+"int_64_param", 1);
}
namespace otherservice {
RegisteredGlobalObject int_64_param(getInstatnceDefenitionPlaceStr()+"int_64_param", 2);
}
}
can I implement the function getInstatnceDefenitionPlaceStr()
which returns "base::vpeservice
" for the first call and "base::otherservice
" for the second?