Skip to content

Commit

Permalink
Remove the SharedPtrToPython macro.
Browse files Browse the repository at this point in the history
It's unnecessary now as a direct boost::python call is clearer.
Refs #8996
  • Loading branch information
martyngigg committed Feb 13, 2014
1 parent 284788c commit 9469062
Show file tree
Hide file tree
Showing 32 changed files with 113 additions and 213 deletions.

This file was deleted.

Expand Up @@ -4,20 +4,15 @@
#include "MantidAPI/AlgorithmProxy.h"
#include "MantidAPI/Algorithm.h"

#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"

#include <boost/python/class.hpp>
#include <boost/python/register_ptr_to_python.hpp>


using Mantid::API::IAlgorithm;
using Mantid::API::Algorithm;
using Mantid::API::AlgorithmProxy;

using namespace Mantid::API;
using namespace boost::python;

void export_algorithm()
{
REGISTER_SHARED_PTR_TO_PYTHON(Algorithm);
register_ptr_to_python<boost::shared_ptr<Algorithm>>();

class_<Algorithm, bases<IAlgorithm>, boost::noncopyable>("Algorithm", "Base-class for C algorithms", no_init)
.def("fromString", &Algorithm::fromString, "Initialize the algorithm from a string representation")
Expand All @@ -31,7 +26,7 @@ void export_algorithm()


//---------------------------- AlgorithmProxy ----------------------------------
REGISTER_SHARED_PTR_TO_PYTHON(AlgorithmProxy);
register_ptr_to_python<boost::shared_ptr<AlgorithmProxy>>();

class_<AlgorithmProxy, bases<IAlgorithm>, boost::noncopyable>("AlgorithmProxy", "Proxy class returned by managed algorithms", no_init);
}
Expand Down
@@ -1,7 +1,6 @@
#include "MantidAPI/AnalysisDataService.h"
#include "MantidKernel/DataItem.h"

#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/Policies/DowncastingPolicies.h"

#include <boost/python/class.hpp>
Expand Down
@@ -1,17 +1,15 @@
#include "MantidAPI/BoxController.h"

#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"

#include <boost/python/class.hpp>
#include <boost/python/copy_const_reference.hpp>
#include <boost/python/register_ptr_to_python.hpp>

using Mantid::API::BoxController;
using Mantid::API::BoxController_sptr;
using namespace boost::python;

