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

Last change on this file since 25 was 3, checked in by sgosseli, 12 years ago
  • Add the existing Pacpus files from pacpusdev and pacpuscore.
  • Provide a clean build system based on multiple CMake files.
File size: 1.6 KB
RevLine 
[3]1// ********************************************************************
2// created: 2006/02/14 - 16:07
3// filename: ComponentFactoryBase.cpp
4//
5// author: Gerald Dherbomez
6//
7// purpose: Implementation of ComponentFactoryBase class
8// *********************************************************************
9
10#include "kernel/ComponentFactoryBase.h"
11
12#include "kernel/ComponentBase.h"
13#include "kernel/ComponentManager.h"
14#include "kernel/Log.h"
15
16#include <cassert>
17#include <QString>
18
19namespace pacpus {
20
21DECLARE_STATIC_LOGGER("pacpus.core.ComponentFactoryBase");
22
23ComponentFactoryBase::ComponentFactoryBase()
24{
25 LOG_TRACE("constructor");
26
27 // get the adress of the ComponentManager instance
28 mgr_ = ComponentManager::getInstance();
29}
30
31ComponentFactoryBase::~ComponentFactoryBase()
32{
33 LOG_TRACE("destructor");
34}
35
36void ComponentFactoryBase::addFactory(ComponentFactoryBase * addr, const QString & type)
37{
38 LOG_DEBUG("addFactory(type="<< type << ")");
39
40 assert(mgr_);
41 if (!mgr_->registerComponentFactory(addr, type)) {
42 /*
43 // FIXME: delete in a secure manner (no double delete)
44 delete addr;
45 addr = NULL;
46 */
47 }
48}
49
50void ComponentFactoryBase::addComponent(const QString & name)
51{
52 LOG_DEBUG("addComponent(" << name << ")");
53
54 // FIXME: instantiated component is never deleted!
55 // who should do it? ComponentManager?
56 ComponentBase * addr = instantiateComponent(name);
57 assert(mgr_);
58 if (!mgr_->registerComponent(addr, name)) {
59 delete addr;
60 addr = NULL;
61 }
62}
63
64} // namespace pacpus
Note: See TracBrowser for help on using the repository browser.