Skip to content
Snippets Groups Projects
Commit 8f87459c authored by Nick Draper's avatar Nick Draper
Browse files

re #34

Improveed handling if properties file missing.
Changed VS build to use dynamic loading
parent d0079761
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Includes // Includes
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#include "MantidAPI/AlgorithmHistory.h" #include "MantidAPI/AlgorithmHistory.h"
#include "boost/date_time/posix_time/posix_time.hpp"
namespace Mantid namespace Mantid
{ {
......
...@@ -52,10 +52,12 @@ void FrameworkManager::initialize() ...@@ -52,10 +52,12 @@ void FrameworkManager::initialize()
workFactory = WorkspaceFactory::Instance(); workFactory = WorkspaceFactory::Instance();
data = AnalysisDataService::Instance(); data = AnalysisDataService::Instance();
config->loadConfig("Mantid.properties");
std::string pluginDir = config->getString("plugins.directory"); std::string pluginDir = config->getString("plugins.directory");
libManager = Mantid::Kernel::LibraryManager::Instance(); if (pluginDir.length() > 0)
libManager->OpenAllLibraries(pluginDir, false); {
libManager = Mantid::Kernel::LibraryManager::Instance();
libManager->OpenAllLibraries(pluginDir, false);
}
return; return;
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
// Includes // Includes
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#include "MantidKernel/System.h" #include "MantidKernel/System.h"
#include "MantidKernel/Logger.h"
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <string> #include <string>
...@@ -151,6 +152,9 @@ namespace Kernel ...@@ -151,6 +152,9 @@ namespace Kernel
/// Pointer to the factory instance /// Pointer to the factory instance
static ConfigService* m_instance; static ConfigService* m_instance;
/// static reference to the logger class
static Logger& g_log;
}; };
} // namespace Kernel } // namespace Kernel
......
...@@ -17,6 +17,9 @@ namespace Kernel ...@@ -17,6 +17,9 @@ namespace Kernel
// Initialise the instance pointer to zero // Initialise the instance pointer to zero
ConfigService* ConfigService::m_instance=0; ConfigService* ConfigService::m_instance=0;
// Get a reference to the logger
Logger& ConfigService::g_log = Logger::get("ConfigService");
/** A static method which retrieves the single instance of the ConfigService /** A static method which retrieves the single instance of the ConfigService
* *
* @returns A pointer to the instance * @returns A pointer to the instance
...@@ -102,11 +105,21 @@ namespace Kernel ...@@ -102,11 +105,21 @@ namespace Kernel
* returns the value as a string. * returns the value as a string.
* *
* @param keyName The case sensitive name of the property that you need the value of. * @param keyName The case sensitive name of the property that you need the value of.
* @returns The string value of the property * @returns The string value of the property, or an empty string if the key cannot be found
*/ */
std::string ConfigService::getString(const std::string& keyName) std::string ConfigService::getString(const std::string& keyName)
{ {
return m_pConf->getString(keyName); std::string retVal;
try
{
retVal = m_pConf->getString(keyName);
}
catch(Poco::NotFoundException& ex)
{
g_log.warning()<<"Unable to find " << keyName << " in the properties file";
retVal = "";
}
return retVal;
} }
/** Searches for a string within the currently loaded configuaration values and /** Searches for a string within the currently loaded configuaration values and
......
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <ctime> #include <ctime>
#include "Benchmark.h" #include "Benchmark.h"
#include "MantidAPI\IAlgorithm.h"
using namespace Mantid::Kernel; using namespace Mantid::Kernel;
using namespace Mantid::DataObjects; using namespace Mantid::DataObjects;
using namespace Mantid::API; using namespace Mantid::API;
using namespace Mantid::Algorithms;
Workspace1D_sptr Benchmark::Create1DWorkspaceFib(int size) Workspace1D_sptr Benchmark::Create1DWorkspaceFib(int size)
{ {
...@@ -89,15 +88,16 @@ void Benchmark::RunPlusTest(int detectorCount, int timeBinCount) ...@@ -89,15 +88,16 @@ void Benchmark::RunPlusTest(int detectorCount, int timeBinCount)
ADS->add("test_in11", work_in3); ADS->add("test_in11", work_in3);
ADS->add("test_in12", work_in4); ADS->add("test_in12", work_in4);
Plus plus_alg;
IAlgorithm* alg = FrameworkManager::Instance()->createAlgorithm("Plus");
plus_alg.initialize(); //alg.initialize();
plus_alg.setPropertyValue("InputWorkspace_1","test_in11"); alg->setPropertyValue("InputWorkspace_1","test_in11");
plus_alg.setPropertyValue("InputWorkspace_2","test_in12"); alg->setPropertyValue("InputWorkspace_2","test_in12");
plus_alg.setPropertyValue("OutputWorkspace","test_out1"); alg->setPropertyValue("OutputWorkspace","test_out1");
clock_t start = clock(); clock_t start = clock();
plus_alg.execute(); alg->execute();
clock_t end = clock(); clock_t end = clock();
Workspace_sptr work_out1 = ADS->retrieve("test_out1"); Workspace_sptr work_out1 = ADS->retrieve("test_out1");
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
// Includes // Includes
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/AnalysisDataService.h"
#include "MantidAlgorithms/Plus.h" #include "MantidAPI/FrameworkManager.h"
#include "MantidAlgorithms/Multiply.h"
#include "MantidAPI/Workspace.h" #include "MantidAPI/Workspace.h"
#include "MantidAPI/Algorithm.h" #include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/Workspace1D.h" #include "MantidDataObjects/Workspace1D.h"
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
using namespace Mantid::Kernel; using namespace Mantid::Kernel;
using namespace Mantid::DataObjects; using namespace Mantid::DataObjects;
using namespace Mantid::API; using namespace Mantid::API;
using namespace Mantid::Algorithms;
...@@ -17,7 +16,7 @@ int main() ...@@ -17,7 +16,7 @@ int main()
{ {
FrameworkManager* fm = FrameworkManager::Instance(); FrameworkManager* fm = FrameworkManager::Instance();
//fm->initialize(); fm->initialize();
Benchmark b; Benchmark b;
b.RunPlusTest(); b.RunPlusTest();
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="$(SolutionName)API.lib $(SolutionName)Kernel.lib $(SolutionName)Algorithms.lib $(SolutionName)Geometry.lib $(SolutionName)DataHandling.lib $(SolutionName)DataObjects.lib" AdditionalDependencies="$(SolutionName)API.lib $(SolutionName)Kernel.lib $(SolutionName)Geometry.lib"
OutputFile="$(OutDir)\$(SolutionName)$(ProjectName).exe" OutputFile="$(OutDir)\$(SolutionName)$(ProjectName).exe"
AdditionalLibraryDirectories="..\..\Third_Party\lib\win32;..\Debug" AdditionalLibraryDirectories="..\..\Third_Party\lib\win32;..\Debug"
GenerateDebugInformation="true" GenerateDebugInformation="true"
...@@ -122,9 +122,9 @@ ...@@ -122,9 +122,9 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="$(SolutionName)API.lib $(SolutionName)Kernel.lib $(SolutionName)Algorithms.lib $(SolutionName)Geometry.lib $(SolutionName)DataHandling.lib $(SolutionName)DataObjects.lib" AdditionalDependencies="$(SolutionName)API.lib $(SolutionName)Kernel.lib $(SolutionName)Geometry.lib $(SolutionName)DataObjects.lib"
OutputFile="$(OutDir)\$(SolutionName)$(ProjectName).exe" OutputFile="$(OutDir)\$(SolutionName)$(ProjectName).exe"
AdditionalLibraryDirectories="..\Release" AdditionalLibraryDirectories="..\Release;..\..\Third_Party\lib\win32"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
......
#framework configuration
plugins.directory = .
#logging configuration
logging.loggers.root.level = debug
logging.loggers.root.channel.class = SplitterChannel
logging.loggers.root.channel.channel1 = consoleChannel
logging.loggers.root.channel.channel2 = fileChannel
logging.channels.consoleChannel.class = ConsoleChannel
logging.channels.consoleChannel.formatter = f1
logging.channels.fileChannel.class = FileChannel
logging.channels.fileChannel.path = mantid.log
logging.channels.fileChannel.formatter.class = PatternFormatter
logging.channels.fileChannel.formatter.pattern = %Y-%m-%d %H:%M:%S,%i [%I] %p %s - %t
logging.formatters.f1.class = PatternFormatter
logging.formatters.f1.pattern = %s-[%p] %t
logging.formatters.f1.times = UTC;
#framework configuration
plugins.directory = .
#logging configuration
logging.loggers.root.level = debug
logging.loggers.root.channel.class = SplitterChannel
logging.loggers.root.channel.channel1 = consoleChannel
logging.loggers.root.channel.channel2 = fileChannel
logging.channels.consoleChannel.class = ConsoleChannel
logging.channels.consoleChannel.formatter = f1
logging.channels.fileChannel.class = FileChannel
logging.channels.fileChannel.path = mantid.log
logging.channels.fileChannel.formatter.class = PatternFormatter
logging.channels.fileChannel.formatter.pattern = %Y-%m-%d %H:%M:%S,%i [%I] %p %s - %t
logging.formatters.f1.class = PatternFormatter
logging.formatters.f1.pattern = %s-[%p] %t
logging.formatters.f1.times = UTC;
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