source: pacpusframework/branches/0.2.x/src/PacpusLib/ComponentFactoryBase.cpp

Last change on this file 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
Line 
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
12#include <boost/assert.hpp>
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();
25 BOOST_ASSERT(mgr_);
26}
27
28ComponentFactoryBase::~ComponentFactoryBase()
29{
30 LOG_TRACE("destructor");
31}
32
33void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, QString const& type)
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
46void ComponentFactoryBase::createComponent(QString const& name)
47{
48 LOG_DEBUG("addComponent(" << name << ")");
49
50 ComponentSharedPointer component = instantiateComponent(name);
51 mgr_->registerComponent(component, name);
52}
Note: See TracBrowser for help on using the repository browser.