~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Base/ParameterPy.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   (c) Jļæ½rgen Riegel (juergen.riegel@web.de) 2002                        *
 
3
 *                                                                         *
 
4
 *   This file is part of the FreeCAD CAx development system.              *
 
5
 *                                                                         *
 
6
 *   This program is free software; you can redistribute it and/or modify  *
 
7
 *   it under the terms of the GNU Library General Public License (LGPL)   *
 
8
 *   as published by the Free Software Foundation; either version 2 of     *
 
9
 *   the License, or (at your option) any later version.                   *
 
10
 *   for detail see the LICENCE text file.                                 *
 
11
 *                                                                         *
 
12
 *   FreeCAD is distributed in the hope that it will be useful,            *
 
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
15
 *   GNU Library General Public License for more details.                  *
 
16
 *                                                                         *
 
17
 *   You should have received a copy of the GNU Library General Public     *
 
18
 *   License along with FreeCAD; if not, write to the Free Software        *
 
19
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
 
20
 *   USA                                                                   *
 
21
 *                                                                         *
 
22
 *   Juergen Riegel 2002                                                   *
 
23
 ***************************************************************************/
 
24
 
 
25
 
 
26
#include "PreCompiled.h"
 
27
 
 
28
#ifndef _PreComp_
 
29
#   include <assert.h>
 
30
#   include <fcntl.h>
 
31
#   include <sys/types.h>
 
32
#   include <sys/stat.h>
 
33
#   ifdef FC_OS_WIN32
 
34
#   include <io.h>
 
35
#   include <xercesc/sax/SAXParseException.hpp>
 
36
#   endif
 
37
#   include <stdio.h>
 
38
#endif
 
39
 
 
40
 
 
41
#include <fcntl.h>
 
42
#ifdef FC_OS_LINUX
 
43
# include <unistd.h>
 
44
#endif
 
45
 
 
46
#include "Parameter.h"
 
47
#include "Exception.h"
 
48
#include "Console.h"
 
49
#include "PyObjectBase.h"
 
50
 
 
51
using namespace Base;
 
52
 
 
53
//**************************************************************************
 
54
//**************************************************************************
 
55
// FCPyParametrGrp
 
56
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
57
 
 
58
 
 
59
 
 
60
/** The ParameterGrp wrapper class
 
61
 */
 
62
class ParameterGrpPy :public Base::PyObjectBase
 
63
{
 
64
    /** always start with Py_Header */
 
65
    Py_Header;
 
66
 
 
67
protected:
 
68
    /// Destruction 
 
69
    ~ParameterGrpPy();
 
70
 
 
71
public:
 
72
 
 
73
 
 
74
    //---------------------------------------------------------------------
 
75
    // construction / destruction +++++++++++++++++++++++++++++++++++++++++     
 
76
    //---------------------------------------------------------------------
 
77
 
 
78
    /// Constructor 
 
79
    ParameterGrpPy(const Base::Reference<ParameterGrp> &rcParamGrp, PyTypeObject *T = &Type);
 
80
    /// for Construction in python 
 
81
    static PyObject *PyMake(PyObject *, PyObject *);
 
82
 
 
83
    //---------------------------------------------------------------------
 
84
    // python exports  ++++++++++++++++++++++++++++++++++++++++++++++++++++     
 
85
    //---------------------------------------------------------------------
 
86
 
 
87
    PyObject *_getattr(char *attr);                             // __getattr__ function
 
88
    // getter setter
 
89
    int _setattr(char *attr, PyObject *value);  // __setattr__ function
 
90
    // methods
 
91
    PYFUNCDEF_D (ParameterGrpPy,PyGetGrp);
 
92
    PYFUNCDEF_D (ParameterGrpPy,PyRemGrp);
 
93
    PYFUNCDEF_D (ParameterGrpPy,PyHasGroup);
 
94
    PYFUNCDEF_D (ParameterGrpPy,PyIsEmpty);
 
95
    PYFUNCDEF_D (ParameterGrpPy,PyClear);
 
96
    PYFUNCDEF_D (ParameterGrpPy,PyNotify);
 
97
    PYFUNCDEF_D (ParameterGrpPy,PyNotifyAll);
 
98
 
 
99
    PYFUNCDEF_D (ParameterGrpPy,PySetBool);
 
100
    PYFUNCDEF_D (ParameterGrpPy,PyGetBool);
 
101
    PYFUNCDEF_D (ParameterGrpPy,PyRemBool);
 
102
 
 
103
    PYFUNCDEF_D (ParameterGrpPy,PySetInt);
 
104
    PYFUNCDEF_D (ParameterGrpPy,PyGetInt);
 
105
    PYFUNCDEF_D (ParameterGrpPy,PyRemInt);
 
106
 
 
107
    PYFUNCDEF_D (ParameterGrpPy,PySetUnsigned);
 
108
    PYFUNCDEF_D (ParameterGrpPy,PyGetUnsigned);
 
109
    PYFUNCDEF_D (ParameterGrpPy,PyRemUnsigned);
 
110
 
 
111
    PYFUNCDEF_D (ParameterGrpPy,PySetFloat);
 
112
    PYFUNCDEF_D (ParameterGrpPy,PyGetFloat);
 
113
    PYFUNCDEF_D (ParameterGrpPy,PyRemFloat);
 
114
 
 
115
    PYFUNCDEF_D (ParameterGrpPy,PySetString);
 
116
    PYFUNCDEF_D (ParameterGrpPy,PyGetString);
 
117
    PYFUNCDEF_D (ParameterGrpPy,PyRemString);
 
118
 
 
119
    PYFUNCDEF_D (ParameterGrpPy,importFrom);
 
120
    PYFUNCDEF_D (ParameterGrpPy,insert);
 
121
    PYFUNCDEF_D (ParameterGrpPy,exportTo);
 
122
 
 
123
protected:
 
124
    /// Pointer to the FCDocument where the label comes from 
 
125
    Base::Reference<ParameterGrp> _cParamGrp;
 
126
};
 
