source: pacpusframework/trunk/src/PacpusLib/ComponentFactoryBase.cpp@ 357

Last change on this file since 357 was 288, checked in by Marek Kurdej, 11 years ago

Using boost::shared_ptr for storing components.

  • Property svn:executable set to *
File size: 1.4 KB
RevLine 
[89]1// %pacpus:license{
2// This file is part of the PACPUS framework distributed under the
3// CECILL-C License, Version 1.0.
4// %pacpus:license}
5/// @version $Id: ComponentFactoryBase.cpp 76 2013-01-10 17:05:10Z kurdejma $
6
7#include <Pacpus/kernel/ComponentFactoryBase.h>
8#include <Pacpus/kernel/ComponentBase.h>
9#include <Pacpus/kernel/ComponentManager.h>
10#include <Pacpus/kernel/Log.h>
11
[288]12#include <boost/assert.hpp>
[89]13#include <QString>
14
15using namespace pacpus;
16
17DECLARE_STATIC_LOGGER("pacpus.core.ComponentFactoryBase");
18
19ComponentFactoryBase::ComponentFactoryBase()
20 : mgr_(NULL)
21{
22 LOG_TRACE("constructor");
23 // get the adress of the ComponentManager instance
24 mgr_ = ComponentManager::getInstance();
[288]25 BOOST_ASSERT(mgr_);
[89]26}
27
28ComponentFactoryBase::~ComponentFactoryBase()
29{
30 LOG_TRACE("destructor");
31}
32
[288]33void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, QString const& type)
[89]34{
35 LOG_DEBUG("addFactory(type="<< type << ")");
36
37 if (!mgr_->registerComponentFactory(addr, type)) {
38 /*
39 // FIXME: delete in a secure manner (no double delete)
40 delete addr;
41 addr = NULL;
42 */
43 }
44}
45
[288]46void ComponentFactoryBase::createComponent(QString const& name)
[89]47{
48 LOG_DEBUG("addComponent(" << name << ")");
49
[288]50 ComponentSharedPointer component = instantiateComponent(name);
51 mgr_->registerComponent(component, name);
[89]52}
Note: See TracBrowser for help on using the repository browser.