Changeset 288 in pacpusframework for trunk/src/DBITEPlayerLib/DbtPlyUserInterface.cpp


Ignore:
Timestamp:
Mar 26, 2014, 9:27:30 PM (11 years ago)
Author:
Marek Kurdej
Message:

Using boost::shared_ptr for storing components.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/DBITEPlayerLib/DbtPlyUserInterface.cpp

    r152 r288  
    6161ComponentBase::COMPONENT_CONFIGURATION DbtPlyUserInterface::configureComponent(XmlComponentConfig /*config*/)
    6262{
     63    using boost::dynamic_pointer_cast;
     64
    6365    ComponentManager * mgr = ComponentManager::getInstance();
    64     mEngine = dynamic_cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));
    65     if (NULL == mEngine) {
     66    mEngine = dynamic_pointer_cast<DbtPlyEngine>(mgr->getComponent("dbiteEngine"));
     67    if (!mEngine) {
    6668        LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component");
    6769        return CONFIGURED_FAILED;
     
    275277        componentTableWidget->setItem(idx, 0, new QTableWidgetItem(componentName));
    276278
    277         ComponentBase * component = mgr->getComponent(componentName);
    278         if (component) {
    279             COMPONENT_STATE state = component->getState();
    280 
    281             QString stateString;
    282             switch (state) {
    283             case STOPPED:
    284                 stateString = tr("Stopped");
    285                 break;
    286             case NOT_MONITORED:
    287                 stateString = tr("Not monitored");
    288                 break;
    289             case MONITOR_OK:
    290                 stateString = tr("Monitor OK");
    291                 break;
    292             case MONITOR_NOK:
    293                 stateString = tr("Monitor wrong");
    294                 break;
    295 
    296             default:
    297                 stateString = tr("UNKNOWN");
    298                 break;
    299             }
    300             componentTableWidget->setItem(idx, 1, new QTableWidgetItem(stateString));
    301 
    302             // TODO: ADD component type and some detailed information (e.g. parameters)
    303             //QString componentInfo = component->getDetails();
    304             //componentTableWidget->setItem(idx, 2, new QTableWidgetItem(componentInfo));
     279        ComponentSharedPointer component = mgr->getComponent(componentName);
     280        if (!component) {
     281            continue;
    305282        }
     283
     284        COMPONENT_STATE state = component->getState();
     285
     286        QString stateString;
     287        switch (state) {
     288        case STOPPED:
     289            stateString = tr("Stopped");
     290            break;
     291        case NOT_MONITORED:
     292            stateString = tr("Not monitored");
     293            break;
     294        case MONITOR_OK:
     295            stateString = tr("Monitor OK");
     296            break;
     297        case MONITOR_NOK:
     298            stateString = tr("Monitor wrong");
     299            break;
     300
     301        default:
     302            stateString = tr("UNKNOWN");
     303            break;
     304        }
     305        componentTableWidget->setItem(idx, 1, new QTableWidgetItem(stateString));
     306
     307        // TODO: ADD component type and some detailed information (e.g. parameters)
     308        //QString componentInfo = component->getDetails();
     309        //componentTableWidget->setItem(idx, 2, new QTableWidgetItem(componentInfo));
    306310    }
    307311}
     
    309313void DbtPlyUserInterface::connectButtons()
    310314{
     315    // FIXME: use Qt5 connect style
    311316    connect(playBut, SIGNAL(clicked()),
    312         mEngine, SLOT(playEvent()));
     317        mEngine.get(), SLOT(playEvent()));
    313318    connect(pauseBut, SIGNAL(clicked()),
    314         mEngine, SLOT(pauseEvent()));
     319        mEngine.get(), SLOT(pauseEvent()));
    315320    connect(stopBut, SIGNAL(clicked()),
    316         mEngine, SLOT(stopEvent()));
     321        mEngine.get(), SLOT(stopEvent()));
    317322    connect(speedUpBut, SIGNAL(clicked()),
    318         mEngine, SLOT(speedUpEvent()));
     323        mEngine.get(), SLOT(speedUpEvent()));
    319324    connect(speedDownBut, SIGNAL(clicked()),
    320         mEngine, SLOT(speedDownEvent()));
     325        mEngine.get(), SLOT(speedDownEvent()));
    321326}
    322327
    323328void DbtPlyUserInterface::connectDisplay()
    324329{
    325     connect(mEngine, SIGNAL(displayStateSig(DbtPlyEngineState *, float)),
     330    connect(mEngine.get(), SIGNAL(displayStateSig(DbtPlyEngineState *, float)),
    326331        this, SLOT(displayStateSlot(DbtPlyEngineState *, float)));
    327332
    328     connect (mEngine, SIGNAL(timeMinMax(road_time_t, road_time_t)),
     333    connect (mEngine.get(), SIGNAL(timeMinMax(road_time_t, road_time_t)),
    329334        this, SLOT(displayMinMaxTime(road_time_t , road_time_t)));
    330     connect (mEngine, SIGNAL(curReplayTime(road_time_t)),
     335    connect (mEngine.get(), SIGNAL(curReplayTime(road_time_t)),
    331336        this, SLOT(displayTime(road_time_t)));
    332337    connect (rev, SIGNAL(toggled(bool)),
    333         mEngine, SLOT(changeDirection(bool)));
     338        mEngine.get(), SLOT(changeDirection(bool)));
    334339}
    335340
     
    337342{
    338343    connect (timeSlider, SIGNAL(sliderPressed()),
    339         mEngine, SLOT(pauseEvent()));
     344        mEngine.get(), SLOT(pauseEvent()));
    340345    connect (timeSlider, SIGNAL(sliderReleased()),
    341         mEngine, SLOT(playEvent()));
     346        mEngine.get(), SLOT(playEvent()));
    342347}
    343348
Note: See TracChangeset for help on using the changeset viewer.