Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/pointer_vector.cpp @ 29

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

updated boost from 1_33_1 to 1_34_1

File size: 1.1 KB
Line 
1// Copyright Joel de Guzman 2005-2006. Distributed under the Boost
2// Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4#include <boost/python.hpp>
5#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
6#include <vector>
7
8using namespace boost::python;
9
10class Abstract
11{
12public:   
13    virtual std::string    f() =0;
14};
15
16class Concrete1 : public Abstract
17{
18public:   
19    virtual std::string    f()    { return "harru"; }
20};
21
22typedef std::vector<Abstract*>   ListOfObjects;
23
24class DoesSomething
25{
26public:
27    DoesSomething()    {}
28   
29    ListOfObjects   returnList()   
30    {
31        ListOfObjects lst; 
32        lst.push_back(new Concrete1()); return lst; 
33    }
34};
35
36BOOST_PYTHON_MODULE(pointer_vector_ext)
37{       
38class_<Abstract, boost::noncopyable>("Abstract", no_init)
39    .def("f", &Abstract::f)
40    ;
41
42class_<ListOfObjects>("ListOfObjects")
43   .def( vector_indexing_suite<ListOfObjects>() ) 
44    ;
45
46class_<DoesSomething>("DoesSomething")
47    .def("returnList", &DoesSomething::returnList)
48    ;
49}
50
51
Note: See TracBrowser for help on using the repository browser.