Skip to content
Snippets Groups Projects
Commit 006e3cbd authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2:
Browse files

GeoPublisher - Compile time check on proper GeoObject type

parent 8dc75a00
No related branches found
No related tags found
1 merge request!304GeoPublisher - Compile time check on proper GeoObject type
......@@ -45,8 +45,8 @@ typedef std::unordered_map<std::string, std::vector<std::vector<std::variant<int
class GeoPublisher
{
public:
GeoPublisher() {}
virtual ~GeoPublisher() {}
GeoPublisher() = default;
virtual ~GeoPublisher() = default;
template<class N, typename T> void publishNode(N node,T keyT);
......
......@@ -9,17 +9,14 @@ template<typename Iter> void GeoPublisher::printInsertionStatus(Iter it, bool su
template<class N, typename T> void GeoPublisher::publishNode(N node,T keyT)
{
std::any key = keyT;
static_assert(std::is_same_v<GeoVFullPhysVol*, N> || std::is_same_v<GeoAlignableTransform*, N>,
"ERROR!!! The node type is not currently supported by 'GeoPublisher'.\n If in doubt, please ask to `geomodel-developers@cern.ch'.\n");
if constexpr (std::is_same_v<GeoVFullPhysVol*, N>) {
const auto [iter, success] = m_publishedFPV.insert( {node, key} );
if(!success) printInsertionStatus(iter, success);
} else if constexpr (std::is_same_v<GeoAlignableTransform*, N>) {
const auto [iter, success] = m_publishedAXF.insert( {node, key} );
if(!success) printInsertionStatus(iter, success);
} else {
std::cout << "ERROR!!! The node type '" << typeid(N).name()
<< " is not currently supported by 'GeoPublisher'.\n"
<< "If in doubt, please ask to `geomodel-developers@cern.ch'.\n"
<< std::endl;
}
}
......
......@@ -22,6 +22,9 @@ namespace GeoModelIO {
std::string keyType = "";
std::vector<std::vector<std::string>> vecRecords;
static_assert(std::is_same_v<GeoFullPhysVol*, N> || std::is_same_v<GeoAlignableTransform*, N> ,
"ERROR! The node type is not currently supported. If in doubt, please ask to 'geomodel-developers@cern.ch'.\n");
if constexpr ( std::is_same_v<GeoFullPhysVol*, N> ) {
if(doCheckTable){
bool tableExists = m_dbManager->checkTable("PublishedFullPhysVols_"+publisherName);
......@@ -34,12 +37,6 @@ namespace GeoModelIO {
if(!tableExists) return mapNodes;
}
vecRecords = m_dbManager->getPublishedAXFTable( publisherName );
} else {
std::cout << "ERROR! The node type '" << typeid(N).name()
<< "' is not currently supported.\n"
<< "If in doubt, please ask to 'geomodel-developers@cern.ch'.\n"
<< "Exiting...\n";
exit(EXIT_FAILURE);
}
unsigned ii = 0;
for( auto const &record : vecRecords ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment