qtms/src/qtmsgaineffectimpl.cpp
changeset 51 e61a04404bdf
parent 32 edd273b3192a
equal deleted inserted replaced
44:d141fc1ad77b 51:e61a04404bdf
    21 
    21 
    22 using namespace QTMS;
    22 using namespace QTMS;
    23 using namespace TMS;
    23 using namespace TMS;
    24 
    24 
    25 QTMSGainEffectImpl::QTMSGainEffectImpl()
    25 QTMSGainEffectImpl::QTMSGainEffectImpl()
    26     {
    26 {
    27     }
    27 }
    28 
    28 
    29 QTMSGainEffectImpl::~QTMSGainEffectImpl()
    29 QTMSGainEffectImpl::~QTMSGainEffectImpl()
    30     {
    30 {
    31     RemoveObserver(*this);
    31     RemoveObserver(*this);
    32     }
    32 }
    33 
    33 
    34 gint QTMSGainEffectImpl::Create(QTMSEffect*& qgain, TMS::TMSEffect*& tmsgain)
    34 gint QTMSGainEffectImpl::Create(QTMSEffect*& qgain, TMS::TMSEffect*& tmsgain)
    35     {
    35 {
    36     gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY);
    36     gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY);
    37     QTMSGainEffectImpl* self = new QTMSGainEffectImpl();
    37     QTMSGainEffectImpl* self = new QTMSGainEffectImpl();
    38     if (self)
    38     if (self) {
    39         {
       
    40         ret = self->PostConstruct();
    39         ret = self->PostConstruct();
    41         if (ret != QTMS_RESULT_SUCCESS)
    40         if (ret != QTMS_RESULT_SUCCESS) {
    42             {
       
    43             delete self;
    41             delete self;
    44             self = NULL;
    42             self = NULL;
    45             }
    43         }
    46         self->iEffect = tmsgain;
    44         self->iEffect = tmsgain;
    47         ret = self->AddObserver(*self, NULL);
    45         ret = self->AddObserver(*self, NULL);
    48         }
    46     }
    49     qgain = self;
    47     qgain = self;
    50     return ret;
    48     return ret;
    51     }
    49 }
    52 
    50 
    53 gint QTMSGainEffectImpl::PostConstruct()
    51 gint QTMSGainEffectImpl::PostConstruct()
    54     {
    52 {
    55     gint ret(QTMS_RESULT_SUCCESS);
    53     gint ret(QTMS_RESULT_SUCCESS);
    56     return ret;
    54     return ret;
    57     }
    55 }
    58 
    56 
    59 gint QTMSGainEffectImpl::AddObserver(TMS::TMSEffectObserver& obsrvr,
    57 gint QTMSGainEffectImpl::AddObserver(TMS::TMSEffectObserver& obsrvr, gpointer user_data)
    60         gpointer user_data)
    58 {
    61     {
       
    62     gint ret(QTMS_RESULT_SUCCESS);
    59     gint ret(QTMS_RESULT_SUCCESS);
    63 
    60 
    64     if (iEffect)
    61     if (iEffect) {
    65         {
    62         ret = static_cast<TMSGainEffect*> (iEffect)->AddObserver(obsrvr, user_data);
    66         ret = static_cast<TMSGainEffect*> (iEffect)->AddObserver(obsrvr,
    63     }
    67                 user_data);
       
    68         }
       
    69     return ret;
    64     return ret;
    70     }
    65 }
    71 
    66 
    72 gint QTMSGainEffectImpl::RemoveObserver(TMS::TMSEffectObserver& obsrvr)
    67 gint QTMSGainEffectImpl::RemoveObserver(TMS::TMSEffectObserver& obsrvr)
    73     {
    68 {
    74     gint ret(QTMS_RESULT_SUCCESS);
    69     gint ret(QTMS_RESULT_SUCCESS);
    75 
    70 
    76     if (iEffect)
    71     if (iEffect) {
    77         {
       
    78         ret = static_cast<TMSGainEffect*> (iEffect)->RemoveObserver(obsrvr);
    72         ret = static_cast<TMSGainEffect*> (iEffect)->RemoveObserver(obsrvr);
    79         }
    73     }
    80     return ret;
    74     return ret;
    81     }
    75 }
    82 
    76 
    83 gint QTMSGainEffectImpl::GetEffect(TMS::TMSEffect*& tmseffect)
    77 gint QTMSGainEffectImpl::GetEffect(TMS::TMSEffect*& tmseffect)
    84     {
    78 {
    85     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
    79     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
    86 
    80 
    87     if (iEffect)
    81     if (iEffect) {
    88         {
       
    89         tmseffect = iEffect;
    82         tmseffect = iEffect;
    90         ret = QTMS_RESULT_SUCCESS;
    83         ret = QTMS_RESULT_SUCCESS;
    91         }
    84     }
    92     return ret;
    85     return ret;
    93     }
    86 }
    94 
    87 
    95 void QTMSGainEffectImpl::EffectsEvent(const TMS::TMSEffect& /*tmseffect*/,
    88 void QTMSGainEffectImpl::EffectsEvent(const TMS::TMSEffect& /*tmseffect*/,
    96         TMS::TMSSignalEvent event)
    89     TMS::TMSSignalEvent event)
    97     {
    90 {
    98     QTMSSignalEvent qevent;
    91     QTMSSignalEvent qevent;
    99 
    92 
   100     qevent.type = event.type;
    93     qevent.type = event.type;
   101     qevent.reason = event.reason;
    94     qevent.reason = event.reason;
   102     qevent.curr_state = event.curr_state;
    95     qevent.curr_state = event.curr_state;
   103     qevent.prev_state = event.prev_state;
    96     qevent.prev_state = event.prev_state;
   104     qevent.event_data = event.event_data;
    97     qevent.event_data = event.event_data;
   105     qevent.user_data = event.user_data;
    98     qevent.user_data = event.user_data;
   106 
    99 
   107     emit QTMS::QTMSGainEffect::EffectsEvent(static_cast<QTMSEffect&> (*this),
   100     emit QTMS::QTMSGainEffect::EffectsEvent(static_cast<QTMSEffect&> (*this), qevent);
   108             qevent);
   101 }
   109     }
       
   110 
   102 
   111 // End of file
   103 // End of file