I have a C++ class containing a (Poco) mutex:
class ClassWithMutex
{
public:
ClassWithMutex();
virtual ~ClassWithMutex();
Poco::Mutex mMyMutex;
private:
ClassWithMutex(const ClassWithMutex& );
ClassWithMutex& operator=(const ClassWithMutex& other);
};
And another class, using it:
class ClassHavingAClassWithMutex
{
public:
ClassHavingAClassWithMutex();
~ClassHavingAClassWithMutex();
ClassWithMutex A;
private:
ClassHavingAClassWithMutex(const ClassHavingAClassWithMutex&);
ClassHavingAClassWithMutex& ClassHavingAClassWithMutex::operator=(const ClassHavingAClassWithMutex& other);
};
When trying to create a wrapper for ClassHavingAClassWithMutex, I get an error:
Error C2248 'ClassWithMutex::operator =': cannot access private member declared in class 'ClassWithMutex' mvr C:\builds\vs2015\mvr\python_package\src\mvr\mvrPYTHON_wrap.cxx 6493
where the Swig generated code looks like this:
SWIGINTERN PyObject *_wrap_ClassWithMutex_mMyMutex_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
ClassWithMutex *arg1 = (ClassWithMutex *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject *swig_obj[1] ;
Poco::Mutex result;
if (!args) SWIG_fail;
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ClassWithMutex, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ClassWithMutex_mMyMutex_get" "', argument " "1"" of type '" "ClassWithMutex *""'");
}
arg1 = reinterpret_cast< ClassWithMutex * >(argp1);
{
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
result = ((arg1)->mMyMutex);
SWIG_PYTHON_THREAD_END_ALLOW;
}
resultobj = SWIG_NewPointerObj((new Poco::Mutex(static_cast< const Poco::Mutex& >(result))), SWIGTYPE_p_Poco__Mutex, SWIG_POINTER_OWN | 0 );
return resultobj;
fail:
return NULL;
}
and errors emitted from this line:
if (arg1) (arg1)->A = *arg2;
and
resultobj = SWIG_NewPointerObj((new Poco::Mutex(static_cast< const Poco::Mutex& >(result))), SWIGTYPE_p_Poco__Mutex, SWIG_POINTER_OWN | 0 );
Swig interface file:
%immutable
%include "aiClassWithMutex.h"
%include "ClassHavingAClassWithMutex.h"
%mutable
Any suggestions on how to properly wrap the classes above with Swig? I made the copy and assignment ctor's private in the classes above, in order to prevent any copying, but it seems swig insist on it?