127
 
 
128
 
 
129
//--------------------------------------------------------------------------
 
130
// Type structure
 
131
//--------------------------------------------------------------------------
 
132
 
 
133
PyTypeObject ParameterGrpPy::Type = {
 
134
    PyObject_HEAD_INIT(&PyType_Type)
 
135
    0,                                                      /*ob_size*/
 
136
    "ParameterGrp",                                         /*tp_name*/
 
137
    sizeof(ParameterGrpPy),                                 /*tp_basicsize*/
 
138
    0,                                                      /*tp_itemsize*/
 
139
    /* methods */
 
140
    PyDestructor,                                           /*tp_dealloc*/
 
141
    0,                                                      /*tp_print*/
 
142
    __getattr,                                              /*tp_getattr*/
 
143
    __setattr,                                              /*tp_setattr*/
 
144
    0,                                                      /*tp_compare*/
 
145
    __repr,                                                 /*tp_repr*/
 
146
    0,                                                      /*tp_as_number*/
 
147
    0,                                                      /*tp_as_sequence*/
 
148
    0,                                                      /*tp_as_mapping*/
 
149
    0,                                                      /*tp_hash*/
 
150
    0,                                                      /*tp_call */
 
151
    0,                                                      /*tp_str  */
 
152
    0,                                                      /*tp_getattro*/
 
153
    0,                                                      /*tp_setattro*/
 
154
    /* --- Functions to access object as input/output buffer ---------*/
 
155
    0,                                                      /* tp_as_buffer */
 
156
    /* --- Flags to define presence of optional/expanded features */
 
157
    0,                                                      /*tp_flags */
 
158
    "Python interface class to set parameters",             /*tp_doc */
 
159
    0,                                                      /*tp_traverse */
 
160
    0,                                                      /*tp_clear */
 
161
    0,                                                      /*tp_richcompare */
 
162
    0,                                                      /*tp_weaklistoffset */
 
163
    0,                                                      /*tp_iter */
 
164
    0,                                                      /*tp_iternext */
 
165
    0,                                                      /*tp_methods */
 
166
    0,                                                      /*tp_members */
 
167
    0,                                                      /*tp_getset */
 
168
    0,                                                      /*tp_base */
 
169
    0,                                                      /*tp_dict */
 
170
    0,                                                      /*tp_descr_get */
 
171
    0,                                                      /*tp_descr_set */
 
172
    0,                                                      /*tp_dictoffset */
 
173
    0,                                                      /*tp_init */
 
174
    0,                                                      /*tp_alloc */
 
175
    0,                                                      /*tp_new */
 
176
    0,                                                      /*tp_free   Low-level free-memory routine */
 
177
    0,                                                      /*tp_is_gc  For PyObject_IS_GC */
 
178
    0,                                                      /*tp_bases */
 
179
    0,                                                      /*tp_mro    method resolution order */
 
180
    0,                                                      /*tp_cache */
 
181
    0,                                                      /*tp_subclasses */
 
182
    0,                                                      /*tp_weaklist */
 
183
    0                                                       /*tp_del */
 
184
};
 
