Line | |
---|
1 | // This file is part of the PACPUS framework distributed under the
|
---|
2 | // CECILL-C License, Version 1.0.
|
---|
3 | //
|
---|
4 | /// @version $Id$
|
---|
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 |
|
---|
14 | using namespace pacpus;
|
---|
15 |
|
---|
16 | DECLARE_STATIC_LOGGER("pacpus.core.ComponentFactoryBase");
|
---|
17 |
|
---|
18 | ComponentFactoryBase::ComponentFactoryBase()
|
---|
19 | : mgr_(NULL)
|
---|
20 | {
|
---|
21 | LOG_TRACE("constructor");
|
---|
22 | // get the adress of the ComponentManager instance
|
---|
23 | mgr_ = ComponentManager::getInstance();
|
---|
24 | }
|
---|
25 |
|
---|
26 | ComponentFactoryBase::~ComponentFactoryBase()
|
---|
27 | {
|
---|
28 | LOG_TRACE("destructor");
|
---|
29 | }
|
---|
30 |
|
---|
31 | void 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 |
|
---|
45 | void 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.