Changeset 5365
- Timestamp:
- 27/07/10 09:41:09 (6 weeks ago)
- Location:
- trunk/Code/Mantid
- Files:
-
- 3 added
- 7 modified
-
API/API.vcproj (modified) (2 diffs)
-
API/inc/MantidAPI/FileFinder.h (added)
-
API/src/FileFinder.cpp (added)
-
API/test/FileFinderTest.h (added)
-
Algorithms/Algorithms.vcproj (modified) (2 diffs)
-
Kernel/inc/MantidKernel/ConfigService.h (modified) (2 diffs)
-
Kernel/inc/MantidKernel/FacilityInfo.h (modified) (1 diff)
-
Kernel/src/ConfigService.cpp (modified) (5 diffs)
-
Kernel/src/FacilityInfo.cpp (modified) (4 diffs)
-
Kernel/test/FacilitiesTest.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Code/Mantid/API/API.vcproj
r5353 r5365 232 232 </File> 233 233 <File 234 RelativePath=".\src\FileFinder.cpp" 235 > 236 </File> 237 <File 234 238 RelativePath=".\src\FrameworkManager.cpp" 235 239 > … … 473 477 <File 474 478 RelativePath=".\test\ExpressionTest.h" 479 > 480 </File> 481 <File 482 RelativePath=".\inc\MantidAPI\FileFinder.h" 483 > 484 </File> 485 <File 486 RelativePath=".\test\FileFinderTest.h" 475 487 > 476 488 </File> -
trunk/Code/Mantid/Algorithms/Algorithms.vcproj
r5271 r5365 192 192 </File> 193 193 <File 194 RelativePath=".\src\ApplyTransmissionCorrection.cpp" 195 > 196 </File> 197 <File 194 198 RelativePath=".\src\BinaryOperation.cpp" 195 199 > … … 563 567 <File 564 568 RelativePath=".\test\AnyShapeAbsorptionTest.h" 569 > 570 </File> 571 <File 572 RelativePath=".\inc\MantidAlgorithms\ApplyTransmissionCorrection.h" 565 573 > 566 574 </File> -
trunk/Code/Mantid/Kernel/inc/MantidKernel/ConfigService.h
r5348 r5365 98 98 const std::vector<std::string>& getInstrumentPrefixes(const std::string& facility) const; 99 99 100 /// Load facility information from instrumentDir/Facilities.xml file 101 void updateFacilities(const std::string& fName = ""); 100 102 /// Get the default facility 101 103 const FacilityInfo& Facility()const; … … 132 134 /// Create the map of facility name to instrument prefix list 133 135 void cacheInstrumentPrefixes(); 134 /// Load facility information from instrumentDir/Facilities.xml file135 void updateFacilities();136 136 137 137 // Forward declaration of inner class -
trunk/Code/Mantid/Kernel/inc/MantidKernel/FacilityInfo.h
r5333 r5365 70 70 const std::vector<InstrumentInfo> Instruments(const std::string& tech)const; 71 71 /// Returns instruments with given name 72 const InstrumentInfo Instrument(const std::string& iName )const;72 const InstrumentInfo Instrument(const std::string& iName = "")const; 73 73 private: 74 74 /// Add new extension -
trunk/Code/Mantid/Kernel/src/ConfigService.cpp
r5348 r5365 166 166 ConfigServiceImpl::~ConfigServiceImpl() 167 167 { 168 std::cerr << "ConfigService destroyed." << std::endl; 168 169 Kernel::Logger::shutdown(); 169 170 delete m_pSysConfig; … … 859 860 860 861 /** 861 * Load facility information from instrumentDir/Facilities.xml file 862 * Load facility information from instrumentDir/Facilities.xml file if fName parameter 863 * is not set 864 * @param fName An alternative file name for loading facilities information. 862 865 */ 863 void ConfigServiceImpl::updateFacilities() 864 { 866 void ConfigServiceImpl::updateFacilities(const std::string& fName) 867 { 868 m_facilities.clear(); 869 865 870 std::string instrDir = getString("instrumentDefinition.directory"); 866 std::string fileName = instrDir + "Facilities.xml";871 std::string fileName = fName.empty() ? instrDir + "Facilities.xml" : fName; 867 872 868 873 // Set up the DOM parser and parse xml file … … 876 881 { 877 882 g_log.error("Unable to parse file " + fileName); 878 throw Kernel::Exception::FileError("Unable to parse File:" , fileName);883 throw Kernel::Exception::FileError("Unable to parse file:" , fileName); 879 884 } 880 885 // Get pointer to root element … … 883 888 { 884 889 g_log.error("XML file: " + fileName + "contains no root element."); 885 throw Kernel::Exception::InstrumentDefinitionError("No root element in XML facilities file", fileName);890 throw std::runtime_error("No root element in Facilities.xml file"); 886 891 } 887 892 … … 896 901 m_facilities.push_back(new FacilityInfo(elem)); 897 902 } 903 } 904 905 if (m_facilities.empty()) 906 { 907 throw std::runtime_error("The facility definition file "+fileName+" defines no facilities"); 898 908 } 899 909 -
trunk/Code/Mantid/Kernel/src/FacilityInfo.cpp
r5333 r5365 5 5 #include "MantidKernel/Support.h" 6 6 #include "MantidKernel/Exception.h" 7 #include "MantidKernel/ConfigService.h" 7 8 8 9 #include "Poco/DOM/Element.h" … … 29 30 if (m_name.empty()) 30 31 { 31 g_log.error("Facility anme is not defined");32 throw std::runtime_error("Facility anme is not defined");32 g_log.error("Facility name is not defined"); 33 throw std::runtime_error("Facility name is not defined"); 33 34 } 34 35 std::string paddingStr = elem->getAttribute("zeropadding"); … … 68 69 } 69 70 } 71 72 if (m_instruments.empty()) 73 { 74 throw std::runtime_error("Facility "+m_name+" does not have any instrument;"); 75 } 70 76 } 71 77 … … 90 96 const InstrumentInfo FacilityInfo::Instrument(const std::string& iName)const 91 97 { 98 std::string iname; 99 if (iName.empty()) 100 { 101 iname = ConfigService::Instance().getString("default.instrument"); 102 if (iname.empty()) 103 { 104 return m_instruments.front(); 105 } 106 } 107 else 108 { 109 iname = iName; 110 } 92 111 std::vector<InstrumentInfo>::const_iterator it = m_instruments.begin(); 93 112 for(;it != m_instruments.end(); ++it) 94 113 { 95 if (it->name() == i Name)114 if (it->name() == iname) 96 115 { 97 116 return *it; 98 117 } 99 118 } 100 g_log.error("Instrument "+iName+" not found in facility "+name()); 101 throw Exception::NotFoundError("FacilityInfo",iName); 119 120 // if unsuccessful try shortname 121 for(it = m_instruments.begin(); it != m_instruments.end(); ++it) 122 { 123 if (it->shortName() == iname) 124 { 125 return *it; 126 } 127 } 128 g_log.error("Instrument "+iname+" not found in facility "+name()); 129 throw Exception::NotFoundError("FacilityInfo",iname); 102 130 } 103 131 -
trunk/Code/Mantid/Kernel/test/FacilitiesTest.h
r5333 r5365 90 90 } 91 91 92 void testDefaultFacility() 93 { 94 TS_ASSERT_THROWS_NOTHING( 95 const FacilityInfo& fac = ConfigService::Instance().Facility() 96 ); 97 const FacilityInfo& fac = ConfigService::Instance().Facility(); 98 TS_ASSERT_EQUALS(fac.name(),"ISIS"); 99 100 ConfigService::Instance().setString("default.facility","SNS"); 101 const FacilityInfo& fac1 = ConfigService::Instance().Facility(); 102 TS_ASSERT_EQUALS(fac1.name(),"SNS"); 103 104 ConfigService::Instance().setString("default.facility",""); 105 const FacilityInfo& fac2 = ConfigService::Instance().Facility(); 106 TS_ASSERT_EQUALS(fac2.name(),"ISIS"); 107 } 108 109 void testDefaultInstrument() 110 { 111 ConfigService::Instance().setString("default.instrument","HRPD"); 112 const FacilityInfo& fac = ConfigService::Instance().Facility(); 113 InstrumentInfo instr = fac.Instrument(); 114 TS_ASSERT_EQUALS(instr.name(),"HRPD"); 115 } 116 92 117 private: 93 118
