Skip to content

Commit 291929c

Browse files
committed
core: make np_type static thhrough a Singleton
1 parent aacf998 commit 291929c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

include/eigenpy/details.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,19 @@ namespace eigenpy
8989
static void switchToNumpyArray()
9090
{
9191
getInstance().CurrentNumpyType = getInstance().NumpyArrayObject;
92-
getInstance().np_type = ARRAY_TYPE;
92+
getType() = ARRAY_TYPE;
9393
}
9494

9595
static void switchToNumpyMatrix()
9696
{
9797
getInstance().CurrentNumpyType = getInstance().NumpyMatrixObject;
98-
getInstance().np_type = MATRIX_TYPE;
98+
getType() = MATRIX_TYPE;
9999
}
100100

101-
static NP_TYPE getType()
101+
static NP_TYPE & getType()
102102
{
103-
return getInstance().np_type;
103+
static NP_TYPE np_type;
104+
return np_type;
104105
}
105106

106107
protected:
@@ -121,6 +122,7 @@ namespace eigenpy
121122
//NumpyAsMatrixType = reinterpret_cast<PyTypeObject*>(NumpyAsMatrixObject.ptr());
122123

123124
CurrentNumpyType = NumpyMatrixObject; // default conversion
125+
getType() = MATRIX_TYPE;
124126
}
125127

126128
bp::object CurrentNumpyType;
@@ -131,11 +133,8 @@ namespace eigenpy
131133
//bp::object NumpyAsMatrixObject; PyTypeObject * NumpyAsMatrixType;
132134
bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType;
133135

134-
static NP_TYPE np_type;
135136
};
136137

137-
NP_TYPE NumpyType::np_type = MATRIX_TYPE;
138-
139138
template<typename MatType>
140139
struct EigenObjectAllocator
141140
{

0 commit comments

Comments
 (0)