Boost logo

Boost Users :

From: Anand, Kumar (kanand_at_[hidden])
Date: 2006-05-17 13:29:54


A class has static method to create and a static method to destroy. And
the constructors and destructor of the class is marked as private. How
do I expose such a class in Python?


class A {
             static A* instance;
         A() { };
              ~A {};
           static A* create ()
     If(instance != 0)
                          instance = new A();
                     return instance;
            static void destroy()
                 delete instance;
                  instance = 0;

In Boost Python, I tried the following but the code doesn't compile
unless I make the destructor of class A as public.

namespace bp = boost::python;

bp::class_<A> ("A", bp::no_init)
       .def("create", &A::create)
       .def("destroy", &A::destroy)

Any suggestions?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at