Newer
Older
Peterson, Peter
committed
#include "MantidAPI/ITableWorkspace.h"
Roman Tolchenov
committed
#include "MantidAPI/AnalysisDataService.h"
Peterson, Peter
committed
#include "MantidKernel/Logger.h"
#include "MantidKernel/IPropertyManager.h"
Roman Tolchenov
committed
namespace Mantid
{
namespace API
{
// Get a reference to the logger
Kernel::Logger& ITableWorkspace::g_log = Kernel::Logger::get("ITableWorkspace");
Peterson, Peter
committed
Roman Tolchenov
committed
void ITableWorkspace::modified()
{
if (!AnalysisDataService::Instance().doesExist(this->getName())) return;
Workspace_sptr ws = AnalysisDataService::Instance().retrieve(this->getName());
if (!ws) return;
ITableWorkspace_sptr tws = boost::dynamic_pointer_cast<ITableWorkspace>(ws);
if (!tws) return;
AnalysisDataService::Instance().notificationCenter.postNotification(
new Kernel::DataService<API::Workspace>::AfterReplaceNotification(this->getName(),tws));
}
/** Overridable method to custom-sort the workspace
*
* @param criteria : a vector with a list of pairs: column name, bool;
* where bool = true for ascending, false for descending sort.
* The peaks are sorted by the first criterion first, then the 2nd if equal, etc.
* @throw std::runtime_error unless overridden
*/
void ITableWorkspace::sort(std::vector< std::pair<std::string, bool> > & criteria)
{
UNUSED_ARG(criteria);
throw std::runtime_error("This type of ITableWorkspace (" + this->id() + ") has not implemented sort() yet customSort() returns true. Please contact the developers.");
}
} // namespace API
Peterson, Peter
committed
} // Namespace Mantid
///\cond TEMPLATE
namespace Mantid
{
namespace Kernel
{
Gigg, Martyn Anthony
committed
template<> MANTID_API_DLL
Peterson, Peter
committed
API::ITableWorkspace_sptr IPropertyManager::getValue<API::ITableWorkspace_sptr>(const std::string &name) const
{
PropertyWithValue<API::ITableWorkspace_sptr>* prop =
dynamic_cast<PropertyWithValue<API::ITableWorkspace_sptr>*>(getPointerToProperty(name));
if (prop)
{
return *prop;
}
else
{
std::string message = "Attempt to assign property "+ name +" to incorrect type (ITableWorkspace)";
throw std::runtime_error(message);
}
}
} // namespace Kernel
} // namespace Mantid
Roman Tolchenov
committed
Peterson, Peter
committed
///\endcond TEMPLATE