SoftOpExternalMgr.sip 4.33 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
class SoftOpExternalMgr
{
%TypeHeaderCode
#include <SoftOpExternalMgr.h>
using namespace lima;
%End

  public:
    typedef std::string alias;
    typedef int stage;
    SoftOpExternalMgr();
    ~SoftOpExternalMgr();
    
    SIP_PYOBJECT getAvailableOp() const;
%MethodCode
    const SoftOpKey *SoftOpTable;
    sipCpp->getAvailableOp(SoftOpTable);
    int index = 0;
    PyObject *aReturnListPt = PyList_New(0);
    while(1)
     {
       const SoftOpKey &aSoftOpKey = SoftOpTable[index++];
       if(!aSoftOpKey.m_name) break;
       PyObject *wobj = sipConvertFromType((void*)(&aSoftOpKey),sipType_SoftOpKey,NULL);
       if(!wobj) //Error
	{
	  Py_DECREF(aReturnListPt);
          return NULL;
	}
       PyList_Append(aReturnListPt,wobj);
       Py_DECREF(wobj);
     }
sipRes = aReturnListPt;
%End
    void getActiveOp(std::map<int,std::list<std::string> > &activeOp /Out/) const;
    void getActiveStageOp(int,std::list<std::string> &activeOp /Out/) const;

59 60 61
    SIP_PYOBJECT addOp(SoftOpId,const alias&,int stage);
%MethodCode
    SoftOpInstance anInstance;
62
TRY
63 64
    sipCpp->addOp(a0,*a1,a2,anInstance);
INSTANCE_2_SoftOp
65
CATCH
66
%End
67 68 69 70
    void delOp(const alias&);
    SIP_PYOBJECT getOpClass(const alias&) const;
%MethodCode
    SoftOpInstance anInstance;
71
TRY
72
    sipCpp->getOpClass(*a0,anInstance);
73
INSTANCE_2_SoftOp
74
CATCH
75 76 77 78 79 80 81 82 83 84
%End

    void setEndLinkTaskCallback(TaskEventCallback *aCbk);
    void setEndSinkTaskCallback(TaskEventCallback *aCbk);

    void addTo(TaskMgr&,int begin_stage,int &last_link_task /Out/,
               int &last_sink_task /Out/);
    
    void isTaskActive(bool &linkTaskFlag /Out/,bool &sinkTaskFlag /Out/) const;
    void prepare();
85 86 87 88 89 90 91 92
%TypeCode
#define INSTANCE_2_SoftOp \
    if(anInstance.m_opt) \
      { \
	switch(anInstance.m_key.m_id) \
	{ \
	case(BACKGROUNDSUBSTRACTION): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftOpBackgroundSubstraction,NULL);break; \
93 94 95 96 97 98 99 100 101 102
	case(BINNING): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftOpBinning,NULL);break; \
	case(BPM): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftOpBpm,NULL);break; \
	case(FLATFIELDCORRECTION): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftOpFlatfieldCorrection,NULL);break; \
	case(FLIP): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftOpFlip,NULL);break; \
	case(MASK): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftOpMask,NULL);break; \
103 104
	case(ROICOUNTERS): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftOpRoiCounter,NULL);break; \
105 106
	case(ROI2SPECTRUM): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftOpRoi2Spectrum,NULL);break; \
107 108
	case(SOFTROI): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftOpSoftRoi,NULL);break; \
109 110 111 112
	case(USER_LINK_TASK): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftUserLinkTask,NULL);break; \
	case(USER_SINK_TASK): \
	  sipRes = sipConvertFromType(anInstance.m_opt,sipType_SoftUserSinkTask,NULL);break; \
113 114 115 116 117 118 119 120 121
	default: \
	  throw LIMA_CTL_EXC(NotSupported,"Sofware class not yet managed"); \
	} \
      } \
    else \
      { \
        Py_INCREF(Py_None); \
	sipRes = Py_None; \
      }
122 123 124 125 126 127 128 129 130 131 132 133

#define TRY try \
      {
#define CATCH						\
    }							\
    catch(Exception &exp)				\
    {							\
    const std::string& tmpString = exp.getErrMsg();	\
    const char *detail = tmpString.c_str();		\
    PyErr_SetString(sipException_Exception, detail);	\
    return NULL;					\
    }
134
%End
135
};