diff --git a/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h b/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h index f4505bc425543a15d7d9508e207c7f09c94b7eb6..da81529ab1d599e7df16000d051e2f23185e583c 100644 --- a/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h +++ b/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h @@ -1,7 +1,15 @@ -// author: Riccardo.Maria.Bianchi@cern.ch - 2017 -// major updates: -// - Aug 2018, R.M.Bianchi -// - Nov 2020, R.M.Bianchi +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +/* +* author: 2017, Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch> +* major updates: +* - Aug 2020, R.M.Bianchi, +* Added support to publish lists of FullPhysVol and AlignableTransform nodes +* - Jun 2022 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch>, +* Added support for "Verbose" output +*/ #ifndef GMDBManager_H #define GMDBManager_H @@ -23,6 +31,7 @@ * GMDBManager sets up the connection with SQL database * and performs some basics queries. */ + class GMDBManager { public: @@ -280,6 +289,9 @@ private: bool m_debug; + // verbosity level + int m_verbose; + std::unordered_map<std::string, std::vector<std::string>> m_tableNames; /// stores the column names for each table std::unordered_map<std::string, std::string> m_childType_tableName; diff --git a/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp b/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp index e81e204084d74ff56064b928010a6afe9501db04..b6da484e1c4fa1b1eea59fc64eec6b1fdea5fadd 100644 --- a/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp +++ b/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp @@ -9,6 +9,8 @@ * - Aug 2018, R.M.Bianchi * - Jun 2020, R.M.Bianchi * - Aug 2020, R.M.Bianchi - Added support to publish lists of FullPhysVol and AlignableTransform nodes +* - Jun 2022 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch>, +* Added support for "Verbose" output */ #include <GeoModelDBManager/GMDBManager.h> @@ -107,6 +109,13 @@ GMDBManager::GMDBManager(const std::string &path) : m_dbpath(path), m_dbIsOK(fal m_dbIsOK = false; } + // set verbosity level + m_verbose=0; + if(const char* env_p = std::getenv("GEOMODEL_GEOMODELIO_VERBOSE")) { + std::cout << "GeoModelDBManager -- You set the verbosity level to: " << env_p << '\n'; + m_verbose = std::stoi(env_p); + } + // if (m_dbIsOK) { // if ( ! (initDB()) ) { // std::cout << "Error: database initialization failed" << std::endl; @@ -1213,7 +1222,7 @@ bool GMDBManager::createCustomTable(const std::string tableName, const std::vect queryStr += colStr; } queryStr += ")"; - std::cout << "- table definition: " << queryStr << std::endl; + if(m_verbose>0) std::cout << "- table definition: " << queryStr << std::endl; (void)execQuery(queryStr); tab.clear(); diff --git a/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h b/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h index 735f88d00dff75b5200c61832230b9f89254e79c..f9640c71e07a1b1400e26af269ff3e47a7be1082 100644 --- a/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h +++ b/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /* @@ -11,6 +11,8 @@ * - May 2020 - R.M.Bianchi * - Aug 2020 - R.M.Bianchi // added support for GeoPublisher * - Aug 2021 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch> - Added support for GeoSerialTransformer nodes +// - Jun 2022 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch>, +// Added support for "Verbose" output */ #ifndef GeoModelWrite_WriteGeoModel_H @@ -230,6 +232,9 @@ private: // for the particular GeoModel node std::vector<std::string> m_objectsNotPersistified; + // verbosity level + int m_verbose; + }; } /* namespace GeoModelIO */ diff --git a/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp b/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp index 1341cce946b5b598222f8a8838d6c890dbd6dc64..3cbf8bf85c9af7772740e2ea4b74af2677305106 100644 --- a/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp +++ b/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp @@ -7,10 +7,15 @@ // - Aug 2018 - Riccardo Maria Bianchi // - Feb 2019 - Riccardo Maria Bianchi // - May 2020 - Riccardo Maria Bianchi -// - Aug 2020 - Riccardo Maria Bianchi - Added support to publish lists of FPV and AXF nodes +// - Aug 2020 - Riccardo Maria Bianchi, +// Added support to publish lists of FPV and AXF nodes // - Aug 2020 - Marilena Bandieramonte (e-mail: marilena.bandieramonte@cern.ch) -// - Jan 2021 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch> - Added support for custom tables, to store auxiliary data -// - Aug 2021 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch> - Added support for GeoSerialTransformer nodes +// - Jan 2021 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch>, +// Added support for custom tables, to store auxiliary data +// - Aug 2021 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch>, +// Added support for GeoSerialTransformer nodes +// - Jun 2022 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch>, +// Added support for "Verbose" output // local includes @@ -1191,6 +1196,13 @@ WriteGeoModel::WriteGeoModel(GMDBManager &db) // get DB metadata m_memMap_Tables = m_dbManager->getAll_NodeTypesTableIDs(); + + // set verbosity level + m_verbose=0; + if(const char* env_p = std::getenv("GEOMODEL_GEOMODELIO_VERBOSE")) { + std::cout << "GeoModelWrite -- You set the verbosity level to: " << env_p << '\n'; + m_verbose = std::stoi(env_p); + } } WriteGeoModel::~WriteGeoModel() @@ -1695,11 +1707,13 @@ void WriteGeoModel::saveToDB( std::vector<GeoPublisher*>& publishers ) } }*/ if ( m_auxiliaryTablesVar.size() ) { + if (m_verbose>0) { std::cout << "\nINFO: Custom tables to store auxiliary data have been added, " << "so we create these custom tables in the DB:" - << std::endl; + << std::endl; + } for ( auto& tableData : m_auxiliaryTablesVar ) { - std::cout << "\nsaving table: " << tableData.first << std::endl; + if (m_verbose>0) { std::cout << "\nsaving table: " << tableData.first << std::endl; } m_dbManager->createCustomTable( tableData.first, (tableData.second).first, (tableData.second).second, m_auxiliaryTablesVarData[ tableData.first ] ); } } @@ -1719,11 +1733,12 @@ void WriteGeoModel::storePublishedAuxiliaryData(GeoPublisher* publisher) AuxTableDefs tableDefs = publisher->getPublishedAuxData().first; AuxTableData tableAuxData = publisher->getPublishedAuxData().second; if ( tableDefs.size() ) { + std::cout << "\nINFO: Custom tables to store auxiliary data have been added to an instance of GeoPublisher, " << "so we create these custom tables in the DB:" << std::endl; for ( auto& tableData : tableDefs ) { - std::cout << "\nsaving table: " << tableData.first << std::endl; + if(m_verbose>0) { std::cout << "\nsaving table: " << tableData.first << std::endl; } m_dbManager->createCustomTable( tableData.first, (tableData.second).first, (tableData.second).second, tableAuxData[ tableData.first ] ); } } diff --git a/GeoModelTools/GMCAT/src/gmcat.cxx b/GeoModelTools/GMCAT/src/gmcat.cxx index c486d4ab2db40423b9dd92591b06da324a0359d6..b91aba2a0df86d038bf6786e52b9163c5eb8f5ed 100644 --- a/GeoModelTools/GMCAT/src/gmcat.cxx +++ b/GeoModelTools/GMCAT/src/gmcat.cxx @@ -22,6 +22,8 @@ #include <string> #include <vector> #include <unistd.h> +#include <stdlib.h> // setenv + #ifdef __APPLE__ const std::string shared_obj_extension=".dylib"; #else @@ -54,27 +56,31 @@ int main(int argc, char ** argv) { std::string outputFile; bool outputFileSet = false; for (int argi=1;argi<argc;argi++) { - std::string argument=argv[argi]; - if (argument.find("-o")!=std::string::npos) { - argi++; - if (argi>=argc) { - std::cerr << usage << std::endl; - return 1; + std::string argument=argv[argi]; + if (argument.find("-o")!=std::string::npos) { + argi++; + if (argi>=argc) { + std::cerr << usage << std::endl; + return 1; + } + outputFile=argv[argi]; + outputFileSet = true; + } + else if (argument.find("-v")!=std::string::npos) { + setenv("GEOMODEL_GEOMODELIO_VERBOSE", "1", 1); // does overwrite + std::cout << "You set the verbosity level to 1" << std::endl; + } + else if (argument.find(shared_obj_extension)!=std::string::npos) { + inputPlugins.push_back(argument); + } + else if (argument.find(".db")!=std::string::npos) { + inputFiles.push_back(argument); + } + else { + std::cerr << "Unrecognized argument " << argument << std::endl; + std::cerr << usage << std::endl; + return 2; } - outputFile=argv[argi]; - outputFileSet = true; - } - else if (argument.find(shared_obj_extension)!=std::string::npos) { - inputPlugins.push_back(argument); - } - else if (argument.find(".db")!=std::string::npos) { - inputFiles.push_back(argument); - } - else { - std::cerr << "Unrecognized argument " << argument << std::endl; - std::cerr << usage << std::endl; - return 2; - } } if( !outputFileSet ) { std::cerr << "\nERROR! You should set an output file.\n" << std::endl;