Skip to content

Commit

Permalink
Refs #6473. Merge remote-tracking branch 'origin/master' into 6473
Browse files Browse the repository at this point in the history
Conflicts:
	Code/Mantid/MantidQt/MantidWidgets/CMakeLists.txt
  • Loading branch information
arturbekasov committed Dec 12, 2013
2 parents 9483f88 + 8228873 commit cc81dc1
Show file tree
Hide file tree
Showing 353 changed files with 24,796 additions and 10,037 deletions.
4 changes: 3 additions & 1 deletion Code/Mantid/Build/CMake/CppCheckSetup.cmake
Expand Up @@ -57,6 +57,8 @@ if ( CPPCHECK_EXECUTABLE )
Framework/Kernel/src/Math/Optimization/SLSQPMinimizer.cpp
MantidPlot/src/nrutil.cpp
MantidPlot/src/origin/OPJFile.cpp
MantidPlot/src/zlib123/minigzip.c
Framework/SINQ/src/PoldiPeakFit.cpp
)

# Header files to be ignored require different handling
Expand Down Expand Up @@ -114,7 +116,7 @@ if ( CPPCHECK_EXECUTABLE )
# put the finishing bits on the final command call
set (_cppcheck_xml_args)
if (CPPCHECK_GENERATE_XML)
list( APPEND _cppcheck_xml_args --xml --xml-version=2 ${_cppcheck_source_dirs} 2> ${CMAKE_BINARY_DIR}/cppcheck.xml )
list( APPEND _cppcheck_xml_args --xml --xml-version=2 ${_cppcheck_source_dirs} 2> ${CMAKE_BINARY_DIR}/cppcheck.xml )
else (CPPCHECK_GENERATE_XML)
list( APPEND _cppcheck_xml_args ${_cppcheck_source_dirs} )
endif (CPPCHECK_GENERATE_XML)
Expand Down
11 changes: 11 additions & 0 deletions Code/Mantid/Build/CMake/CppCheck_Suppressions.txt
@@ -0,0 +1,11 @@
// suppress memleak and exceptNew errors in the file src/file1.cpp
//memleak:src/file1.cpp
//exceptNew:src/file1.cpp

// suppress in all files - BE CAREFULL not to leave trailing spaces after the rule id. or empty lines
// This finds false positives where private member variable names reused by inheriting classes
duplInheritedMember
// For a library this is not a problem per se
unusedFunction
// cppcheck has problems handling the number of pre-processor definitions used in the DLL_EXPORTs
class_X_Y
4 changes: 2 additions & 2 deletions Code/Mantid/Build/CMake/FindCppcheck.cmake
Expand Up @@ -29,7 +29,7 @@ endif()
find_program(CPPCHECK_EXECUTABLE NAMES cppcheck)

if(MSVC)
set(CPPCHECK_TEMPLATE_ARG --template vs)
set(CPPCHECK_TEMPLATE_ARG --template "{file}({line}): warning : ({severity}-{id}) {message}")
set(CPPCHECK_FAIL_REGULAR_EXPRESSION "[(]error[)]")
set(CPPCHECK_WARN_REGULAR_EXPRESSION "[(]style[)]")
elseif(CMAKE_COMPILER_IS_GNUCXX)
Expand Down Expand Up @@ -61,7 +61,7 @@ if(CPPCHECK_EXECUTABLE)
endif()

mark_as_advanced(CPPCHECK_EXECUTABLE)
set ( CPPCHECK_ARGS --enable=all --inline-suppr CACHE STRING "Arguments for running cppcheck" )
set ( CPPCHECK_ARGS --enable=all --inline-suppr CACHE STRING "Arguments for running cppcheck" --suppressions ${CMAKE_CURRENT_SOURCE_DIR}/Build/CMake/CppCheck_Suppressions.txt )
set ( CPPCHECK_NUM_THREADS 0 CACHE STRING "Number of threads to use when running cppcheck" )
set ( CPPCHECK_GENERATE_XML OFF CACHE BOOL "Generate xml output files from cppcheck" )

