Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/8026_ConvertToMDFails
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Jun 3, 2014
2 parents daee68b + 9dd0d9f commit ccefe54
Show file tree
Hide file tree
Showing 1,310 changed files with 7,755 additions and 10,679 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Build/CMake/FindSphinx.cmake
Expand Up @@ -8,6 +8,7 @@
# SPHINX_EXECUTABLE

find_program( SPHINX_EXECUTABLE NAME sphinx-build
PATHS ${CMAKE_LIBRARY_PATH}/Python27/Scripts
PATH_SUFFIXES bin
DOC "Sphinx documentation generator"
)
Expand Down
14 changes: 4 additions & 10 deletions Code/Mantid/Build/class_maker.py
Expand Up @@ -30,9 +30,9 @@ def write_header(subproject, classname, filename, args):
virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;
private:
virtual void initDocs();
void init();
void exec();
Expand Down Expand Up @@ -125,22 +125,16 @@ def write_source(subproject, classname, filename, args):

algorithm_source = """
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string %s::name() const { return "%s";};
/// Algorithm's version for identification. @see Algorithm::version
int %s::version() const { return 1;};
/// Algorithm's category for identification. @see Algorithm::category
const std::string %s::category() const { return TODO: FILL IN A CATEGORY;}
//----------------------------------------------------------------------------------------------
/// Sets documentation strings for this algorithm
void %s::initDocs()
{
this->setWikiSummary("TODO: Enter a quick description of your algorithm.");
this->setOptionalMessage("TODO: Enter a quick description of your algorithm.");
}
/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary
const std::string %s::summary() const { return TODO: FILL IN A SUMMARY;};
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Build/wiki_tools.py
Expand Up @@ -121,7 +121,7 @@ def get_custom_wiki_section(algo, version, tag, tryUseDescriptionFromBinaries=Fa
from mantid.api import AlgorithmManager
alg = AlgorithmManager.createUnmanaged(algo, version)
print "Getting algorithm description from binaries."
return alg.getWikiDescription()
return alg.summary()
elif source == '' and not tryUseDescriptionFromBinaries:
print "Warning: Cannot find source for algorithm"
return desc
Expand Down
37 changes: 9 additions & 28 deletions Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h
Expand Up @@ -177,15 +177,18 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManag
virtual const std::string name() const = 0;
/// function to return a version of the algorithm, must be overridden in all algorithms
virtual int version() const = 0;
/// function returns a summary message that will be displayed in the default GUI, and in the help.
virtual const std::string summary() const = 0;
/// function to return a category of the algorithm. A default implementation is provided
virtual const std::string category() const {return "Misc";}
/// Function to return all of the categories that contain this algorithm
virtual const std::vector<std::string> categories() const;
/// Function to return the sperator token for the category string. A default implementation ';' is provided
/// Function to return the separator token for the category string. A default implementation ';' is provided
virtual const std::string categorySeparator() const {return ";";}
/// function to return any aliases to the algorithm; A default implementation is provided
virtual const std::string alias() const {return "";}


const std::string workspaceMethodName() const;
const std::vector<std::string> workspaceMethodOn() const;
const std::string workspaceMethodInputProperty() const;
Expand Down Expand Up @@ -237,25 +240,6 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManag
///returns the logging priority offset
int getLoggingOffset() const { return g_log.getLevelOffset(); }


/// function returns an optional message that will be displayed in the default GUI, at the top.
const std::string getOptionalMessage() const { return m_OptionalMessage;}

/// Set an optional message that will be displayed in the default GUI, at the top.
void setOptionalMessage(const std::string optionalMessage) { m_OptionalMessage = optionalMessage;}

/// Get a summary to be used in the wiki page.
const std::string getWikiSummary() const { return m_WikiSummary;}

/// Set a summary to be used in the wiki page. Normally, this is approx. the same as the optional message.
void setWikiSummary(const std::string WikiSummary) { m_WikiSummary = WikiSummary;}

/// Get a description to be used in the wiki page.
const std::string getWikiDescription() const { return m_WikiDescription;}

/// Set a string to be used as the Description field in the wiki page.
void setWikiDescription(const std::string WikiDescription) { m_WikiDescription = WikiDescription;}

///setting the child start progress
void setChildStartProgress(const double startProgress)const{m_startChildProgress=startProgress;}
/// setting the child end progress
Expand Down Expand Up @@ -283,8 +267,6 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManag
virtual void init() = 0;
/// Virtual method - must be overridden by concrete algorithm
virtual void exec() = 0;
/// Method defining summary, optional
virtual void initDocs() {};

/// Returns a semi-colon separated list of workspace types to attach this algorithm
virtual const std::string workspaceMethodOnTypes() const { return ""; }
Expand Down Expand Up @@ -349,6 +331,9 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManag
Kernel::Logger m_log;
Kernel::Logger &g_log;

/// Pointer to the parent history object (if set)
boost::shared_ptr<AlgorithmHistory> m_parentHistory;

private:
/// Private Copy constructor: NO COPY ALLOWED
Algorithm(const Algorithm&);
Expand All @@ -359,11 +344,12 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManag
void unlockWorkspaces();

void store();
void fillHistory();

void logAlgorithmInfo() const;

bool executeAsyncImpl(const Poco::Void & i);
/// Copy workspace history for input workspaces to output workspaces and record the history for ths algorithm
void fillHistory();

// --------------------- Private Members -----------------------------------
/// Poco::ActiveMethod used to implement asynchronous execution.
Expand All @@ -386,9 +372,6 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManag
mutable double m_startChildProgress; ///< Keeps value for algorithm's progress at start of an Child Algorithm
mutable double m_endChildProgress; ///< Keeps value for algorithm's progress at Child Algorithm's finish
AlgorithmID m_algorithmID; ///< Algorithm ID for managed algorithms
std::string m_OptionalMessage; ///< An optional message string to be displayed in the GUI.
std::string m_WikiSummary; ///< A summary line for the wiki page.
std::string m_WikiDescription; ///< Description in the wiki page.
std::vector<boost::weak_ptr<IAlgorithm>> m_ChildAlgorithms; ///< A list of weak pointers to any child algorithms created

/// Vector of all the workspaces that have been read-locked
Expand All @@ -411,8 +394,6 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManag
size_t m_groupSize;
/// All the groups have similar names (group_1, group_2 etc.)
bool m_groupsHaveSimilarNames;
/// Pointer to the parent history object (if set)
boost::shared_ptr<AlgorithmHistory> m_parentHistory;
/// A non-recursive mutex for thread-safety
mutable Kernel::Mutex m_mutex;
};
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmFactory.h
Expand Up @@ -125,6 +125,9 @@ class MANTID_API_DLL AlgorithmFactoryImpl : public Kernel::DynamicFactory<Algori
/// Get the algorithm names and version - mangled use decodeName to separate
const std::vector<std::string> getKeys() const;
const std::vector<std::string> getKeys(bool includeHidden) const;

/// Returns the highest version of the algorithm currently registered
int highestVersion(const std::string & algorithmName) const;

///Get the algorithm categories
const std::set<std::string> getCategories(bool includeHidden=false) const;
Expand Down
5 changes: 4 additions & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmHistory.h
Expand Up @@ -7,6 +7,7 @@
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/PropertyHistory.h"
#include "MantidKernel/DateAndTime.h"
#include <nexus/NeXusFile.hpp>

#include <boost/bind.hpp>
#include <boost/function.hpp>
Expand Down Expand Up @@ -120,12 +121,14 @@ class MANTID_API_DLL AlgorithmHistory
boost::shared_ptr<IAlgorithm> createAlgorithm() const;
/// Create an child algorithm from a history record at a given index
boost::shared_ptr<IAlgorithm> getChildAlgorithm(const size_t index) const;
/// Write this history object to a nexus file
void saveNexus(::NeXus::File* file, int& algCount) const;
// Allow Algorithm::execute to change the exec count & duration after the algorithm was executed
friend class Algorithm;

private:
// Set the execution count
void setExecCount(std::size_t execCount) { m_execCount = execCount; }
private:
/// The name of the Algorithm
std::string m_name;
/// The version of the algorithm
Expand Down
13 changes: 3 additions & 10 deletions Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h
Expand Up @@ -81,14 +81,12 @@ namespace Mantid
const std::string categorySeparator() const {return m_categorySeparator;}
/// Aliases to the algorithm
const std::string alias() const {return m_alias;}
/// function returns a summary message that will be displayed in the default GUI, and in the help.
const std::string summary() const {return m_summary;}

/// The algorithmID
AlgorithmID getAlgorithmID() const;

virtual const std::string getOptionalMessage() const { return m_OptionalMessage; }
virtual const std::string getWikiSummary() const { return m_WikiSummary; }
virtual const std::string getWikiDescription() const { return m_WikiDescription; }

void initialize();
std::map<std::string, std::string> validateInputs();
bool execute();
Expand Down Expand Up @@ -145,9 +143,6 @@ namespace Mantid
virtual std::string toString() const;
//@}

/// Set the wiki summary.
virtual void setWikiSummary(const std::string wikiSummary){m_WikiSummary = wikiSummary;}

private:
/// Private Copy constructor: NO COPY ALLOWED
AlgorithmProxy(const AlgorithmProxy&);
Expand All @@ -169,9 +164,7 @@ namespace Mantid
const std::string m_category; ///< category of the real algorithm
const std::string m_categorySeparator; ///< category seperator of the real algorithm
const std::string m_alias; ///< alias to the algorithm
std::string m_OptionalMessage; ///<Message to display in GUI
std::string m_WikiSummary; ///< A summary line for the wiki page.
std::string m_WikiDescription; ///< Description in the wiki page.
const std::string m_summary; ///<Message to display in GUI and help.
const int m_version; ///< version of the real algorithm

mutable boost::shared_ptr<Algorithm> m_alg; ///< Shared pointer to a real algorithm. Created on demand
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h
Expand Up @@ -73,6 +73,8 @@ namespace API

/// Replaces current parameter map with copy of given map
void replaceInstrumentParameters(const Geometry::ParameterMap & pmap);
/// exchange contents of current parameter map with contents of other map)
void swapInstrumentParameters(Geometry::ParameterMap & pmap);

/// Cache a lookup of grouped detIDs to member IDs
void cacheDetectorGroupings(const det2group_map & mapping);
Expand Down
14 changes: 3 additions & 11 deletions Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h
Expand Up @@ -64,6 +64,9 @@ class MANTID_API_DLL IAlgorithm : virtual public Kernel::IPropertyManager

/// function to return a version of the algorithm, must be overridden in all algorithms
virtual int version() const = 0;

/// function returns a summary message that will be displayed in the default GUI, and in the help.
virtual const std::string summary() const = 0;

/// function to return a category of the algorithm.
virtual const std::string category() const = 0;
Expand All @@ -90,15 +93,6 @@ class MANTID_API_DLL IAlgorithm : virtual public Kernel::IPropertyManager
/// Algorithm ID. Unmanaged algorithms return 0 (or NULL?) values. Managed ones have non-zero.
virtual AlgorithmID getAlgorithmID()const = 0;

/// function returns an optional message that will be displayed in the default GUI, at the top.
virtual const std::string getOptionalMessage() const = 0;

/// Get a summary to be used in the wiki page.
virtual const std::string getWikiSummary() const = 0;

/// Get a description to be used in the wiki page.
virtual const std::string getWikiDescription() const = 0;

/** Initialization method invoked by the framework. This method is responsible
* for any bookkeeping of initialization required by the framework itself.
* It will in turn invoke the init() method of the derived algorithm,
Expand Down Expand Up @@ -168,8 +162,6 @@ class MANTID_API_DLL IAlgorithm : virtual public Kernel::IPropertyManager
virtual void setChildEndProgress(const double endProgress)const = 0;
/// Serialize an algorithm
virtual std::string toString() const = 0;
/// Set the wiki summary.
virtual void setWikiSummary(const std::string WikiSummary) = 0;
};

typedef boost::shared_ptr<IAlgorithm> IAlgorithm_sptr;
Expand Down
2 changes: 0 additions & 2 deletions Code/Mantid/Framework/API/inc/MantidAPI/ISpectrum.h
Expand Up @@ -46,8 +46,6 @@ namespace API
*/
class DLLExport ISpectrum
{
friend class ManagedDataBlock2D;

public:
ISpectrum();
ISpectrum(const specid_t specNo);
Expand Down
2 changes: 0 additions & 2 deletions Code/Mantid/Framework/API/inc/MantidAPI/MemoryManager.h
Expand Up @@ -53,8 +53,6 @@ namespace Mantid
public:
/// Returns available physical memory in the system in KB.
MemoryInfo getMemoryInfo();
/// Returns true if there is not sufficient memory for a full Workspace2D.
bool goForManagedWorkspace(std::size_t NVectors,std::size_t XLength,std::size_t YLength, bool* isCompressedOK = NULL);
/// Release memory back to the system if we linked againsed tcmalloc
void releaseFreeMemory();
/// Release memory back to the system if we linked againsed tcmalloc and are above this much use
Expand Down
Expand Up @@ -72,7 +72,9 @@ class MANTID_API_DLL MultiDomainFunction : public CompositeFunction
/// Get domain indices for a member function
void getDomainIndices(size_t i, size_t nDomains, std::vector<size_t>& domains)const;

/// Returns the number of attributes associated with the function
/// Returns the number of "local" attributes associated with the function.
/// Local attributes are attributes of MultiDomainFunction but describe properties
/// of individual member functions.
virtual size_t nLocalAttributes()const {return 1;}
/// Returns a list of attribute names
virtual std::vector<std::string> getLocalAttributeNames()const {return std::vector<std::string>(1,"domains");}
Expand Down
9 changes: 8 additions & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceHistory.h
Expand Up @@ -82,14 +82,21 @@ class MANTID_API_DLL WorkspaceHistory
/// Pretty print the entire history
void printSelf(std::ostream&, const int indent = 0) const;

/// Save the workspace history to a nexus file
void saveNexus(::NeXus::File * file) const;
/// Load the workspace history from a nexus file
void loadNexus(::NeXus::File * file);


private:
/// Private, unimplemented copy assignment operator
WorkspaceHistory& operator=(const WorkspaceHistory& );

/// Recursive function to load the algorithm history tree from file
void loadNestedHistory(::NeXus::File * file, AlgorithmHistory_sptr parent = boost::shared_ptr<AlgorithmHistory>());
/// Parse an algorithm history string loaded from file
AlgorithmHistory_sptr parseAlgorithmHistory(const std::string& rawData);
/// Find the history entries at this level in the file.
std::set<int> findHistoryEntries(::NeXus::File* file);
/// The environment of the workspace
const Kernel::EnvironmentHistory m_environment;
/// The algorithms which have been called on the workspace
Expand Down
Expand Up @@ -345,7 +345,7 @@ namespace Mantid
virtual const Kernel::PropertyHistory createHistory() const
{
std::string wsName = m_workspaceName;
if (wsName.empty())
if (wsName.empty() && this->operator()())
{
//give the property a temporary name in the history
std::ostringstream os;
Expand Down
3 changes: 0 additions & 3 deletions Code/Mantid/Framework/API/src/Algorithm.cpp
Expand Up @@ -320,9 +320,6 @@ namespace Mantid
getLogger().fatal("UNKNOWN Exception is caught in initialize()");
throw;
}

// Set the documentation. This virtual method is overridden by (nearly) all algorithms and gives documentation summary.
initDocs();
}

//---------------------------------------------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions Code/Mantid/Framework/API/src/AlgorithmFactory.cpp
Expand Up @@ -227,6 +227,21 @@ namespace Mantid
}
}

/**
* @param algorithmName The name of an algorithm registered with the factory
* @return An integer corresponding to the highest version registered
* @throw std::invalid_argument if the algorithm cannot be found
*/
int AlgorithmFactoryImpl::highestVersion(const std::string &algorithmName) const
{
VersionMap::const_iterator viter = m_vmap.find(algorithmName);
if(viter != m_vmap.end()) return viter->second;
else
{
throw std::invalid_argument("AlgorithmFactory::highestVersion() - Unknown algorithm '" + algorithmName + "'");
}
}

/**
* Return the categories of the algorithms. This includes those within the Factory itself and
* any cleanly constructed algorithms stored here.
Expand Down

0 comments on commit ccefe54

Please sign in to comment.