Skip to content

Commit

Permalink
[SWIG] sort-out factory for get_prior
Browse files Browse the repository at this point in the history
tell SWIG about the prior hierarchy such that get_prior() returns instances of the actual prior (not just the base class)
  • Loading branch information
KrisThielemans committed Oct 18, 2020
1 parent 9c72b9e commit c6fbe6f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/swig/stir.i
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@
#endif

%include "attribute.i"
%include "factory.i"

%init %{
#if defined(SWIGPYTHON)
Expand Down Expand Up @@ -1575,14 +1576,24 @@ namespace stir {
%shared_ptr(stir::FBP2DReconstruction);
%shared_ptr(stir::FBP3DRPReconstruction);

// tell SWIG to convert the return of get_prior_ptr etc to the appropriate object
/* This currently fails, so is still commented out
%newobject *::get_objective_function;
%factory(
stir::GeneralisedObjectiveFunction<TargetT >& stir::IterativeReconstruction<TargetT >::get_objective_function,
%arg(stir::PoissonLogLikelihoodWithLinearModelForMeanAndProjData<TargetT >));
*/
%newobject *::get_prior_ptr;
%factory(stir::GeneralisedPrior<TargetT> *stir::GeneralisedObjectiveFunction< TargetT >::get_prior_ptr,
stir::QuadraticPrior<elemT>,
stir::PLSPrior<elemT>,
stir::RelativeDifferencePrior<elemT>);

#undef TargetT
#undef elemT
#endif

%newobject *::get_prior_ptr;
%factory(stir::GeneralisedPrior *stir::GeneralisedObjectiveFunction::get_prior_ptr, stir::QuadraticPrior, stir::PLSPrior, stir::RelativeDifferencePrior);
//%factory(stir::GeneralisedPrior<TargetT> *stir::GeneralisedObjectiveFunction< TargetT >::get_prior_ptr, stir::QuadraticPrior<elemT>, stir::PLSPrior<elemT>, stir::RelativeDifferencePrior<elemT>);

%include "stir/recon_buildblock/GeneralisedObjectiveFunction.h"
%include "stir/recon_buildblock/GeneralisedObjectiveFunction.h"
%include "stir/recon_buildblock/PoissonLogLikelihoodWithLinearModelForMean.h"
Expand Down

0 comments on commit c6fbe6f

Please sign in to comment.