Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/python/test/pointer_vector.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 899 bytes
Line 
1#include <boost/python.hpp>
2#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
3#include <vector>
4
5using namespace boost::python;
6
7class Abstract
8{
9public:   
10    virtual std::string    f() =0;
11};
12
13class Concrete1 : public Abstract
14{
15public:   
16    virtual std::string    f()    { return "harru"; }
17};
18
19typedef std::vector<Abstract*>   ListOfObjects;
20
21class DoesSomething
22{
23public:
24    DoesSomething()    {}
25   
26    ListOfObjects   returnList()   
27    {
28        ListOfObjects lst; 
29        lst.push_back(new Concrete1()); return lst; 
30    }
31};
32
33BOOST_PYTHON_MODULE(pointer_vector_ext)
34{       
35class_<Abstract, boost::noncopyable>("Abstract", no_init)
36    .def("f", &Abstract::f)
37    ;
38
39class_<ListOfObjects>("ListOfObjects")
40   .def( vector_indexing_suite<ListOfObjects>() ) 
41    ;
42
43class_<DoesSomething>("DoesSomething")
44    .def("returnList", &DoesSomething::returnList)
45    ;
46}
47
48
Note: See TracBrowser for help on using the repository browser.