Changeset 288 in pacpusframework for trunk/src/PacpusLib/ComponentBase.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/PacpusLib/ComponentBase.cpp

    r286 r288  
    1717#include <boost/program_options/parsers.hpp>
    1818#include <boost/program_options/variables_map.hpp>
    19 #include <boost/thread/thread.hpp>
     19//#include <boost/thread/thread.hpp>
    2020#include <ostream>
    2121#include <string>
     
    7777DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase");
    7878
    79 ComponentBase::ComponentBase(const QString & componentName)
     79ComponentBase::ComponentBase(QString const& componentName)
    8080    : m_componentName(componentName)
    8181    , m_isActive(false)
     
    131131}
    132132
    133 void ComponentBase::startComponentWithException(boost::exception_ptr& error)
    134 {
    135     try {
    136         startActivity();
    137         error = boost::exception_ptr();
    138     } catch (...) {
    139         error = boost::current_exception();
    140     }
    141 }
    142 
    143 void ComponentBase::startComponentInThread()
    144 {
    145     boost::exception_ptr error;
    146     boost::thread t(
    147         boost::bind(
    148             &ComponentBase::startComponentWithException,
    149             this,
    150             boost::ref(error)
    151         )
    152     );
    153     t.join();
    154     if (error) {
    155         try {
    156             boost::rethrow_exception(error);
    157         } catch (boost::exception& e) {
    158             LOG_FATAL("[" << getName() << "]" << "\tboost::exception thrown: " << boost::diagnostic_information(e));
    159             //throw;
    160         }
    161     }
    162 }
     133//void ComponentBase::startComponentWithException(boost::exception_ptr& error)
     134//{
     135//    try {
     136//        startActivity();
     137//        error = boost::exception_ptr();
     138//    } catch (...) {
     139//        error = boost::current_exception();
     140//    }
     141//}
     142//
     143//void ComponentBase::startComponentInThread()
     144//{
     145//    boost::exception_ptr error;
     146//    boost::thread t(
     147//        boost::bind(
     148//            &ComponentBase::startComponentWithException,
     149//            this,
     150//            boost::ref(error)
     151//        )
     152//    );
     153//    t.join();
     154//    if (error) {
     155//        try {
     156//            boost::rethrow_exception(error);
     157//        } catch (boost::exception& e) {
     158//            LOG_FATAL("[" << getName() << "]" << "\tboost::exception thrown: " << boost::diagnostic_information(e));
     159//            //throw;
     160//        }
     161//    }
     162//}
    163163
    164164int ComponentBase::startComponent()
     
    170170
    171171    setActive(true);
    172     boost::thread worker(&ComponentBase::startComponentInThread, this);
    173     //boost::thread worker(&ComponentBase::startActivity, this);
    174     //startActivity();
     172    //boost::thread worker(&ComponentBase::startComponentInThread, this);
     173    startActivity();
     174    //moveToThread(&mThread);
     175    //mThread.start();
    175176    return true;
    176177}
     
    185186    setActive(false);
    186187    stopActivity();
    187    
     188    //QMetaObject::invokeMethod(&mThread, "quit");
    188189    return true;
    189190}
Note: See TracChangeset for help on using the changeset viewer.