void export_BoxController()
{
REGISTER_SHARED_PTR_TO_PYTHON(BoxController);
register_ptr_to_python<boost::shared_ptr<BoxController>>();

class_< BoxController, boost::noncopyable >("BoxController", no_init)
.def("getNDims", &BoxController::getNDims, "Get # of dimensions")
Expand Down
@@ -1,13 +1,12 @@
#include "MantidGeometry/IDTypes.h"
#include "MantidAPI/ExperimentInfo.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/Policies/RemoveConst.h"
#include <boost/python/class.hpp>
#include <boost/python/copy_const_reference.hpp>
#include <boost/python/overloads.hpp>
#include <boost/python/register_ptr_to_python.hpp>

using Mantid::API::ExperimentInfo;
using Mantid::API::ExperimentInfo_sptr;
using Mantid::PythonInterface::Policies::RemoveConstSharedPtr;
using namespace boost::python;

Expand All @@ -16,7 +15,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS(getInstrumentFilename_Overload, ExperimentInfo::

void export_ExperimentInfo()
{
REGISTER_SHARED_PTR_TO_PYTHON(ExperimentInfo);
register_ptr_to_python<boost::shared_ptr<ExperimentInfo>>();

class_<ExperimentInfo, boost::noncopyable>("ExperimentInfo", no_init)
.def("getInstrument", &ExperimentInfo::getInstrument, return_value_policy<RemoveConstSharedPtr>(),
Expand Down
Expand Up @@ -6,14 +6,14 @@
#pragma warning( default: 4250 )
#endif
#include "MantidKernel/Strings.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/Policies/VectorToNumpy.h"

#include <Poco/Thread.h>

#include <boost/python/object.hpp>
#include <boost/python/bases.hpp>
#include <boost/python/class.hpp>
#include <boost/python/object.hpp>
#include <boost/python/register_ptr_to_python.hpp>

using Mantid::Kernel::IPropertyManager;
using Mantid::Kernel::Property;
Expand Down Expand Up @@ -213,7 +213,7 @@ namespace

void export_ialgorithm()
{
REGISTER_SHARED_PTR_TO_PYTHON(IAlgorithm);
register_ptr_to_python<boost::shared_ptr<IAlgorithm>>();

class_<IAlgorithm, bases<IPropertyManager>, boost::noncopyable>("IAlgorithm", "Interface for all algorithms", no_init)
.def("name", &IAlgorithm::name, "Returns the name of the algorithm")
Expand Down
@@ -1,17 +1,14 @@
#include "MantidAPI/IEventWorkspace.h"
#include "MantidAPI/IEventList.h"
#include "MantidAPI/WorkspaceProperty.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/Registry/RegisterSingleValueHandler.h"
#include "MantidPythonInterface/kernel/PropertyWithValue.h"

#include <boost/python/class.hpp>
#include <boost/python/object.hpp>
#include <boost/python/register_ptr_to_python.hpp>

using Mantid::API::IEventWorkspace;
using Mantid::API::IEventWorkspace_sptr;
using Mantid::API::IEventList;
using Mantid::API::WorkspaceProperty;
using Mantid::API::IWorkspaceProperty;
using namespace Mantid::API;
using Mantid::Kernel::PropertyWithValue;
using namespace boost::python;

Expand All @@ -20,7 +17,7 @@ using namespace boost::python;
*/
void export_IEventWorkspace()
{
REGISTER_SHARED_PTR_TO_PYTHON(IEventWorkspace);
register_ptr_to_python<boost::shared_ptr<IEventWorkspace>>();

class_<IEventWorkspace, bases<Mantid::API::MatrixWorkspace>, boost::noncopyable>("IEventWorkspace", no_init)
.def("getNumberEvents", &IEventWorkspace::getNumberEvents, args("self"),
Expand Down
@@ -1,9 +1,9 @@
#include "MantidPythonInterface/api/FitFunctions/IFunctionAdapter.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"

#include <boost/python/class.hpp>
#include <boost/python/def.hpp>
#include <boost/python/overloads.hpp>
#include <boost/python/register_ptr_to_python.hpp>

using Mantid::API::IFunction;
using Mantid::PythonInterface::IFunctionAdapter;
Expand Down Expand Up @@ -47,7 +47,7 @@ namespace
void export_IFunction()
{

REGISTER_SHARED_PTR_TO_PYTHON(IFunction);
register_ptr_to_python<boost::shared_ptr<IFunction>>();

class_<IFunction, IFunctionAdapter, boost::noncopyable>("IFunction", "Base class for all functions", no_init)
.def("name", &IFunction::name, "Return the name of the function")
Expand Down
@@ -1,19 +1,15 @@
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"

#include "MantidPythonInterface/kernel/Registry/RegisterSingleValueHandler.h"
#include <boost/python/class.hpp>
#include <boost/python/register_ptr_to_python.hpp>

using Mantid::API::IMDEventWorkspace;
using Mantid::API::IMDEventWorkspace_sptr;
using Mantid::API::BoxController_sptr;
using Mantid::API::IMDWorkspace;
using Mantid::API::MultipleExperimentInfos;
using Mantid::Kernel::DataItem_sptr;
using namespace Mantid::API;
using namespace boost::python;

void export_IMDEventWorkspace()
{
REGISTER_SHARED_PTR_TO_PYTHON(IMDEventWorkspace);
register_ptr_to_python<boost::shared_ptr<IMDEventWorkspace>>();

// MDEventWorkspace class
class_< IMDEventWorkspace, bases<IMDWorkspace, MultipleExperimentInfos>, boost::noncopyable >("IMDEventWorkspace", no_init)
Expand Down
@@ -1,17 +1,14 @@
#include "MantidAPI/IMDHistoWorkspace.h"
#include "MantidPythonInterface/kernel/Converters/CArrayToNDArray.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/Registry/RegisterSingleValueHandler.h"

#include <boost/python/class.hpp>
#include <boost/python/copy_non_const_reference.hpp>
#include <boost/python/numeric.hpp>
#include <boost/python/register_ptr_to_python.hpp>

using Mantid::API::IMDHistoWorkspace;
using Mantid::API::IMDHistoWorkspace_sptr;
using Mantid::API::IMDWorkspace;
using Mantid::API::MultipleExperimentInfos;
using Mantid::Kernel::DataItem_sptr;

using namespace Mantid::API;
namespace Converters = Mantid::PythonInterface::Converters;

using namespace boost::python;
Expand Down Expand Up @@ -146,7 +143,7 @@ namespace

void export_IMDHistoWorkspace()
{
REGISTER_SHARED_PTR_TO_PYTHON(IMDHistoWorkspace);
register_ptr_to_python<boost::shared_ptr<IMDHistoWorkspace>>();

// EventWorkspace class
class_< IMDHistoWorkspace, bases<IMDWorkspace,MultipleExperimentInfos>, boost::noncopyable >("IMDHistoWorkspace", no_init)
Expand Down
@@ -1,14 +1,11 @@
#include "MantidAPI/IMDWorkspace.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/Registry/RegisterSingleValueHandler.h"
#include <boost/python/class.hpp>
#include <boost/python/self.hpp>
#include <boost/python/enum.hpp>
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/python/self.hpp>

using Mantid::API::IMDWorkspace;
using Mantid::API::IMDWorkspace_sptr;
using Mantid::API::MDGeometry;
using Mantid::API::Workspace;
using namespace Mantid::API;
using namespace boost::python;

void export_IMDWorkspace()
Expand All @@ -18,7 +15,7 @@ void export_IMDWorkspace()
.value("VolumeNormalization", Mantid::API::VolumeNormalization)
.value("NumEventsNormalization", Mantid::API::NumEventsNormalization);

REGISTER_SHARED_PTR_TO_PYTHON(IMDWorkspace);
register_ptr_to_python<boost::shared_ptr<IMDWorkspace>>();

// EventWorkspace class
class_< IMDWorkspace, bases<Workspace, MDGeometry>, boost::noncopyable >("IMDWorkspace", no_init)
Expand Down
@@ -1,21 +1,16 @@
#include "MantidAPI/IPeaksWorkspace.h"
#include "MantidAPI/IPeak.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/Registry/RegisterSingleValueHandler.h"
#include <boost/python/class.hpp>
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/python/return_internal_reference.hpp>

using Mantid::API::IPeaksWorkspace;
using Mantid::API::IPeaksWorkspace_sptr;
using Mantid::API::IPeak;
using Mantid::API::ExperimentInfo;
using Mantid::API::ITableWorkspace;
using Mantid::Kernel::DataItem_sptr;
using namespace Mantid::API;
using namespace boost::python;

void export_IPeaksWorkspace()
{
REGISTER_SHARED_PTR_TO_PYTHON(IPeaksWorkspace);
register_ptr_to_python<boost::shared_ptr<IPeaksWorkspace>>();

// IPeaksWorkspace class
class_< IPeaksWorkspace, bases<ITableWorkspace, ExperimentInfo>, boost::noncopyable >("IPeaksWorkspace", no_init)
Expand Down
@@ -1,17 +1,15 @@
#include "MantidAPI/ISplittersWorkspace.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/Registry/RegisterSingleValueHandler.h"
#include <boost/python/class.hpp>
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/python/return_internal_reference.hpp>

using Mantid::API::ISplittersWorkspace;
using Mantid::API::ITableWorkspace;
using Mantid::Kernel::DataItem_sptr;
using namespace Mantid::API;
using namespace boost::python;

void export_IPeaksWorkspace()
{
REGISTER_SHARED_PTR_TO_PYTHON(ISplittersWorkspace);
register_ptr_to_python<boost::shared_ptr<ISplittersWorkspace>>();

// ISplittersWorkspace class
class_< ISplittersWorkspace, bases<ITableWorkspace>, boost::noncopyable >("ISplittersWorkspace", no_init)
Expand Down
Expand Up @@ -5,14 +5,14 @@
#include "MantidPythonInterface/kernel/Converters/NDArrayToVector.h"
#include "MantidPythonInterface/kernel/Converters/PySequenceToVector.h"
#include "MantidPythonInterface/kernel/Converters/CloneToNumpy.h"
#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/Registry/RegisterSingleValueHandler.h"
#include "MantidPythonInterface/kernel/PropertyWithValue.h"

#include <boost/python/class.hpp>
#include <boost/python/list.hpp>
#include <boost/python/dict.hpp>
#include <boost/python/converter/builtin_converters.hpp>
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/preprocessor/list/for_each.hpp>
#include <boost/preprocessor/tuple/to_list.hpp>
#include <vector>
Expand All @@ -22,13 +22,7 @@
#define NO_IMPORT_ARRAY
#include <numpy/arrayobject.h>

using Mantid::API::ITableWorkspace;
using Mantid::API::ITableWorkspace_sptr;
using Mantid::API::TableRow;
using Mantid::API::Column_sptr;
using Mantid::API::Column_const_sptr;
using Mantid::API::Workspace;
using Mantid::Kernel::DataItem_sptr;
using namespace Mantid::API;
using namespace boost::python;

namespace
Expand Down Expand Up @@ -348,7 +342,7 @@ namespace

void export_ITableWorkspace()
{
REGISTER_SHARED_PTR_TO_PYTHON(ITableWorkspace);
register_ptr_to_python<boost::shared_ptr<ITableWorkspace>>();
std::string iTableWorkspace_docstring = "Most of the information from a table workspace is returned ";
iTableWorkspace_docstring += "as native copies. All of the column accessors return lists while the ";
iTableWorkspace_docstring += "rows return dicts. This object does support the idom 'for row in ";
Expand Down
@@ -1,18 +1,17 @@
#include "MantidAPI/PropertyManagerDataService.h"
#include "MantidKernel/PropertyManager.h"

#include "MantidPythonInterface/kernel/SharedPtrToPythonMacro.h"
#include "MantidPythonInterface/kernel/WeakPtr.h"

#include <boost/python/class.hpp>
#include <boost/python/def.hpp>
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/python/return_value_policy.hpp>
#include <boost/python/reference_existing_object.hpp>
#include <boost/python/list.hpp>

using Mantid::API::PropertyManagerDataServiceImpl;
using Mantid::API::PropertyManagerDataService;
using Mantid::Kernel::PropertyManager;
using namespace Mantid::API;
using namespace Mantid::Kernel;
using namespace boost::python;

/// Weak pointer to DataItem typedef
Expand Down

0 comments on commit 9469062

Please sign in to comment.