[C++-sig] Iterators + shared_ptr + Abstract base classes + Pass by reference = help :)

David Sankel camio at yahoo.com
Sat Jan 4 00:55:14 CET 2003


Hello,
  I have several questions and I think they are all
most easily answered by example:

class Abstract
{
public:
  shared_ptr<Abstract> clone()=0;
};

class Filter
{
public:
  vector<shared_ptr<Abstract> >  Abstract data;
  void doFilter( vector<shared_ptr<Abstract> > &result
)=0;
};

How would I use boost.python to allow python code to
use Filter as a base class?

I figure there is going to be:

class PythonFilter : public Filter
{
public:
    void doFilter( vector<shared_ptr<Abstract> >
&result)
    {
       //What goes here?
    }
}

and:

BOOST_PYTHON_MODULE(embedded_Filter)
{
    class_< Abstract > ("Abstract", no_init );
    class_< Filter,
            PythonFilter >("Filter")
    //What goes here?
    ;

}

The python code to look something like this:

import ...
class SpecificFilter( Filter ):
  def doFilter( self, result )
     #make result some modification of self.data

Thanks beforehand for helping,

David J. Sankel
Head Consultant
Electron Consulting




More information about the Cplusplus-sig mailing list