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

Last change on this file since 43 was 43, checked in by sgosseli, 12 years ago

Minor: add some documentation, update the license header, update the coding style.

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