Ticket #12168: TestShared.cpp

File TestShared.cpp, 782 bytes (added by Praveen <praveenkumar076@…>, 6 years ago)

C++ File

Line 
1#include <vector>
2
3struct A
4{
5 int data;
6 virtual int f() { return 0; }
7 ~A()
8 {
9 std::cout << "Destructed" << endl;
10 }
11};
12std::vector<boost::shared_ptr<A>> test3;
13std::vector<boost::shared_ptr<A>> test4;
14
15void TestWriteDisk(boost::shared_ptr<A> readDIsk)
16{
17
18 test3.push_back(readDIsk);
19 test4.push_back(readDIsk);
20}
21void CLearWrite()
22{
23 test3.clear();
24}
25BOOST_PYTHON_MODULE(PyWrap)
26{
27
28 class_<A, boost::shared_ptr<A> >("A")
29 .def("f", &A::f)
30 ;
31 boost::python::def("TestWriteDisk", TestWriteDisk, "");
32 boost::python::def("ClearWrite", CLearWrite, "");
33}
34
35
36// PYTHON FILE
37// import NVMeCMDWrapper as PyWrap
38// PyWrap.TestWriteDisk(PyWrap.A())
39// PyWrap.ClearWrite()