185
 
 
186
//--------------------------------------------------------------------------
 
187
// Methods structure
 
188
//--------------------------------------------------------------------------
 
189
PyMethodDef ParameterGrpPy::Methods[] = {
 
190
    {"GetGroup",         (PyCFunction) sPyGetGrp,          Py_NEWARGS, 0},
 
191
    {"RemGroup",         (PyCFunction) sPyRemGrp,          Py_NEWARGS, 0},
 
192
    {"HasGroup",         (PyCFunction) sPyHasGroup,        Py_NEWARGS, 0},
 
193
    {"IsEmpty",          (PyCFunction) sPyIsEmpty,         Py_NEWARGS, 0},
 
194
    {"Clear",            (PyCFunction) sPyClear,           Py_NEWARGS, 0},
 
195
    {"Notify",           (PyCFunction) sPyNotify,          Py_NEWARGS, 0},
 
196
    {"NotifyAll",        (PyCFunction) sPyNotifyAll,       Py_NEWARGS, 0},
 
197
 
 
198
    {"SetBool",          (PyCFunction) sPySetBool,         Py_NEWARGS, 0},
 
199
    {"GetBool",          (PyCFunction) sPyGetBool,         Py_NEWARGS, 0},
 
200
    {"RemBool",          (PyCFunction) sPyRemBool,         Py_NEWARGS, 0},
 
201
 
 
202
    {"SetInt",           (PyCFunction) sPySetInt,          Py_NEWARGS, 0},
 
203
    {"GetInt",           (PyCFunction) sPyGetInt,          Py_NEWARGS, 0},
 
204
    {"RemInt",           (PyCFunction) sPyRemInt,          Py_NEWARGS, 0},
 
205
 
 
206
    {"SetUnsigned",      (PyCFunction) sPySetUnsigned,     Py_NEWARGS, 0},
 
207
    {"GetUnsigned",      (PyCFunction) sPyGetUnsigned,     Py_NEWARGS, 0},
 
208
    {"RemUnsigned",      (PyCFunction) sPyRemUnsigned,     Py_NEWARGS, 0},
 
209
 
 
210
    {"SetFloat",         (PyCFunction) sPySetFloat,        Py_NEWARGS, 0},
 
211
    {"GetFloat",         (PyCFunction) sPyGetFloat,        Py_NEWARGS, 0},
 
212
    {"RemFloat",         (PyCFunction) sPyRemFloat,        Py_NEWARGS, 0},
 
213
 
 
214
    {"SetString",        (PyCFunction) sPySetString,       Py_NEWARGS, 0},
 
215
    {"GetString",        (PyCFunction) sPyGetString,       Py_NEWARGS, 0},
 
216
    {"RemString",        (PyCFunction) sPyRemString,       Py_NEWARGS, 0},
 
217
 
 
218
    {"Import",           (PyCFunction) simportFrom,        Py_NEWARGS, 0},
 
219
    {"Insert",           (PyCFunction) sinsert,            Py_NEWARGS, 0},
 
220
    {"Export",           (PyCFunction) sexportTo,          Py_NEWARGS, 0},
 
221
 
 
222
    {NULL, NULL, 0, NULL}               /* Sentinel */
 
223
};
 
224
 
 
225
//--------------------------------------------------------------------------
 
226
// Parents structure
 
227
//--------------------------------------------------------------------------
 
228
PyParentObject ParameterGrpPy::Parents[] = {&PyObjectBase::Type,&ParameterGrpPy::Type, NULL};     
 
229
 
 
230
//--------------------------------------------------------------------------
 
231
// constructor
 
232
//--------------------------------------------------------------------------
 
233
ParameterGrpPy::ParameterGrpPy(const Base::Reference<ParameterGrp> &rcParamGrp, PyTypeObject *T ) 
 
234
 : PyObjectBase(0, T),_cParamGrp(rcParamGrp)
 
235
{
 
236
    //Console().Log("Create Param Group %p\n",this);
 
237
}
 
238
 
 
239
PyObject *ParameterGrpPy::PyMake(PyObject* /*ignored*/, PyObject* /*args*/)     // Python wrapper
 
240
{
 
241
    //return new ParameterGrpPy();                      // Make new Python-able object
 
242
    return 0;
 
243
}
 
