Belle II Software  release-05-02-19
LocalDatabase.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015-2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Kuhr, Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <framework/database/LocalDatabase.h>
12 #include <framework/database/Configuration.h>
13 #include <framework/logging/Logger.h>
14 #include <boost/filesystem.hpp>
15 #include <boost/algorithm/string.hpp>
16 
17 // we know all of this is deprecated, we don't want the warnings when compiling the service itself ...
18 #ifdef __INTEL_COMPILER
19 #pragma warning (disable:1478) //[[deprecated]]
20 #pragma warning (disable:1786) //[[deprecated("message")]]
21 #else
22 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
23 #endif
24 
25 
26 namespace Belle2 {
31  void LocalDatabase::createInstance(const std::string& fileName, const std::string& payloadDir, bool readOnly,
33  {
34  if (!readOnly) {
35  B2WARNING(R"warn(Local databases are now aways read only.
36  If you want to change the location of newly created payload files please use
37 
38  >>> basf2.conditions.expert_settings(save_payloads=filename))warn");
39  }
40  if (!payloadDir.empty()) {
41  boost::filesystem::path file(fileName);
42  std::string absFileDir = boost::filesystem::absolute(file.parent_path()).string();
43  std::string payloads = boost::filesystem::absolute(payloadDir).string();
44  boost::algorithm::trim_right_if(absFileDir, boost::is_any_of("/"));
45  boost::algorithm::trim_right_if(payloads, boost::is_any_of("/"));
46  if (absFileDir != payloads) {
47  B2FATAL(R"warn(Local databases with payloads in different files than the text file is no longer supported:
48  Payloads need to be in the same file as the text file)warn"
49  << LogVar("filename", fileName) << LogVar("payloaddir", payloadDir));
50  }
51  }
53  }
54 
56 }
Belle2::LogConfig::ELogLevel
ELogLevel
Definition of the supported log levels.
Definition: LogConfig.h:36
Belle2::LocalDatabase::createInstance
static void createInstance(const std::string &fileName="database.txt", const std::string &payloadDir="", bool readOnly=false, LogConfig::ELogLevel logLevel=LogConfig::c_Warning, bool invertLogging=false)
Method to set the database instance to a local database.
Definition: LocalDatabase.cc:39
Belle2::Conditions::Configuration::getInstance
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24
Belle2::Conditions::Configuration::prependTestingPayloadLocation
void prependTestingPayloadLocation(const std::string &filename)
Prepend a local text file with testing payloads to the list.
Definition: Configuration.h:205