Expand Down
5 changes: 0 additions & 5 deletions Code/Mantid/Build/CMake/WindowsNSIS.cmake
Expand Up @@ -83,11 +83,6 @@
install ( FILES ${VC_REDIST}/${REDIST_SUBDIR}/${DLL} DESTINATION bin )
endforeach()

# Copy Intel fortran libraries from numpy to general bin directory. Both numpy & scipy are compiled with intel compiler as it is the only way to get 64-bit libs at the moment.
# This means scipy requires the intel libraries that are stuck in numpy/core.
file ( GLOB INTEL_DLLS "${CMAKE_LIBRARY_PATH}/Python27/Lib/site-packages/numpy/core/*.dll" )
install ( FILES ${INTEL_DLLS} DESTINATION ${INBUNDLE}bin )

# Copy third party dlls excluding selected Qt ones and debug ones
install ( DIRECTORY ${CMAKE_LIBRARY_PATH}/ DESTINATION bin FILES_MATCHING PATTERN "*.dll"
REGEX "${CMAKE_LIBRARY_PATH}/CRT/*" EXCLUDE
Expand Down
13 changes: 8 additions & 5 deletions Code/Mantid/Framework/API/CMakeLists.txt
Expand Up @@ -95,6 +95,7 @@ set ( SRC_FILES
src/Run.cpp
src/Sample.cpp
src/SampleEnvironment.cpp
src/ScopedWorkspace.cpp
src/ScriptRepository.cpp
src/ScriptRepositoryFactory.cpp
src/SpectraAxis.cpp
Expand Down Expand Up @@ -241,6 +242,7 @@ set ( INC_FILES
inc/MantidAPI/Run.h
inc/MantidAPI/Sample.h
inc/MantidAPI/SampleEnvironment.h
inc/MantidAPI/ScopedWorkspace.h
inc/MantidAPI/ScriptRepository.h
inc/MantidAPI/ScriptRepositoryFactory.h
inc/MantidAPI/SingleValueParameter.h
Expand Down Expand Up @@ -288,25 +290,25 @@ set ( TEST_FILES
FilePropertyTest.h
FrameworkManagerTest.h
FuncMinimizerFactoryTest.h
FunctionAttributeTest.h
FunctionDomainTest.h
FunctionFactoryTest.h
FunctionAttributeTest.h
FunctionDomainTest.h
FunctionFactoryTest.h
FunctionPropertyTest.h
FunctionTest.h
FunctionValuesTest.h
IEventListTest.h
IFunction1DTest.h
IFunctionMDTest.h
IkedaCarpenterModeratorTest.h
ILiveListenerTest.h
IMDWorkspaceTest.h
ISpectrumTest.h
IkedaCarpenterModeratorTest.h
ImmutableCompositeFunctionTest.h
ImplicitFunctionParserFactoryTest.h
IncreasingAxisValidatorTest.h
InstrumentDataServiceTest.h
LiveListenerFactoryTest.h
LogManagerTest.h
LogManagerTest.h
MDGeometryTest.h
MatrixWorkspaceMDIteratorTest.h
MemoryManagerTest.h
Expand All @@ -324,6 +326,7 @@ set ( TEST_FILES
RunTest.h
SampleEnvironmentTest.h
SampleTest.h
ScopedWorkspaceTest.h
SpectraAxisTest.h
SpectrumDetectorMappingTest.h
TextAxisTest.h
Expand Down
4 changes: 3 additions & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/ICatalog.h
Expand Up @@ -50,7 +50,9 @@ class DLLExport ICatalog
/// logout from catalog
virtual void logout()=0;
///Search investigations
virtual void search(const ICat::CatalogSearchParam&,ITableWorkspace_sptr &)=0;
virtual void search(const ICat::CatalogSearchParam&,ITableWorkspace_sptr&, const int &offset,const int &limit)=0;
/// Obtain the number of results returned by the search method.
virtual int64_t getNumberOfSearchResults(const ICat::CatalogSearchParam&)=0;
/// search logged in users data
virtual void myData(ITableWorkspace_sptr &)=0;
/// get datasets.
Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h
Expand Up @@ -422,7 +422,8 @@ class MANTID_API_DLL IFunction
/// Set an attribute value
template<typename T>
void setAttributeValue(const std::string& attName,const T& value){setAttribute(attName,Attribute(value));}
void setAttributeValue(const std::string& attName,const char* value){setAttribute(attName,Attribute(std::string(value)));}
void setAttributeValue(const std::string& attName,const char* value);
void setAttributeValue(const std::string& attName,const std::string& value);
//@}

/// Set up the function for a fit.
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDEventWorkspace.h
Expand Up @@ -68,6 +68,8 @@ namespace API

/// Return the type of event contained, as a string. MDEvent or MDLeanEvent
virtual std::string getEventTypeName() const = 0;
/// Return the size(in bytes) for the event, which this workspace contains
virtual size_t sizeofEvent()const = 0;

/// Split all boxes that exceed the split threshold.
virtual void splitAllIfNeeded(Kernel::ThreadScheduler * ts) = 0;
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDNode.h
Expand Up @@ -209,6 +209,8 @@ class IMDNode
virtual coord_t * getVertexesArray(size_t & numVertices, const size_t outDimensions, const bool * maskDim) const=0;
virtual void transformDimensions(std::vector<double> & scaling, std::vector<double> & offset)=0;

// to avoid casting (which need also the number of dimensions) method say if Node is a box. if not, it is gridbox
virtual bool isBox()const=0;
// ----------------------------- Helper Methods --------------------------------------------------------
//-----------------------------------------------------------------------------------------------
/** Helper method for sorting MDBoxBasees by file position.
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h
Expand Up @@ -120,6 +120,7 @@ namespace Mantid
virtual ITableWorkspace_sptr makeBoxTable(size_t /*start*/, size_t /* num*/)
{throw Kernel::Exception::NotImplementedError("This method is not generally implemented ");}


protected:
virtual const std::string toString() const;
};
Expand Down
92 changes: 92 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/ScopedWorkspace.h
@@ -0,0 +1,92 @@
#ifndef MANTID_API_SCOPEDWORKSPACE_H_
#define MANTID_API_SCOPEDWORKSPACE_H_

#include <string>

#include "MantidKernel/ClassMacros.h"
#include "MantidKernel/System.h"
#include "MantidAPI/Workspace.h"

namespace Mantid
{
namespace API
{
/** ScopedWorkspace : scoped workspace ADS entry.
This class is provided for situations when you need a workspace to be in the ADS to run an
algorithm, but you don't really need to keep it there after the algorithm has finished. In
these circumstances you can create ScopedWorkspace, set it's name as a workspace property
for the algorithm and retrieve it when algorithm has finished. The workspace will be
removed from the ADS when the object goes out of scope, or exception is thrown.
Primarily, it was created to overcome some limitations of WorkspaceProperties, but it can be
useful in other places, e.g. tests.
Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ScopedWorkspace
{
public:
/// Empty constructor
ScopedWorkspace();

/// Workspace constructor
ScopedWorkspace(Workspace_sptr ws);

/// Destructor
virtual ~ScopedWorkspace();

/// Returns ADS name of the workspace
std::string name() const { return m_name; }

/// Retrieve workspace from the ADS
Workspace_sptr retrieve() const;

/// Removes the workspace entry from the ADS
void remove();

/// Operator for conversion to boolean
operator bool() const;

/// Make ADS entry to point to the given workspace
void set(Workspace_sptr newWS);

private:
DISABLE_COPY_AND_ASSIGN(ScopedWorkspace);

/// ADS name of the workspace
const std::string m_name;

/// Generates a tricky name which is unique within ADS
static std::string generateUniqueName();

/// Generates a random alpha-numeric string
static std::string randomString(size_t len);

/// Length of workspace names generated
static const size_t NAME_LENGTH;
};


} // namespace API
} // namespace Mantid

#endif /* MANTID_API_SCOPEDWORKSPACE_H_ */
10 changes: 10 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceProperty.h
Expand Up @@ -147,6 +147,11 @@ namespace Mantid
*/
virtual boost::shared_ptr<TYPE>& operator=( const boost::shared_ptr<TYPE>& value )
{
std::string wsName = value->name();
if ( this->direction() == Kernel::Direction::Input && !wsName.empty() )
{
m_workspaceName = wsName;
}
return Kernel::PropertyWithValue< boost::shared_ptr<TYPE> >::operator=( value );
}

Expand Down Expand Up @@ -215,6 +220,11 @@ namespace Mantid
boost::shared_ptr<TYPE> typed = boost::dynamic_pointer_cast<TYPE>(value);
if(typed)
{
std::string wsName = typed->name();
if ( this->direction() == Kernel::Direction::Input && !wsName.empty() )
{
m_workspaceName = wsName;
}
Kernel::PropertyWithValue< boost::shared_ptr<TYPE> >::m_value = typed;
}
else
Expand Down
51 changes: 41 additions & 10 deletions Code/Mantid/Framework/API/src/Algorithm.cpp
Expand Up @@ -715,22 +715,53 @@ namespace Mantid
void Algorithm::store()
{
const std::vector< Property*> &props = getProperties();
std::vector<int> groupWsIndicies;

//add any regular/child workspaces first, then add the groups
for (unsigned int i = 0; i < props.size(); ++i)
{
IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty*>(props[i]);
if (wsProp)
{
try
{
wsProp->store();
}
catch (std::runtime_error&)
{
g_log.error("Error storing output workspace in AnalysisDataService");
throw;
}
{
//check if the workspace is a group, if so remember where it is and add it later
auto group = boost::dynamic_pointer_cast<WorkspaceGroup>( wsProp->getWorkspace() );
if ( !group )
{
try
{
wsProp->store();
}
catch (std::runtime_error&)
{
g_log.error("Error storing output workspace in AnalysisDataService");
throw;
}
}
else
{
groupWsIndicies.push_back(i);
}
}
}

//now store workspace groups once their members have been added
std::vector<int>::const_iterator wsIndex;
for (wsIndex = groupWsIndicies.begin(); wsIndex != groupWsIndicies.end(); ++wsIndex)
{
IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty*>(props[*wsIndex]);
if(wsProp)
{
try
{
wsProp->store();
}
catch (std::runtime_error&)
{
g_log.error("Error storing output workspace in AnalysisDataService");
throw;
}
}
}
}

//---------------------------------------------------------------------------------------------
Expand Down
17 changes: 10 additions & 7 deletions Code/Mantid/Framework/API/src/FileProperty.cpp
Expand Up @@ -42,7 +42,7 @@ FileProperty::FileProperty(const std::string & name, const std::string& default_
/* Create either a FileValidator or a DirectoryValidator, depending on Action */
(action == FileProperty::Directory || action == FileProperty::OptionalDirectory) ?
boost::make_shared<DirectoryValidator>(action == FileProperty::Directory) :
boost::make_shared<FileValidator>(exts, (action == FileProperty::Load) )
boost::make_shared<FileValidator>(exts, (action == FileProperty::Load), (action == FileProperty::Save) )
, direction),
m_action(action),
m_defaultExt(""),
Expand All @@ -69,7 +69,7 @@ FileProperty::FileProperty(const std::string & name, const std::string& default_
/* Create either a FileValidator or a DirectoryValidator, depending on Action */
(action == FileProperty::Directory || action == FileProperty::OptionalDirectory) ?
boost::make_shared<DirectoryValidator>(action == FileProperty::Directory) :
boost::make_shared<FileValidator>(std::vector<std::string>(1,ext), (action == FileProperty::Load) )
boost::make_shared<FileValidator>(std::vector<std::string>(1,ext), (action == FileProperty::Load), (action == FileProperty::Save) )
, direction),
m_action(action),
m_defaultExt(ext),
Expand Down Expand Up @@ -370,27 +370,30 @@ std::string FileProperty::createDirectory(const std::string & path) const
{
stempath.makeParent();
}
std::string error("");

if( !stempath.toString().empty() )
{
Poco::File stem(stempath);
if( !stem.exists() )
{
try
{
stem.createDirectories();
stem.createDirectories();
}
catch(Poco::Exception &e)
{
error = e.what();
std::stringstream msg;
msg << "Failed to create directory \"" << stempath.toString()
<< "\": " << e.what() ;
return msg.str();
}
}
}
else
{
error = "Invalid directory.";
return "Invalid directory.";
}
return error;
return ""; // everything went fine
}

/**
Expand Down

0 comments on commit cc81dc1

Please sign in to comment.