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

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

Minor: line-endings.

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