/// Default constructor
FrameworkManagerImpl::FrameworkManagerImpl()
#ifdef MPI_BUILD
  : m_mpi_environment()
#endif
{
  // Mantid only understands English...
  setGlobalLocaleToAscii();
  // Setup memory allocation scheme
  Kernel::MemoryOptions::initAllocatorOptions();

#ifdef _WIN32
    WSADATA wsaData;
    WSAStartup(MAKEWORD(2,2), &wsaData);
#endif

#ifdef _MSC_VER
  // This causes the exponent to consist of two digits (Windows Visual Studio normally 3, Linux default 2), where two digits are not sufficient I presume it uses more
  _set_output_format(_TWO_DIGIT_EXPONENT);
#endif

  g_log.notice() << Mantid::welcomeMessage() << std::endl;
  loadPluginsUsingKey(PLUGINS_DIR_KEY);
  disableNexusOutput();
  setNumOMPThreadsToConfigValue();

#ifdef MPI_BUILD
  g_log.notice() << "This MPI process is rank: " << boost::mpi::communicator().rank() << std::endl;
#endif

  g_log.debug() << "FrameworkManager created." << std::endl;

  int updateInstrumentDefinitions = 0;
  int reVal = Kernel::ConfigService::Instance().getValue("UpdateInstrumentDefinitions.OnStartup",updateInstrumentDefinitions);
  if ((reVal == 1) &&  (updateInstrumentDefinitions == 1))
  {
    UpdateInstrumentDefinitions();
  }
  else
  {
    g_log.information() << "Instrument updates disabled - cannot update instrument definitions." << std::endl;
  }
}
/// Starts asynchronous tasks that are done as part of Start-up.
void FrameworkManagerImpl::AsynchronousStartupTasks() {
  int updateInstrumentDefinitions = 0;
  int retVal = Kernel::ConfigService::Instance().getValue(
      "UpdateInstrumentDefinitions.OnStartup", updateInstrumentDefinitions);
  if ((retVal == 1) && (updateInstrumentDefinitions == 1)) {
    UpdateInstrumentDefinitions();
  } else {
    g_log.information()
        << "Instrument updates disabled - cannot update instrument definitions."
        << std::endl;
  }

  int checkIfNewerVersionIsAvailable = 0;
  int retValVersionCheck = Kernel::ConfigService::Instance().getValue(
      "CheckMantidVersion.OnStartup", checkIfNewerVersionIsAvailable);
  if ((retValVersionCheck == 1) && (checkIfNewerVersionIsAvailable == 1)) {
    CheckIfNewerVersionIsAvailable();
  } else {
    g_log.information() << "Version check disabled." << std::endl;
  }

  setupUsageReporting();
}