diff --git a/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h b/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h index 1d9b0794f3bd8625d179480052144f7f45143e81..a0c06efb634af93a1eb6036c81448546c5494b57 100644 --- a/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h +++ b/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h @@ -220,11 +220,11 @@ class GMDBManager { bool addListOfRecords(const std::string geoType, const std::vector<std::vector<std::string>> records); bool addListOfRecords(const std::string geoType, - const std::vector<std::vector<std::variant<int, long, float, double, std::string>>> records); + const DBRowsList records); bool addRecordsToTable( const std::string tableName, - const std::vector<std::variant<int, long, float, double, std::string>> + const DBRowEntry records); bool addListOfChildrenPositions( @@ -309,9 +309,9 @@ class GMDBManager { std::unordered_map<unsigned int, std::string> getAll_TableIDsNodeTypes(); std::unordered_map<std::string, unsigned int> getAll_NodeTypesTableIDs(); - std::vector<std::vector<std::string>> getTableRecords_String(const std::string_view tableName) const; - std::vector<std::variant<int, long, float, double, std::string>> getTableRecords_VecData(const std::string_view tableName) const; - std::vector<std::vector<std::variant<int, long, float, double, std::string>>> getTableRecords_VecVecData(const std::string_view tableName) const; + std::vector<std::vector<std::string>> getTableRecords(std::string tableName) const; + DBRowEntry getTableRecords_VecData(std::string tableName) const; + DBRowsList getTableRecords_VecVecData(std::string tableName) const; //! Test if a given table exists //! This requires the *full* table name (i.e. prefix_suffix) @@ -335,7 +335,7 @@ class GMDBManager { const std::vector<std::string> tableColNames, const std::vector<std::string> tableColTypes, const std::vector< - std::vector<std::variant<int, long, float, double, std::string>>> + DBRowEntry> &records); @@ -351,7 +351,7 @@ class GMDBManager { bool addListOfRecordsToTable( const std::string tableName, const std::vector< - std::vector<std::variant<int, long, float, double, std::string>>> + DBRowEntry> records); // bool addListOfRecordsToTableOld(const QString tableName, const // std::vector<QStringList> records); // for the old SQlite only diff --git a/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp b/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp index bb619bff13f586854d135a7fcf951369a3ff0713..542f99a8dab6a519425466b1cb2d858470f424cc 100644 --- a/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp +++ b/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp @@ -294,12 +294,13 @@ std::vector<std::vector<std::string>> GMDBManager::getTableRecords_String( return records; } -std::vector<std::vector<std::variant<int, long, float, double, std::string>>> GMDBManager::getTableRecords_VecVecData( - const std::string_view tableName) const +// New version with variant +DBRowsList GMDBManager::getTableRecords_VecVecData( + std::string tableName) const { // container to be returned - std::vector<std::vector<std::variant<int, long, float, double, std::string>>> records; + DBRowsList records; // get the query statetement ready to be executed sqlite3_stmt *stmt = nullptr; @@ -323,7 +324,7 @@ std::vector<std::vector<std::variant<int, long, float, double, std::string>>> GM res = sqlite3_step(stmt); // Execute SQL Statement. if (res == SQLITE_ROW) { - std::vector<std::variant<int, long, float, double, std::string>> + DBRowEntry nodeParams; // stores the data items contained in a // single row // Loop times the number of columns in the table @@ -409,14 +410,14 @@ std::vector<std::vector<std::variant<int, long, float, double, std::string>>> GM return records; } // New version with variant -std::vector<std::variant<int, long, float, double, std::string>> GMDBManager::getTableRecords_VecData( - const std::string_view tableName) const +DBRowEntry GMDBManager::getTableRecords_VecData( + std::string tableName) const { if (!checkTableFromCache(tableName)) { THROW_EXCEPTION("ERROR!!! Table name '" + std::string(tableName) + "' does not exist in cache! (It has not been loaded from the DB)"); } // container to be returned - std::vector<std::variant<int, long, float, double, std::string>> records; + DBRowEntry records; // get the query statetement ready to be executed sqlite3_stmt *stmt = nullptr; @@ -534,15 +535,14 @@ std::vector<std::vector<std::string>> GMDBManager::getTableFromNodeType_String( { std::mutex coutMutex; coutMutex.lock(); - printf( - "\t ===> WARNING! The geometry input file does not contain a " - "table " - "for the %s nodes. That means that you are probably using an " - "old " - "geometry file. Unless you know exactly what you are doing, " - "please " - "expect to see incomplete geometries or crashes.\n", - nodeType.c_str()); + std::string errMsg = "\t ===> WARNING! The geometry input file does not contain a " + "table for the " + + nodeType + + " nodes. That means that you are probably using an " + + "old geometry file." + + "Unless you know exactly what you are doing, " + + "please expect to see incomplete geometries or crashes.\n"; + std::cout << errMsg << std::endl; coutMutex.unlock(); } else @@ -567,15 +567,13 @@ DBRowsList GMDBManager::getTableFromNodeType_VecVecData( { std::mutex coutMutex; coutMutex.lock(); - printf( - "\t ===> WARNING! The geometry input file does not contain a " - "table " - "for the %s nodes. That means that you are probably using an " - "old " - "geometry file. Unless you know exactly what you are doing, " - "please " - "expect to see incomplete geometries or crashes.\n", - nodeType.c_str()); + std::cout << + "\t ===> WARNING! The geometry input file does not contain a table for the" + << nodeType + << "nodes. That means that you are probably using an " + << "old geometry file. Unless you know exactly what you are doing, " + << "please expect to see incomplete geometries or crashes.\n" + << std::endl; coutMutex.unlock(); } else @@ -591,20 +589,21 @@ DBRowsList GMDBManager::getTableFromNodeType_VecVecData( DBRowsList GMDBManager::getTableFromTableName_VecVecData( std::string tableName) { - std::vector<std::vector<std::variant<int, long, float, double, std::string>>> out; + DBRowsList out; if (tableName.empty()) { std::mutex coutMutex; coutMutex.lock(); - printf( + std::cout << "\t ===> WARNING! The geometry input file does not contain a " - "table " - "for the %s nodes. That means that you are probably using an " - "old " - "geometry file. Unless you know exactly what you are doing, " - "please " - "expect to see incomplete geometries or crashes.\n", - tableName.c_str()); + "table for the " + << tableName + << "nodes. That means that you are probably using an " + << "old " + << "geometry file. Unless you know exactly what you are doing, " + << "please " + << "expect to see incomplete geometries or crashes.\n" + << std::endl; coutMutex.unlock(); } else @@ -625,15 +624,14 @@ DBRowEntry GMDBManager::getTableFromTableName_VecData( { std::mutex coutMutex; coutMutex.lock(); - printf( - "\t ===> WARNING! The geometry input file does not contain a " - "table " - "for the %s nodes. That means that you are probably using an " - "old " - "geometry file. Unless you know exactly what you are doing, " - "please " - "expect to see incomplete geometries or crashes.\n", - tableName.c_str()); + std::cout << "\t ===> WARNING! The geometry input file does not contain a " + << "table " + << "for the " + << tableName + << "nodes. That means that you are probably using an " + << "old geometry file. Unless you know exactly what you are doing, " + << "please expect to see incomplete geometries or crashes.\n" + << std::endl; coutMutex.unlock(); } else @@ -649,7 +647,7 @@ DBRowEntry GMDBManager::getTableFromTableName_VecData( std::vector<double> GMDBManager::getTableFromTableName_VectorDouble(std::string tableName) { - std::vector<std::variant<int, long, float, double, std::string>> inputRecords = getTableFromTableName_VecData(tableName); + DBRowEntry inputRecords = getTableFromTableName_VecData(tableName); std::vector<double> outRecords; for (const auto &rec : inputRecords) { @@ -665,6 +663,9 @@ std::vector<double> GMDBManager::getTableFromTableName_VectorDouble(std::string } return outRecords; } + +// TODO: make template +// from Johannes: Couldn't you declare this method as a general template method to downcast the variant? std::deque<double> GMDBManager::getTableFromTableName_DequeDouble(std::string tableName) { std::vector<double> inputRecords = getTableFromTableName_VectorDouble(tableName); @@ -765,7 +766,7 @@ bool GMDBManager::addListOfRecords( bool GMDBManager::addListOfRecords( const std::string geoType, - const std::vector<std::vector<std::variant<int, long, float, double, std::string>>> records) { + const DBRowsList records) { // if (m_debug) qDebug() << "GMDBManager::addListOfRecords():" << // geoType; @@ -845,7 +846,7 @@ bool GMDBManager::addListOfRecordsToTable( bool GMDBManager::addListOfRecordsToTable( const std::string tableName, const std::vector< - std::vector<std::variant<int, long, float, double, std::string>>> + DBRowEntry> records) { if ( !(hasTableBeenCreatedInDB(tableName)) ) { @@ -867,7 +868,7 @@ bool GMDBManager::addListOfRecordsToTable( std::string sql = fmt::format("INSERT INTO {0} {1} VALUES ", tableName, tableColString); unsigned int id = 0; - for (const std::vector<std::variant<int, long, float, double, std::string>>& + for (const DBRowEntry& rec : records) { ++id; // a vector to store string-conversions of values, to build the SQL @@ -922,7 +923,7 @@ bool GMDBManager::addListOfRecordsToTable( bool GMDBManager::addRecordsToTable( const std::string tableName, - const std::vector<std::variant<int, long, float, double, std::string>> + const DBRowEntry records) { if (records.size() > 0) { @@ -1504,7 +1505,7 @@ bool GMDBManager::createCustomTable( const std::string tableName, const std::vector<std::string> tableColNames, const std::vector<std::string> tableColTypes, const std::vector< - std::vector<std::variant<int, long, float, double, std::string>>>& + DBRowEntry>& records) { if (tableColNames.size() == 0) throw std::runtime_error( diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes.h index 3713c4beb284afe343e61af8957afea26437488c..71927390f71a797203311205265ae173465e3c79 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes.h @@ -34,7 +34,7 @@ public: BuildGeoShapes(std::string_view shapeType, const unsigned size); BuildGeoShapes(std::string_view shapeType, const unsigned size, DBRowsList shapesData); - virtual void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) = 0; + virtual void buildShape(const DBRowEntry row) = 0; // --- methods for caching GeoShape nodes --- void storeBuiltShape(const unsigned id, GeoShape *nodePtr); diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.cpp index bd9176330cf567ec04ad8cccc217515be4f5d212..b76a7b19f51e7157251bb90d04a4d0e1d7d861e1 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_Box::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_Box::buildShape(const DBRowEntry row) { // === get shape numeric data from the DB row // shape ID diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.h index 1489796a32101e7401348aae023136c17c50e7bf..b3f5dbab09c8948bfc8789e16f423c6b7faa0c66 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.h @@ -22,7 +22,7 @@ class BuildGeoShapes_Box : public BuildGeoShapes { public: BuildGeoShapes_Box(const unsigned size):BuildGeoShapes("Box", size){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Cons.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Cons.cpp index ebab087d5f588defc1448b3448ce4ca5d2d409b8..e884f7f9076b903b502afc333de88d912edf54de 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Cons.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Cons.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_Cons::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_Cons::buildShape(const DBRowEntry row) { // === get shape numeric data from the DB row // shape ID diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Cons.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Cons.h index e414ff8c9ad5c9e035faddefa114f4369ae4ecbf..fdfdda6b64fedc24b88f08b39760b273673df275 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Cons.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Cons.h @@ -23,7 +23,7 @@ class BuildGeoShapes_Cons : public BuildGeoShapes { public: BuildGeoShapes_Cons(const unsigned size):BuildGeoShapes("Cons", size){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Para.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Para.cpp index d5372870e39267cd3340e85bc8a11ee134733c0d..fb387e2a22d43c8dc2d26857465a43877c9bfa1d 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Para.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Para.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_Para::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_Para::buildShape(const DBRowEntry row) { // === get shape numeric data from the DB row // shape ID diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Para.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Para.h index 3c2a883faa9a0fc088f3900f46f17785b7c682be..2a5aa78574668f79b627d4d6fc033fc9e946cdcd 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Para.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Para.h @@ -23,7 +23,7 @@ class BuildGeoShapes_Para : public BuildGeoShapes { public: BuildGeoShapes_Para(const unsigned size):BuildGeoShapes("Para", size){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pcon.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pcon.cpp index 0d9cf455f21ba566aa20f8a24d120aa185ec5ee0..6a7a303be4a647e49ec64f8acaeea9694658c1fc 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pcon.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pcon.cpp @@ -16,7 +16,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_Pcon::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_Pcon::buildShape(const DBRowEntry row) { if (!(m_shape_data.size())) { THROW_EXCEPTION("ERROR! GeoPcon shape has no ZPlanes data!! [m_shape_data.size() == 0]"); diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pcon.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pcon.h index 6721ba1eab740d5eb80e435f37a0b4eee2ef5b65..5d66e1a69e792dd33350aa0d78f668e5dd0f064c 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pcon.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pcon.h @@ -24,7 +24,7 @@ class BuildGeoShapes_Pcon : public BuildGeoShapes { public: BuildGeoShapes_Pcon(const unsigned size, DBRowsList shapeData):BuildGeoShapes("Pcon", size, shapeData){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pgon.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pgon.cpp index 3391eb0f9dc20351ca72e2bbb488f31dd0adfe2f..666ede875f0f314fdac0b0041c78dc85deee7caa 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pgon.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pgon.cpp @@ -16,7 +16,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_Pgon::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_Pgon::buildShape(const DBRowEntry row) { if (!(m_shape_data.size())) { THROW_EXCEPTION("ERROR! GeoPgon shape has no ZPlanes data!! [m_shape_data.size() == 0]"); diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pgon.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pgon.h index 33679a99d6cd10e82b8400be8b77f5dc480909ef..89880b32667ea4466acfe4bad59268988e2c2c43 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pgon.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Pgon.h @@ -24,7 +24,7 @@ class BuildGeoShapes_Pgon : public BuildGeoShapes { public: BuildGeoShapes_Pgon(const unsigned size, DBRowsList shapeData):BuildGeoShapes("Pgon", size, shapeData){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_SimplePolygonBrep.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_SimplePolygonBrep.cpp index 131c2760d6a0748d68b41ce7d98c3154d9b9fcf7..d78a1eb11f3dda2770071b8e144c4fe4c0cb76d5 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_SimplePolygonBrep.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_SimplePolygonBrep.cpp @@ -16,7 +16,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_SimplePolygonBrep::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_SimplePolygonBrep::buildShape(const DBRowEntry row) { if (!(m_shape_data.size())) { diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_SimplePolygonBrep.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_SimplePolygonBrep.h index c7442b675eba7a5ab8fb7caf37e33d7bfcfaba30..cff630dc09a4d4c2c673879c5fcd6e4efa9636ba 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_SimplePolygonBrep.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_SimplePolygonBrep.h @@ -24,7 +24,7 @@ class BuildGeoShapes_SimplePolygonBrep : public BuildGeoShapes { public: BuildGeoShapes_SimplePolygonBrep(const unsigned size, DBRowsList shapeData):BuildGeoShapes("SimplePolygonBrep", size, shapeData){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trap.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trap.cpp index 3a7f816bab524ef8d6e1fb38fc2b9566ae52d90a..ae847a0e33dae5fb2c1f04e29eb957143f7c3b58 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trap.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trap.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_Trap::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_Trap::buildShape(const DBRowEntry row) { // === get shape numeric data from the DB row // shape ID diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trap.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trap.h index f42b86c67b31ac6f217a3ceedc286fd0601d5a25..1292a45c54679dbf073b05e391351278dbac7347 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trap.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trap.h @@ -23,7 +23,7 @@ class BuildGeoShapes_Trap : public BuildGeoShapes { public: BuildGeoShapes_Trap(const unsigned size):BuildGeoShapes("Trap", size){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trd.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trd.cpp index b001e988da29605774bf29c8e3f4f6b67e5c8d03..f81d01efa3c467f89c48982e616ad1b7a2c43266 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trd.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trd.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_Trd::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_Trd::buildShape(const DBRowEntry row) { // === get shape numeric data from the DB row // shape ID diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trd.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trd.h index caf4a47dcb09604f37f1d675bbf0a12a8d579f83..9625b83b31f2e04db58dff6d686f1f4e9e5f04a8 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trd.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Trd.h @@ -23,7 +23,7 @@ class BuildGeoShapes_Trd : public BuildGeoShapes { public: BuildGeoShapes_Trd(const unsigned size):BuildGeoShapes("Trd", size){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tube.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tube.cpp index 4e9659650b4938089d92f224ecc2d15a584b7c35..4c486e77b94146b9410234e25a61bf85c5fbdf25 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tube.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tube.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_Tube::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_Tube::buildShape(const DBRowEntry row) { // === get shape numeric data from the DB row // shape ID diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tube.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tube.h index 5087d928705a3f375f0f474aa4de6a979dd812fa..4a8856bfaea4f6b228dde17998090a579e09e2fd 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tube.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tube.h @@ -22,7 +22,7 @@ class BuildGeoShapes_Tube : public BuildGeoShapes { public: BuildGeoShapes_Tube(const unsigned size):BuildGeoShapes("Tube", size){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tubs.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tubs.cpp index c05bf1710b555ac099331345bd5cf04c9fa6e3bc..e4ada4eb0783905b336b828bcf609a79328b2897 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tubs.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tubs.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_Tubs::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_Tubs::buildShape(const DBRowEntry row) { // === get shape numeric data from the DB row // shape ID diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tubs.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tubs.h index 6e3e603e65136f378430e8137ad167df7ebb7124..eeb330db986be59d3c4f303ace459ab5aff77fd2 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tubs.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Tubs.h @@ -22,7 +22,7 @@ class BuildGeoShapes_Tubs : public BuildGeoShapes { public: BuildGeoShapes_Tubs(const unsigned size):BuildGeoShapes("Tubs", size){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_TwistedTrap.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_TwistedTrap.cpp index 1f778cbba7ca85f5c9f6bb558a2b27aa8ad54af5..da3a20dc95502981a360c751092acc748c45f241 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_TwistedTrap.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_TwistedTrap.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_TwistedTrap::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_TwistedTrap::buildShape(const DBRowEntry row) { // === get shape numeric data from the DB row // shape ID diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_TwistedTrap.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_TwistedTrap.h index 72b8c98a5b79e02c8e32928a4f40a973af1f2817..874cca86237563a0aad9629cd0d7bb0c0a8422a3 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_TwistedTrap.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_TwistedTrap.h @@ -22,7 +22,7 @@ class BuildGeoShapes_TwistedTrap : public BuildGeoShapes { public: BuildGeoShapes_TwistedTrap(const unsigned size):BuildGeoShapes("TwistedTrap", size){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.cpp index ef31a5811b839ef309a581e4e00763463700df09..a7d87a8357af57f8910871f32d0e847e9dbddd06 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> -void BuildGeoShapes_UnidentifiedShape::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +void BuildGeoShapes_UnidentifiedShape::buildShape(const DBRowEntry row) { // === get shape numeric data from the DB row // shape ID diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.h index d076b39a2a1d5881ac2c33a129b49f0924062d76..4e277c8f63b5d0e9d7a78e4464400a87f7a5b490 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.h +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.h @@ -22,7 +22,7 @@ class BuildGeoShapes_UnidentifiedShape : public BuildGeoShapes { public: BuildGeoShapes_UnidentifiedShape(const unsigned size):BuildGeoShapes("UnidentifiedShape", size){}; - void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; + void buildShape(const DBRowEntry row) override; }; #endif diff --git a/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h b/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h index 51596afb32c0e01c55b5ee9d081a60da7875528c..686cbd86bc1650669d46c7d0f8c4d10b2e7134c3 100644 --- a/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h +++ b/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h @@ -119,8 +119,7 @@ class WriteGeoModel : public GeoNodeAction { void storeDataTable( std::string tableName, std::vector<std::string> colNames, std::vector<std::string> colTypes, - std::vector< - std::vector<std::variant<int, long, float, double, std::string>>> + DBRowsList tableData); void saveToDB(GeoPublisher *store = nullptr); @@ -244,7 +243,7 @@ class WriteGeoModel : public GeoNodeAction { unsigned int addShape(const std::string &type, const std::string ¶meters); unsigned int addShape(const std::string &type, - const std::vector<std::variant<int, long, float, double, std::string>> ¶meters); + const DBRowEntry ¶meters); std::pair<unsigned, unsigned> addShapeData(const std::string type, const DBRowsList &shapeData); @@ -312,7 +311,7 @@ class WriteGeoModel : public GeoNodeAction { // moved to an Utility class, so we can use it // from TransFunctionRecorder as well. std::string getShapeParameters(const GeoShape *); - std::pair<std::vector<std::variant<int, long, float, double, std::string>>, + std::pair<DBRowEntry, DBRowsList> getShapeParametersV(const GeoShape *, const bool data = false); @@ -400,7 +399,7 @@ class WriteGeoModel : public GeoNodeAction { DBRowsList m_functions; // operators used in Function's expression // caches for additional data to be saved into the DB - std::vector<std::variant<int, long, float, double, std::string>> m_exprData; // numbers used in Function's expression + DBRowEntry m_exprData; // numbers used in Function's expression // caches for Metadata to be saved into the DB // std::vector<std::string> m_rootVolume; diff --git a/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp b/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp index a785f401d38f326cce580329c0bd6cd277b7e649..0006e5c8c248b7430bc6bf99bb66c50695b4f4bd 100644 --- a/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp +++ b/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp @@ -972,16 +972,16 @@ void WriteGeoModel::handleReferencedVPhysVol(const GeoVPhysVol* vol) { } // Get shape parameters -std::pair<std::vector<std::variant<int, long, float, double, std::string>>, - std::vector<std::vector<std::variant<int, long, float, double, std::string>>>> +std::pair<DBRowEntry, + DBRowsList> WriteGeoModel::getShapeParametersV(const GeoShape *shape, const bool data) { const std::string shapeType = shape->type(); - std::vector<std::variant<int, long, float, double, std::string>> shapePars; - std::vector<std::vector<std::variant<int, long, float, double, std::string>>> shapeData; - std::pair<std::vector<std::variant<int, long, float, double, std::string>>, std::vector<std::vector<std::variant<int, long, float, double, std::string>>>> shapePair; - std::vector<std::variant<int, long, float, double, std::string>> dataRow; + DBRowEntry shapePars; + DBRowsList shapeData; + std::pair<DBRowEntry, DBRowsList> shapePair; + DBRowEntry dataRow; // init the 'computedVolume' column with a dummy value: '-1' // the real value will be added later, when the DB will be passed throug @@ -1978,8 +1978,8 @@ unsigned int WriteGeoModel::addRecord( } unsigned int WriteGeoModel::addRecord( - std::vector<std::vector<std::variant<int, long, float, double, std::string>>>* container, - const std::vector<std::variant<int, long, float, double, std::string>> values) const { + DBRowsList* container, + const DBRowEntry values) const { container->push_back(values); unsigned int idx = container->size(); // index of pushed element = size after pushing, to @@ -1988,8 +1988,8 @@ unsigned int WriteGeoModel::addRecord( } std::pair<unsigned, unsigned> WriteGeoModel::addRecordData( - std::vector<std::vector<std::variant<int, long, float, double, std::string>>> *container, - const std::vector<std::vector<std::variant<int, long, float, double, std::string>>> values) const + DBRowsList *container, + const DBRowsList values) const { const unsigned dataStart = container->size() + 1; // Note: ^ we add +1 because start filling the table @@ -2009,7 +2009,7 @@ std::pair<unsigned, unsigned> WriteGeoModel::addRecordData( std::vector<unsigned> WriteGeoModel::addExprData( const std::deque<double>& exprData) { - std::vector<std::variant<int, long, float, double, std::string>> *container = &m_exprData; + DBRowEntry *container = &m_exprData; const unsigned dataStart = container->size() + 1; // Note: ^ we add +1 because start filling the table // from a new row with respect to what we currently have @@ -2399,8 +2399,8 @@ unsigned int WriteGeoModel::addIdentifierTag(const int& identifier) { unsigned int WriteGeoModel::addFunction(const std::string& expression, const unsigned &dataStart, const unsigned &dataEnd) { // std::vector<std::vector<std::string>>* container = &m_functions; - std::vector<std::vector<std::variant<int, long, float, double, std::string>>>* container = &m_functions; - std::vector<std::variant<int, long, float, double, std::string>> values; + DBRowsList* container = &m_functions; + DBRowEntry values; values.push_back(expression); values.push_back(dataStart); values.push_back(dataEnd); @@ -2459,9 +2459,9 @@ unsigned int WriteGeoModel::addShape(const std::string& type, return addRecord(container, values); } unsigned int WriteGeoModel::addShape(const std::string &type, - const std::vector<std::variant<int, long, float, double, std::string>> ¶meters) + const DBRowEntry ¶meters) { - std::vector<std::vector<std::variant<int, long, float, double, std::string>>> *container = nullptr; + DBRowsList *container = nullptr; if ("Box" == type) { container = &m_shapes_Box; @@ -2573,8 +2573,8 @@ unsigned int WriteGeoModel::addLogVol(const std::string& name, const unsigned int& shapeId, std::string_view shapeType, const unsigned int& materialId) { - std::vector<std::vector<std::variant<int, long, float, double, std::string>>>* container = &m_logVols; - std::vector<std::variant<int, long, float, double, std::string>> values; + DBRowsList* container = &m_logVols; + DBRowEntry values; values.push_back(name); values.push_back(shapeId); values.push_back(std::string(shapeType)); @@ -2871,9 +2871,7 @@ std::vector<std::vector<std::string>> tableData ) void WriteGeoModel::storeDataTable( std::string tableName, std::vector<std::string> colNames, std::vector<std::string> colTypes, - std::vector< - std::vector<std::variant<int, long, float, double, std::string>>> - tableData) { + DBRowsList tableData) { m_auxiliaryTablesVar[tableName] = std::make_pair(colNames, colTypes); m_auxiliaryTablesVarData[tableName] = tableData; }