244
 
 
245
//--------------------------------------------------------------------------
 
246
//  FCPyParametrGrp destructor 
 
247
//--------------------------------------------------------------------------
 
248
ParameterGrpPy::~ParameterGrpPy()                                               // Everything handled in parent
 
249
{
 
250
    //Console().Log("Destroy ParameterGrp %p\n",this);
 
251
 
252
 
 
253
//--------------------------------------------------------------------------
 
254
// FCPyParametrGrp Attributes
 
255
//--------------------------------------------------------------------------
 
256
PyObject *ParameterGrpPy::_getattr(char *attr)              // __getattr__ function: note only need to handle new state
 
257
{
 
258
    _getattr_up(PyObjectBase);                              // send to parent
 
259
 
260
 
 
261
int ParameterGrpPy::_setattr(char *attr, PyObject *value)   // __setattr__ function: note only need to handle new state
 
262
{
 
263
    return PyObjectBase::_setattr(attr, value); // send up to parent
 
264
 
265
 
 
266
 
 
267
//--------------------------------------------------------------------------
 
268
// Python wrappers
 
269
//--------------------------------------------------------------------------
 
270
 
 
271
PyObject *ParameterGrpPy::importFrom(PyObject *args)
 
272
{
 
273
    char *pstr;
 
274
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
275
        return NULL;                             // NULL triggers exception 
 
276
    PY_TRY {
 
277
        _cParamGrp->importFrom(pstr);
 
278
    }PY_CATCH;
 
279
    Py_Return;
 
280
 
281
 
 
282
PyObject *ParameterGrpPy::insert(PyObject *args)
 
283
{
 
284
    char *pstr;
 
285
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
286
        return NULL;                             // NULL triggers exception 
 
287
    PY_TRY {
 
288
        _cParamGrp->insert(pstr);
 
289
    }PY_CATCH;
 
290
    Py_Return;
 
291
 
292
 
 
293
PyObject *ParameterGrpPy::exportTo(PyObject *args)
 
294
{
 
295
    char *pstr;
 
296
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
297
        return NULL;                             // NULL triggers exception 
 
298
    PY_TRY {
 
299
        _cParamGrp->exportTo(pstr);
 
300
    }PY_CATCH;
 
301
    Py_Return;
 
302
 
303
 
 
304
PyObject *ParameterGrpPy::PyGetGrp(PyObject *args)
 
305
{
 
306
    char *pstr;
 
307
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
308
        return NULL;                             // NULL triggers exception 
 
309
    PY_TRY {
 
310
        // get the Handle of the wanted group
 
311
        Base::Reference<ParameterGrp> handle = _cParamGrp->GetGroup(pstr);
 
312
        if(handle.isValid()){
 
313
            // crate a python wrapper class
 
314
            ParameterGrpPy *pcParamGrp = new ParameterGrpPy(handle);
 
315
            // increment the reff count
 
316
            //pcParamGrp->_INCREF();
 
317
            return pcParamGrp;
 
318
        }else{
 
319
            PyErr_SetString(PyExc_IOError, "GetGroup failed");
 
320
            return 0L;
 
321
        }
 
322
    }PY_CATCH;
 
323
 
324
 
 
325
PyObject *ParameterGrpPy::PySetBool(PyObject *args)
 
326
{
 
327
    char *pstr;
 
328
    int  Bool;
 
329
    if (!PyArg_ParseTuple(args, "si", &pstr,&Bool))     // convert args: Python->C 
 
330
        return NULL;                             // NULL triggers exception 
 
331
    PY_TRY {
 
332
        _cParamGrp->SetBool(pstr,Bool!=0);
 
333
        Py_Return; 
 
334
    }PY_CATCH;
 
335
 
336
 
 
337
PyObject *ParameterGrpPy::PyGetBool(PyObject *args)
 
338
{
 
339
    char *pstr;
 
340
    int  Bool=0;
 
341
    if (!PyArg_ParseTuple(args, "s|i", &pstr,&Bool))     // convert args: Python->C 
 
342
        return NULL;                             // NULL triggers exception 
 
343
    PY_TRY {
 
344
        return Py_BuildValue("i",_cParamGrp->GetBool(pstr,Bool!=0));
 
345
    }PY_CATCH;
 
346
 
347
 
 
348
PyObject *ParameterGrpPy::PySetInt(PyObject *args)
 
349
{
 
350
    char *pstr;
 
351
    long  Int;
 
352
    if (!PyArg_ParseTuple(args, "si", &pstr,&Int))     // convert args: Python->C 
 
353
        return NULL;                             // NULL triggers exception 
 
354
    PY_TRY {
 
355
        _cParamGrp->SetInt(pstr,Int);
 
356
        Py_Return; 
 
357
    }PY_CATCH;
 
358
 
359
 
 
360
PyObject *ParameterGrpPy::PyGetInt(PyObject *args)
 
361
{
 
362
    char *pstr;
 
363
    long  Int=0;
 
364
    if (!PyArg_ParseTuple(args, "s|i", &pstr,&Int))     // convert args: Python->C 
 
365
        return NULL;                             // NULL triggers exception 
 
366
    PY_TRY {
 
367
        return Py_BuildValue("i",_cParamGrp->GetInt(pstr,Int));
 
368
    }PY_CATCH;
 
369
 
370
 
 
371
PyObject *ParameterGrpPy::PySetUnsigned(PyObject *args)
 
372
{
 
373
    char *pstr;
 
374
    unsigned long  UInt;
 
375
    if (!PyArg_ParseTuple(args, "sI", &pstr,&UInt))     // convert args: Python->C 
 
376
        return NULL;                             // NULL triggers exception 
 
377
    PY_TRY {
 
378
        _cParamGrp->SetUnsigned(pstr,UInt);
 
379
        Py_Return; 
 
380
    }PY_CATCH;
 
381
 
382
 
 
383
PyObject *ParameterGrpPy::PyGetUnsigned(PyObject *args)
 
384
{
 
385
    char *pstr;
 
386
    unsigned long  UInt=0;
 
387
    if (!PyArg_ParseTuple(args, "s|I", &pstr,&UInt))     // convert args: Python->C 
 
388
        return NULL;                             // NULL triggers exception 
 
389
    PY_TRY {
 
390
        return Py_BuildValue("I",_cParamGrp->GetUnsigned(pstr,UInt));
 
391
    }PY_CATCH;
 
392
 
393
 
 
394
PyObject *ParameterGrpPy::PySetFloat(PyObject *args)
 
395
{
 
396
    char *pstr;
 
397
    double  Float;
 
398
    if (!PyArg_ParseTuple(args, "sd", &pstr,&Float))     // convert args: Python->C 
 
399
        return NULL;                             // NULL triggers exception 
 
400
    PY_TRY {
 
401
        _cParamGrp->SetFloat(pstr,Float);
 
402
        Py_Return; 
 
403
    }PY_CATCH;
 
404
}
 
405
 
 
406
PyObject *ParameterGrpPy::PyGetFloat(PyObject *args)
 
407
{
 
408
    char *pstr;
 
409
    double  Float=0.0;
 
410
    if (!PyArg_ParseTuple(args, "s|d", &pstr,&Float))     // convert args: Python->C 
 
411
        return NULL;                             // NULL triggers exception 
 
412
    PY_TRY {
 
413
        return Py_BuildValue("d",_cParamGrp->GetFloat(pstr,Float));
 
414
    }PY_CATCH;
 
415
 
416
 
 
417
PyObject *ParameterGrpPy::PySetString(PyObject *args)
 
418
{
 
419
    char *pstr;
 
420
    char *  str;
 
421
    if (!PyArg_ParseTuple(args, "ss", &pstr,&str))     // convert args: Python->C 
 
422
        return NULL;                             // NULL triggers exception 
 
423
    PY_TRY {
 
424
        _cParamGrp->SetASCII(pstr,str);
 
425
        Py_Return; 
 
426
    }PY_CATCH;
 
427
 
428
 
 
429
PyObject *ParameterGrpPy::PyGetString(PyObject *args)
 
430
{
 
431
    char *pstr;
 
432
    char *  str="";
 
433
    if (!PyArg_ParseTuple(args, "s|s", &pstr,&str))     // convert args: Python->C 
 
434
        return NULL;                             // NULL triggers exception 
 
435
    PY_TRY {
 
436
        return Py_BuildValue("s",_cParamGrp->GetASCII(pstr,str).c_str());
 
437
    }PY_CATCH;
 
438
 
439
 
 
440
//----
 
441
 
 
442
PyObject *ParameterGrpPy::PyRemInt(PyObject *args)
 
443
{
 
444
    char *pstr;
 
445
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
446
        return NULL;                             // NULL triggers exception 
 
447
    PY_TRY {
 
448
        _cParamGrp->RemoveInt(pstr);
 
449
        Py_Return; 
 
450
    }PY_CATCH;
 
451
 
452
 
 
453
PyObject *ParameterGrpPy::PyRemUnsigned(PyObject *args)
 
454
{
 
455
    char *pstr;
 
456
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
457
        return NULL;                             // NULL triggers exception 
 
458
    PY_TRY {
 
459
        _cParamGrp->RemoveUnsigned(pstr);
 
460
        Py_Return; 
 
461
    }PY_CATCH;
 
462
 
463
 
 
464
PyObject *ParameterGrpPy::PyRemBool(PyObject *args)
 
465
{
 
466
    char *pstr;
 
467
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
468
        return NULL;                             // NULL triggers exception 
 
469
    PY_TRY {
 
470
        _cParamGrp->RemoveBool(pstr);
 
471
        Py_Return; 
 
472
    }PY_CATCH;
 
473
 
474
 
 
475
PyObject *ParameterGrpPy::PyRemGrp(PyObject *args)
 
476
{
 
477
    char *pstr;
 
478
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
479
        return NULL;                             // NULL triggers exception 
 
480
    PY_TRY {
 
481
        _cParamGrp->RemoveGrp(pstr);
 
482
        Py_Return; 
 
483
    }PY_CATCH;
 
484
 
485
 
 
486
PyObject *ParameterGrpPy::PyRemFloat(PyObject *args)
 
487
{
 
488
    char *pstr;
 
489
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
490
        return NULL;                             // NULL triggers exception 
 
491
    PY_TRY {
 
492
        _cParamGrp->RemoveFloat(pstr);
 
493
        Py_Return; 
 
494
    }PY_CATCH;
 
495
 
496
 
 
497
PyObject *ParameterGrpPy::PyRemString(PyObject *args)
 
498
{
 
499
    char *pstr;
 
500
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
501
        return NULL;                             // NULL triggers exception 
 
502
    PY_TRY {
 
503
        _cParamGrp->RemoveASCII(pstr);
 
504
        Py_Return; 
 
505
    }PY_CATCH;
 
506
 
507
 
 
508
PyObject *ParameterGrpPy::PyClear(PyObject *args)
 
509
{
 
510
    if (!PyArg_ParseTuple(args, ""))     // convert args: Python->C 
 
511
        return NULL;                             // NULL triggers exception 
 
512
    PY_TRY {
 
513
        _cParamGrp->Clear();
 
514
        Py_Return; 
 
515
    }PY_CATCH;
 
516
 
517
 
 
518
PyObject *ParameterGrpPy::PyIsEmpty(PyObject *args)
 
519
{
 
520
    if (!PyArg_ParseTuple(args, ""))     // convert args: Python->C 
 
521
        return NULL;                             // NULL triggers exception 
 
522
    PY_TRY {
 
523
        return Py_BuildValue("i",_cParamGrp->IsEmpty());
 
524
    }PY_CATCH;
 
525
 
526
 
 
527
PyObject *ParameterGrpPy::PyHasGroup(PyObject *args)
 
528
{
 
529
    char *pstr;
 
530
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
531
        return NULL;                             // NULL triggers exception 
 
532
    PY_TRY {
 
533
        return Py_BuildValue("i",_cParamGrp->HasGroup(pstr));
 
534
    }PY_CATCH;
 
535
 
536
 
 
537
PyObject *ParameterGrpPy::PyNotify(PyObject *args)
 
538
{
 
539
    char *pstr;
 
540
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C 
 
541
        return NULL;                             // NULL triggers exception 
 
542
    PY_TRY {
 
543
        _cParamGrp->Notify(pstr);
 
544
        Py_Return;
 
545
    }PY_CATCH;
 
546
 
547
PyObject *ParameterGrpPy::PyNotifyAll(PyObject *args)
 
548
{
 
549
    if (!PyArg_ParseTuple(args, ""))     // convert args: Python->C 
 
550
        return NULL;                             // NULL triggers exception 
 
551
 
 
552
    PY_TRY {
 
553
        _cParamGrp->NotifyAll();
 
554
        Py_Return;
 
555
    }PY_CATCH;
 
556
 
557
 
 
558
/** python wrapper function
 
559
*/
 
560
PyObject* GetPyObject( const Base::Reference<ParameterGrp> &hcParamGrp)
 
561
{
 
562
    return new ParameterGrpPy(hcParamGrp); 
 
563
}