SWIG - python : les accesseurs
Bonjour,
Je suis en train de travailler sur un outil de "lecture" de fichier de données Electro encephalo Gramme, qui est codé en c++ et qui utilise SWIG pour un interfacage en python.
J'ai une question toute simple, comment utiliser les accesseurs en python dans ce cas ?
Mon fichier python :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| class HDRTYPE_FILE(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, HDRTYPE_FILE, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, HDRTYPE_FILE, name)
__repr__ = _swig_repr
__swig_setmethods__["FID"] = _biosig.HDRTYPE_FILE_FID_set
__swig_getmethods__["FID"] = _biosig.HDRTYPE_FILE_FID_get
if _newclass:FID = _swig_property(_biosig.HDRTYPE_FILE_FID_get, _biosig.HDRTYPE_FILE_FID_set)
__swig_setmethods__["POS"] = _biosig.HDRTYPE_FILE_POS_set
__swig_getmethods__["POS"] = _biosig.HDRTYPE_FILE_POS_get
if _newclass:POS = _swig_property(_biosig.HDRTYPE_FILE_POS_get, _biosig.HDRTYPE_FILE_POS_set)
__swig_setmethods__["OPEN"] = _biosig.HDRTYPE_FILE_OPEN_set
__swig_getmethods__["OPEN"] = _biosig.HDRTYPE_FILE_OPEN_get
if _newclass:OPEN = _swig_property(_biosig.HDRTYPE_FILE_OPEN_get, _biosig.HDRTYPE_FILE_OPEN_set)
__swig_setmethods__["LittleEndian"] = _biosig.HDRTYPE_FILE_LittleEndian_set
__swig_getmethods__["LittleEndian"] = _biosig.HDRTYPE_FILE_LittleEndian_get
if _newclass:LittleEndian = _swig_property(_biosig.HDRTYPE_FILE_LittleEndian_get, _biosig.HDRTYPE_FILE_LittleEndian_set)
__swig_setmethods__["COMPRESSION"] = _biosig.HDRTYPE_FILE_COMPRESSION_set
__swig_getmethods__["COMPRESSION"] = _biosig.HDRTYPE_FILE_COMPRESSION_get
if _newclass:COMPRESSION = _swig_property(_biosig.HDRTYPE_FILE_COMPRESSION_get, _biosig.HDRTYPE_FILE_COMPRESSION_set)
def __init__(self, *args):
this = _biosig.new_HDRTYPE_FILE(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _biosig.delete_HDRTYPE_FILE
__del__ = lambda self : None;
HDRTYPE_FILE_swigregister = _biosig.HDRTYPE_FILE_swigregister
HDRTYPE_FILE_swigregister(HDRTYPE_FILE) |
mon fichier SWIG :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| typedef struct { /* File specific data */
FILE* FID; /* file handle */
size_t POS; /* current reading/writing position [in blocks] */
// int Des; /* file descriptor */
uint8_t OPEN; /* 0: closed, 1:read, 2: write */
uint8_t LittleEndian;
uint8_t COMPRESSION; /* 0: no compression 9: best compression */
// int DES; /* descriptor for streams */
} HDRTYPE_FILE; |
après j'ai des fonction definies comme ca : SWIGINTERN PyObject *_wrap_xxxxxxxx
qui ont l'air d'etre des accesseurs...
par exemple :
Code:
1 2
|
SWIGINTERN PyObject *_wrap_HDRTYPE_TYPE_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { |
et ensuite toute une liste de :
Code:
1 2 3 4 5
|
static PyMethodDef SwigMethods[] = {
{ (char *)"HDRTYPE_TYPE_get", _wrap_HDRTYPE_TYPE_get, METH_VARARGS, NULL},
...
... |
Bien sur le code n'est pas commenté (ni en python ni en c++)
Voila donc comment est ce que je peut utiliser une methode du genre HDRTYPE.HDRTYPE_TYPE_get() ??
Merci beaucoup de votre aide !!!
edit :
et quand je crée un objet HDRTYPE nommé HDR, j'ai la structure suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| In [28]: HDR.
HDR.AS HDR.T0 HDR.__reduce_ex__
HDR.CHANNEL HDR.TYPE HDR.__repr__
HDR.ELEC HDR.VERSION HDR.__setattr__
HDR.EVENT HDR.__class__ HDR.__sizeof__
HDR.FILE HDR.__del__ HDR.__str__
HDR.FLAG HDR.__delattr__ HDR.__subclasshook__
HDR.FileName HDR.__dict__ HDR.__swig_destroy__
HDR.HeadLen HDR.__doc__ HDR.__swig_getmethods__
HDR.ID HDR.__format__ HDR.__swig_setmethods__
HDR.IPaddr HDR.__getattr__ HDR.__weakref__
HDR.LOC HDR.__getattribute__ HDR.aECG
HDR.NRec HDR.__hash__ HDR.data
HDR.NS HDR.__init__ HDR.this
HDR.Patient HDR.__module__ HDR.tzmin
HDR.SPR HDR.__new__
HDR.SampleRate HDR.__reduce__ |
A quoi corresponde les champ de type _nomduchamp_ ?
Merci encore