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 | |
---|
8 | using namespace boost::python; |
---|
9 | |
---|
10 | class Abstract |
---|
11 | { |
---|
12 | public: |
---|
13 | virtual std::string f() =0; |
---|
14 | }; |
---|
15 | |
---|
16 | class Concrete1 : public Abstract |
---|
17 | { |
---|
18 | public: |
---|
19 | virtual std::string f() { return "harru"; } |
---|
20 | }; |
---|
21 | |
---|
22 | typedef std::vector<Abstract*> ListOfObjects; |
---|
23 | |
---|
24 | class DoesSomething |
---|
25 | { |
---|
26 | public: |
---|
27 | DoesSomething() {} |
---|
28 | |
---|
29 | ListOfObjects returnList() |
---|
30 | { |
---|
31 | ListOfObjects lst; |
---|
32 | lst.push_back(new Concrete1()); return lst; |
---|
33 | } |
---|
34 | }; |
---|
35 | |
---|
36 | BOOST_PYTHON_MODULE(pointer_vector_ext) |
---|
37 | { |
---|
38 | class_<Abstract, boost::noncopyable>("Abstract", no_init) |
---|
39 | .def("f", &Abstract::f) |
---|
40 | ; |
---|
41 | |
---|
42 | class_<ListOfObjects>("ListOfObjects") |
---|
43 | .def( vector_indexing_suite<ListOfObjects>() ) |
---|
44 | ; |
---|
45 | |
---|
46 | class_<DoesSomething>("DoesSomething") |
---|
47 | .def("returnList", &DoesSomething::returnList) |
---|
48 | ; |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
Note: See
TracBrowser
for help on using the repository browser.