Add register function for column type

This commit is contained in:
2016-12-20 11:13:57 +01:00
parent 82fbe43980
commit 3cedd00d7f
2 changed files with 12 additions and 1 deletions

View File

@ -4,6 +4,7 @@ from .capi.obidmscolumn cimport OBIDMS_column_p
from .capi.obiview cimport Obiview_p from .capi.obiview cimport Obiview_p
from .capi.obitypes cimport obiversion_t, OBIType_t, index_t from .capi.obitypes cimport obiversion_t, OBIType_t, index_t
from ._obidmscolumn_int cimport OBIDMS_column_int, \ from ._obidmscolumn_int cimport OBIDMS_column_int, \
OBIDMS_column_multi_elts_int OBIDMS_column_multi_elts_int
@ -50,3 +51,4 @@ cdef class OBIDMS_column_line:
cdef OBIDMS_column _column cdef OBIDMS_column _column
cdef index_t _index cdef index_t _index
cdef register_column_class(OBIType_t obitype,type classe)

View File

@ -1,5 +1,7 @@
#cython: language_level=3 #cython: language_level=3
cdef dict __OBIDMS_COLUMN_CLASS__ = {}
cdef class OBIDMS_column : cdef class OBIDMS_column :
# Note: should only be initialized through a subclass # Note: should only be initialized through a subclass
@ -16,6 +18,8 @@ cdef class OBIDMS_column :
self._pointer = column_pp self._pointer = column_pp
self._view = view self._view = view
cpdef getitem(self,index_t line_nb, str element_name):
def __setitem__(self, index_t line_nb, object value): def __setitem__(self, index_t line_nb, object value):
self.set_line(line_nb, value) self.set_line(line_nb, value)
@ -189,3 +193,8 @@ cdef class OBIDMS_column_line :
###################################################################################################### ######################################################################################################
cdef register_column_class(OBIType_t obitype,type classe):
assert issubclass(classe,OBIDMS_column)
__OBIDMS_COLUMN_CLASS__[obitype]=classe