- .h file :
template <typename ImageT, typename MaskT> class DifferenceImageFootprintInformation : public lsst::daf::base::Persistable, public lsst::daf::data::LsstBase { public: typedef boost::shared_ptr<DifferenceImageFootprintInformation<ImageT, MaskT> > Ptr; typedef std::vector<typename DifferenceImageFootprintInformation<ImageT, MaskT>::Ptr> DifiList; // constructor DifferenceImageFootprintInformation(lsst::detection::Footprint::PtrType footprintPtr, maskedImagePtrType imageToConvolvePtr, maskedImagePtrType imageToNotConvolvePtr); // get, set methods ... private: int _id; double _colcNorm; double _rowcNorm; lsst::detection::Footprint::PtrType _footprintPtr; maskedImagePtrType _imageToConvolvePtr; maskedImagePtrType _imageToNotConvolvePtr; boost::shared_ptr<lsst::afw::math::LinearCombinationKernel> _singleKernelPtr; double _singleKernelSum; double _singleBackground; DifferenceImageStatistics<ImageT, MaskT> _singleKernelStats; bool _isGood; };
- .cc file : constructor
template <typename ImageT, typename MaskT> lsst::ip::diffim::DifferenceImageFootprintInformation<ImageT, MaskT>::DifferenceImageFootprintInformation( lsst::detection::Footprint::PtrType footprintPtr, maskedImagePtrType imageToConvolvePtr, maskedImagePtrType imageToNotConvolvePtr ) : lsst::daf::data::LsstBase(typeid(this)), _id(-1), _colcNorm(0), _rowcNorm(0), _footprintPtr(footprintPtr), _imageToConvolvePtr(imageToConvolvePtr), _imageToNotConvolvePtr(imageToNotConvolvePtr), _singleKernelPtr(), _singleKernelSum(0), _singleBackground(0), _singleKernelStats(), _isGood(true) { }
- .cc file : Explicit instantiation
template class lsst::ip::diffim::DifferenceImageFootprintInformation<float, lsst::afw::image::maskPixelType>;
- .i file :
%template(DifferenceImageFootprintInformationF) lsst::ip::diffim::DifferenceImageFootprintInformation<float, lsst::afw::image::maskPixelType>;
Use of class; subroutine that accepts and returns a vector of pointers to class instances
- .h file :
THIS DID NOT WORK
template <typename ImageT, typename MaskT>
typename DifferenceImageFootprintInformation<ImageT, MaskT>::DifiList
getGoodFootprints( typename DifferenceImageFootprintInformation<ImageT,MaskT>::DifiList & difiList );
THIS DID
template <typename ImageT, typename MaskT>
typename DifferenceImageFootprintInformation<ImageT, MaskT>::DifiList
getGoodFootprints(std::vector<boost::shared_ptr<DifferenceImageFootprintInformation<ImageT, MaskT> > > & difiList );
- .cc file : implementation
THIS DID NOT WORK
template <typename ImageT, typename MaskT>
typename lsst::ip::diffim::DifferenceImageFootprintInformation<ImageT, MaskT>::DifiList
lsst::ip::diffim::getGoodFootprints(
typename DifferenceImageFootprintInformation<ImageT,MaskT>::DifiList & difiList
)
{
typename DifferenceImageFootprintInformation<ImageT,MaskT>::DifiList goodList;
for (typename DifferenceImageFootprintInformation<ImageT,MaskT>::DifiList::iterator i = difiList.begin();
i != difiList.end(); ++i) {
if ((*i)->getStatus() == true) {
goodList.push_back((*i));
}
}
return goodList;
}
THIS DID
template <typename ImageT, typename MaskT>
typename lsst::ip::diffim::DifferenceImageFootprintInformation<ImageT, MaskT>::DifiList
lsst::ip::diffim::getGoodFootprints(
std::vector<boost::shared_ptr<DifferenceImageFootprintInformation<ImageT, MaskT> > > &difiList
)
{
typename DifferenceImageFootprintInformation<ImageT,MaskT>::DifiList goodList;
for (typename DifferenceImageFootprintInformation<ImageT,MaskT>::DifiList::iterator i = difiList.begin();
i != difiList.end(); ++i) {
if ((*i)->getStatus() == true) {
goodList.push_back((*i));
}
}
return goodList;
}
- .cc file : explicit instantiation (note no typename!)
THIS DID NOT WORK
template
lsst::ip::diffim::DifferenceImageFootprintInformation<float, lsst::afw::image::maskPixelType>::DifiList
lsst::ip::diffim::getGoodFootprints(
lsst::ip::diffim::DifferenceImageFootprintInformation<float, lsst::afw::image::maskPixelType>::DifiList & difiList
);
FAILURE MODE BELOW
src/ImageSubtract.cc:781: error: template-id 'getGoodFootprints<>' for 'std::vector<boost::shared_ptr<lsst::ip::diffim::DifferenceImageFootprintInformation<float, short unsigned int> >, std::allocator<boost::shared_ptr<lsst::ip::diffim::DifferenceImageFootprintInformation<float, short unsigned int> > > > lsst::ip::diffim::getGoodFootprints(std::vector<boost::shared_ptr<lsst::ip::diffim::DifferenceImageFootprintInformation<float, short unsigned int> >, std::allocator<boost::shared_ptr<lsst::ip::diffim::DifferenceImageFootprintInformation<float, short unsigned int> > > >&)' does not match any template declaration
THIS DID
template
lsst::ip::diffim::DifferenceImageFootprintInformation<float, lsst::afw::image::maskPixelType>::DifiList
lsst::ip::diffim::getGoodFootprints(
std::vector<boost::shared_ptr<DifferenceImageFootprintInformation<float, lsst::afw::image::maskPixelType> > > &difiList
);
- .i file :
%boost_shared_ptr(DifiPtrF, lsst::ip::diffim::DifferenceImageFootprintInformation<float, lsst::afw::image::maskPixelType>); %boost_shared_ptr(DifiPtrD, lsst::ip::diffim::DifferenceImageFootprintInformation<double, lsst::afw::image::maskPixelType>); %template(DifiListF) std::vector<lsst::ip::diffim::DifferenceImageFootprintInformation<float, lsst::afw::image::maskPixelType>::PtrType>; %template(DifiListD) std::vector<lsst::ip::diffim::DifferenceImageFootprintInformation<double, lsst::afw::image::maskPixelType>::PtrType>; %template(getGoodFootprints) lsst::ip::diffim::getGoodFootprints<float, lsst::afw::image::maskPixelType>; %template(getGoodFootprints) lsst::ip::diffim::getGoodFootprints<double, lsst::afw::image::maskPixelType>;
Explicit Instatiation
If you get no compilation errors but get Python errors when you import the library
File "/lsst/becker/lsst_devel/DMS/t354/python/lsst/ip/diffim/diffimLib.py", line 13, in <module> import _diffimLib ImportError: /lsst/becker/lsst_devel/DMS/t354/python/lsst/ip/diffim/_diffimLib.so: undefined symbol: _ZN4lsst2ip6diffim17getGoodFootprintsIftEENS1_35DifferenceImageFootprintInformationIT_T0_E9difiListTERS7_
you forgot to explicitly instantiate something. You can figure out what is missing by saying
c++filt _ZN4lsst2ip6diffim17getGoodFootprintsIftEENS1_35DifferenceImageFootprintInformationIT_T0_E9difiListTERS7_ lsst::ip::diffim::DifferenceImageFootprintInformation<float, unsigned short>::difiListT lsst::ip::diffim::getGoodFootprints<float, unsigned short>(lsst::ip::diffim::DifferenceImageFootprintInformation<float, unsigned short>::difiListT&)
I think for every "template" in the .i file, you need explicit instantiation in the .cc file.
