Skip to content

Commit

Permalink
Remove all of the Python downcasting framework
Browse files Browse the repository at this point in the history
This should now happen behind the scenes in Boost Python.
Refs #9801
  • Loading branch information
martyngigg committed May 29, 2015
1 parent fe90068 commit f25b7d0
Show file tree
Hide file tree
Showing 27 changed files with 412 additions and 789 deletions.
@@ -0,0 +1,43 @@
#ifndef MANTID_PYTHONINTERFACE_EXTRACTWORKSPACE_H_
#define MANTID_PYTHONINTERFACE_EXTRACTWORKSPACE_H_
/**
Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
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>
*/
#include <MantidAPI/Workspace.h>

#include <boost/python/object_fwd.hpp>

namespace Mantid {
namespace PythonInterface {

struct ExtractWorkspace {
ExtractWorkspace(const boost::python::object &pyvalue);
bool check() const;
const API::Workspace_sptr operator()() const;

private:
API::Workspace_sptr m_value;
};
}
}

#endif // MANTID_PYTHONINTERFACE_EXTRACTWORKSPACE_H_

This file was deleted.

Expand Up @@ -25,31 +25,30 @@
*/

#include "MantidKernel/PropertyWithValue.h"
#include "MantidPythonInterface/kernel/Policies/DowncastingPolicies.h"

#ifndef Q_MOC_RUN
#include <boost/python/class.hpp>
#include <boost/python/bases.hpp>
#include <boost/python/return_value_policy.hpp>
#include <boost/python/return_by_value.hpp>
#endif

namespace Mantid {
namespace PythonInterface {
/**
* A helper struct to export PropertyWithValue<> types to Python.
*/
template <typename HeldType> struct PropertyWithValueExporter {
template <typename HeldType, typename ValueReturnPolicy=boost::python::return_by_value>
struct PropertyWithValueExporter {
static void define(const char *pythonClassName) {
using namespace boost::python;
using namespace Mantid::Kernel;

class_<PropertyWithValue<HeldType>, bases<Property>, boost::noncopyable>(
pythonClassName, no_init)
.add_property(
"value",
make_function(
&PropertyWithValue<HeldType>::operator(),
return_value_policy<Policies::ToSharedPtrWithDowncast>()));
.add_property("value",
make_function(&PropertyWithValue<HeldType>::operator(),
return_value_policy<ValueReturnPolicy>()));
}
};
}
Expand Down

This file was deleted.

0 comments on commit f25b7d0

Please sign in to comment.