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

    r89 r288  
    1010#include <Pacpus/kernel/Log.h>
    1111
    12 #include <cassert>
     12#include <boost/assert.hpp>
    1313#include <QString>
    1414
     
    2323    // get the adress of the ComponentManager instance
    2424    mgr_ = ComponentManager::getInstance();
     25    BOOST_ASSERT(mgr_);
    2526}
    2627
     
    3031}
    3132
    32 void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, const QString& type)
     33void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, QString const& type)
    3334{
    3435    LOG_DEBUG("addFactory(type="<< type << ")");
    3536
    36     assert(mgr_);
    3737    if (!mgr_->registerComponentFactory(addr, type)) {
    3838        /*
     
    4444}
    4545
    46 void ComponentFactoryBase::addComponent(const QString& name)
     46void ComponentFactoryBase::createComponent(QString const& name)
    4747{
    4848    LOG_DEBUG("addComponent(" << name << ")");
    4949
    50     // FIXME: instantiated component is never deleted!
    51     // who should do it? ComponentManager?
    52     ComponentBase * addr = instantiateComponent(name);
    53     assert(mgr_);
    54     if (!mgr_->registerComponent(addr, name)) {
    55         delete addr;
    56         addr = NULL;
    57     }
     50    ComponentSharedPointer component = instantiateComponent(name);
     51    mgr_->registerComponent(component, name);
    5852}
Note: See TracChangeset for help on using the changeset viewer.