[89] | 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}
|
---|
[162] | 5 | /// @author Gerald Dherbomez <firstname.surname@utc.fr>
|
---|
[89] | 6 | /// @version $Id: ComponentManager.cpp 76 2013-01-10 17:05:10Z kurdejma $
|
---|
| 7 |
|
---|
[199] | 8 | #include <Pacpus/kernel/ComponentManager.h>
|
---|
| 9 |
|
---|
[162] | 10 | #include <Pacpus/kernel/ComponentFactoryBase.h>
|
---|
[89] | 11 | #include <Pacpus/kernel/ComponentBase.h>
|
---|
[110] | 12 | #include <Pacpus/kernel/ConnectionBase.h>
|
---|
[182] | 13 | #include <Pacpus/kernel/InputOutputBase.h>
|
---|
[89] | 14 | #include <Pacpus/kernel/Log.h>
|
---|
[201] | 15 | #include <Pacpus/kernel/PacpusException.h>
|
---|
[199] | 16 |
|
---|
[182] | 17 | #include <QDomNodeList>
|
---|
[89] | 18 | #include <QObject>
|
---|
| 19 |
|
---|
| 20 | using namespace pacpus;
|
---|
| 21 |
|
---|
| 22 | DECLARE_STATIC_LOGGER("pacpus.core.ComponentManager");
|
---|
| 23 |
|
---|
[185] | 24 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 25 |
|
---|
| 26 | bool connectInterface(OutputInterfaceBase * out, InputInterfaceBase * in, int priority, InputInterfaceBase::ReadingMode mode = InputInterfaceBase::GetLast);
|
---|
| 27 |
|
---|
| 28 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 29 |
|
---|
| 30 | bool connectInterface(OutputInterfaceBase * out, InputInterfaceBase * in, int priority, InputInterfaceBase::ReadingMode mode)
|
---|
| 31 | {
|
---|
[199] | 32 | if ((out->getDataType() == in->getDataType())
|
---|
| 33 | || (out->getDataType() == typeid(QByteArray))
|
---|
| 34 | || (in->getDataType() == typeid(QByteArray))) {
|
---|
[185] | 35 | // Add connection
|
---|
| 36 | out->addConnection(ConnectionBase(in, priority)); // TODO make connect function
|
---|
| 37 | in->addConnection(ConnectionBase(out, priority));
|
---|
| 38 | in->setReadingMode(mode);
|
---|
| 39 | //LOG_INFO("connection : Output " << out->getSignature() << " => Input " << in->getSignature());
|
---|
| 40 | return true;
|
---|
| 41 | } else {
|
---|
| 42 | //LOG_WARN("connecting " << out->getSignature() << ":" << out->getDataType() << " to " << in->getSignature() << ":" << in->getDataType() << " failled : DataType incompatible " << QString(typeid(QByteArray).name()));
|
---|
| 43 | return false;
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 48 |
|
---|
[89] | 49 | ComponentManager * ComponentManager::mInstance = NULL;
|
---|
| 50 |
|
---|
| 51 | ComponentManager * ComponentManager::create()
|
---|
| 52 | {
|
---|
| 53 | return getInstance();
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | ComponentManager * ComponentManager::getInstance()
|
---|
| 57 | {
|
---|
| 58 | LOG_TRACE("getInstance()");
|
---|
[146] | 59 | LOG_TRACE("before: mInstance = " << mInstance);
|
---|
[89] | 60 |
|
---|
[146] | 61 | if (!mInstance) {
|
---|
[89] | 62 | LOG_INFO("creating new instance...");
|
---|
| 63 | mInstance = new ComponentManager();
|
---|
| 64 | LOG_DEBUG("mInstance = " << mInstance);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
[146] | 67 | LOG_TRACE("after : mInstance = " << mInstance);
|
---|
[89] | 68 | return mInstance;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | void ComponentManager::destroy()
|
---|
| 72 | {
|
---|
| 73 | LOG_TRACE("destroy");
|
---|
| 74 |
|
---|
[146] | 75 | LOG_TRACE("before: mInstance = " << mInstance);
|
---|
[89] | 76 | delete mInstance;
|
---|
| 77 | mInstance = NULL;
|
---|
[146] | 78 | LOG_TRACE("after : mInstance = " << mInstance);
|
---|
[89] | 79 | }
|
---|
| 80 |
|
---|
| 81 | ComponentManager::ComponentManager()
|
---|
| 82 | {
|
---|
| 83 | LOG_TRACE("constructor");
|
---|
| 84 |
|
---|
| 85 | xmlTree_ = XmlConfigFile::create();
|
---|
| 86 | LOG_DEBUG("component manager was created");
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | ComponentManager::~ComponentManager()
|
---|
| 90 | {
|
---|
| 91 | LOG_TRACE("destructor");
|
---|
| 92 |
|
---|
[146] | 93 | for (ComponentMap::iterator it = componentMap_.begin(), itend = componentMap_.end(); it != itend; ++it) {
|
---|
| 94 | bool unregisteredSuccessfully = unregisterComponent(it.key());
|
---|
| 95 | }
|
---|
[89] | 96 |
|
---|
| 97 | LOG_DEBUG("component manager was deleted");
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | bool ComponentManager::registerComponentFactory(ComponentFactoryBase* addr, const QString& type)
|
---|
| 101 | {
|
---|
| 102 | LOG_TRACE("registerComponentFactory(type="<< type << ")");
|
---|
| 103 |
|
---|
| 104 | if (factoryMap_.contains(type))
|
---|
| 105 | {
|
---|
| 106 | LOG_WARN("cannot register a component factory of type '" << type << "'. It already belongs to the manager");
|
---|
| 107 | return false;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | factoryMap_[type] = addr;
|
---|
| 111 | LOG_INFO("registered component factory '" << type << "'");
|
---|
| 112 |
|
---|
| 113 | return true;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
[146] | 116 | bool ComponentManager::unregisterComponentFactory(const QString& type)
|
---|
[89] | 117 | {
|
---|
[146] | 118 | LOG_TRACE("unregisterComponentFactory(type="<< type << ")");
|
---|
[89] | 119 |
|
---|
[146] | 120 | if (!factoryMap_.contains(type)) {
|
---|
[89] | 121 | LOG_WARN("cannot unregister component factory '" << type << "'. It was not registered");
|
---|
| 122 | return false;
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | factoryMap_.remove(type);
|
---|
| 126 | LOG_INFO("unregistered component factory '" << type << "'");
|
---|
| 127 |
|
---|
| 128 | return true;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | bool ComponentManager::registerComponent(ComponentBase* addr, const QString& name)
|
---|
| 132 | {
|
---|
| 133 | LOG_TRACE("registerComponent(name="<< name << ")");
|
---|
| 134 |
|
---|
| 135 | if (componentMap_.contains(name))
|
---|
| 136 | {
|
---|
| 137 | LOG_WARN("cannot register component '" << name << "'. A component with the same name exists already");
|
---|
| 138 | return false;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | componentMap_[name] = addr;
|
---|
| 142 | LOG_INFO("registered component " << name);
|
---|
| 143 |
|
---|
| 144 | return true;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
[146] | 147 | bool ComponentManager::unregisterComponent(const QString& name)
|
---|
[89] | 148 | {
|
---|
[146] | 149 | LOG_TRACE("unregisterComponent(name="<< name << ")");
|
---|
[89] | 150 |
|
---|
[146] | 151 | if (!componentMap_.contains(name)) {
|
---|
[89] | 152 | LOG_WARN("cannot unregister component '" << name << "'. It was not registered");
|
---|
| 153 | return false;
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | // FIXME: delete component
|
---|
[146] | 157 | ComponentBase* component = componentMap_.value(name, NULL);
|
---|
| 158 | //delete component;
|
---|
| 159 |
|
---|
| 160 | // FIXME: remove from map (causes segfault in QMap::qMapLessThanKey on Windows)
|
---|
| 161 | //componentMap_.remove(name);
|
---|
[89] | 162 | LOG_INFO("unregistered component '" << name << "'");
|
---|
| 163 |
|
---|
| 164 | return true;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | bool ComponentManager::createComponent(const QString& type, const QString& name)
|
---|
| 168 | {
|
---|
| 169 | LOG_TRACE("createComponent(type=" << type << ", " << "name="<< name << ")");
|
---|
| 170 |
|
---|
[146] | 171 | if (factoryMap_.contains(type)) {
|
---|
| 172 | ComponentFactoryBase* factory = factoryMap_.value(type);
|
---|
| 173 | assert(factory);
|
---|
| 174 | factory->addComponent(name);
|
---|
[89] | 175 | return true;
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | LOG_WARN("cannot create component '" << name << "'"
|
---|
| 179 | << ". Component factory for type '" << type << "'"
|
---|
| 180 | << " does not exist or was not registered"
|
---|
| 181 | );
|
---|
| 182 | return false;
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | bool ComponentManager::loadPlugin(const QString& filename)
|
---|
| 186 | {
|
---|
| 187 | LOG_TRACE("loadPlugin(filename=" << filename << ")");
|
---|
| 188 |
|
---|
| 189 | pluginLoader_.setFileName(filename);
|
---|
| 190 |
|
---|
| 191 | if (!pluginLoader_.load()) {
|
---|
| 192 | LOG_ERROR("cannot load plugin '" << filename << "'"
|
---|
| 193 | << ". Plugin loader returned error: " << pluginLoader_.errorString()
|
---|
| 194 | );
|
---|
| 195 | return false;
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | QObject * plugin = pluginLoader_.instance();
|
---|
| 199 | if (NULL == plugin) {
|
---|
| 200 | LOG_WARN("cannot create an instance of the plugin '" << filename << "'"
|
---|
| 201 | << ". Plugin loader returned error: " << pluginLoader_.errorString()
|
---|
| 202 | );
|
---|
| 203 | return false;
|
---|
| 204 | }
|
---|
| 205 | pluginList_.append(plugin);
|
---|
| 206 | LOG_INFO("loaded plugin '" << qobject_cast<PacpusPluginInterface*>(plugin)->name() << "'"
|
---|
| 207 | << " from file '" << pluginLoader_.fileName() << "'"
|
---|
| 208 | );
|
---|
| 209 | return true;
|
---|
| 210 | }
|
---|
| 211 |
|
---|
[184] | 212 | bool ComponentManager::checkComponentConnection(const QString& componentName, const QString& connectionName)
|
---|
| 213 | {
|
---|
| 214 | if (NULL == getComponent(componentName)) {
|
---|
| 215 | LOG_WARN("cannot make connection : component " << componentName << " not found");
|
---|
| 216 | return false;
|
---|
| 217 | }
|
---|
| 218 | if (NULL == getComponent(componentName)->getOutput(connectionName)) {
|
---|
| 219 | LOG_WARN("cannot make connection : component " << componentName << " does not have input/output " << connectionName);
|
---|
| 220 | return false;
|
---|
| 221 | }
|
---|
| 222 | return true;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
[89] | 225 | bool ComponentManager::createConnection(const QString& outputSignature, const QString& inputSignature, const QString& type, int priority = 0)
|
---|
| 226 | {
|
---|
[184] | 227 | // FIXME: use 2 signatures (output component + output connection) instead of 1 separated by a (".") dot
|
---|
[89] | 228 | QStringList output = outputSignature.split(".");
|
---|
| 229 | QStringList input = inputSignature.split(".");
|
---|
| 230 |
|
---|
[184] | 231 | if (!checkComponentConnection(output[0], output[1])) {
|
---|
| 232 | return false;
|
---|
| 233 | }
|
---|
| 234 | if (!checkComponentConnection(input[0], input[1])) {
|
---|
| 235 | return false;
|
---|
| 236 | }
|
---|
[96] | 237 | // NOTE Create communicationInterface if needed ??
|
---|
[182] | 238 | return connectInterface(
|
---|
| 239 | getComponent(output[0])->getOutput(output[1]),
|
---|
| 240 | getComponent(input[0])->getInput(input[1]),
|
---|
| 241 | priority
|
---|
| 242 | );
|
---|
[89] | 243 | }
|
---|
| 244 |
|
---|
| 245 | std::size_t ComponentManager::loadComponents(const QString& configFilename)
|
---|
| 246 | {
|
---|
| 247 | LOG_TRACE("loadComponents(filename=" << configFilename << ")");
|
---|
| 248 |
|
---|
| 249 | // load the components tree in memory
|
---|
| 250 | xmlTree_->loadFile(configFilename);
|
---|
| 251 |
|
---|
| 252 | {
|
---|
| 253 | // Load the plugins containing the components
|
---|
[146] | 254 | QStringList plugins = xmlTree_->getAllPluginsNames();
|
---|
[89] | 255 | Q_FOREACH (QString plugin, plugins) {
|
---|
| 256 | if (!loadPlugin(plugin)) {
|
---|
| 257 | LOG_WARN("cannot load plugin '" << plugin << "'");
|
---|
[146] | 258 | } else {
|
---|
| 259 | LOG_INFO("successfully loaded plugin '" << plugin << "'");
|
---|
[89] | 260 | }
|
---|
| 261 | }
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | QDomNodeList componentsNodeList = xmlTree_->getAllComponents();
|
---|
| 265 | XmlComponentConfig cfg;
|
---|
| 266 |
|
---|
| 267 | // First, create all the components in the XML list
|
---|
| 268 | for (int i = 0; i < componentsNodeList.size(); ++i) {
|
---|
| 269 | cfg.localCopy(componentsNodeList.item(i).toElement());
|
---|
| 270 | QString componentType = cfg.getComponentType();
|
---|
| 271 | QString componentName = cfg.getComponentName();
|
---|
[110] | 272 | LOG_DEBUG("try to create component '" << componentName << "'");
|
---|
| 273 |
|
---|
[89] | 274 | // create the component and automatically add it to the component manager list
|
---|
| 275 | if (!createComponent(componentType, componentName)) {
|
---|
| 276 | LOG_ERROR("cannot create component '" << componentName << "'");
|
---|
| 277 | continue;
|
---|
| 278 | }
|
---|
| 279 | }
|
---|
| 280 |
|
---|
| 281 | int componentsToConfigureCount = componentMap_.count();
|
---|
| 282 |
|
---|
| 283 | // Second, try to configure the components without regarding the dependencies
|
---|
| 284 | for (int i = 0; i < componentsNodeList.size(); ++i) {
|
---|
| 285 | cfg.localCopy(componentsNodeList.item(i).toElement());
|
---|
| 286 | QString componentName = cfg.getComponentName();
|
---|
[110] | 287 | LOG_DEBUG("try to configure component '" << componentName << "'");
|
---|
[89] | 288 |
|
---|
| 289 | // copy locally the config parameters of the component
|
---|
| 290 | ComponentBase * component = getComponent(componentName);
|
---|
| 291 | if (NULL == component) {
|
---|
| 292 | LOG_WARN("component '" << componentName << "' does not exist");
|
---|
[201] | 293 | continue;
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 | component->param.localCopy(cfg.qDomElement());
|
---|
| 297 | try {
|
---|
[176] | 298 | component->parseParameters(cfg);
|
---|
[152] | 299 | component->setConfigurationState(component->configureComponent(cfg));
|
---|
[201] | 300 | } catch (PacpusException & e) {
|
---|
| 301 | LOG_ERROR("component '" << componentName << "' has thrown an exception");
|
---|
| 302 | LOG_ERROR(e.what());
|
---|
| 303 | component->setConfigurationState(ComponentBase::CONFIGURED_FAILED);
|
---|
[89] | 304 | }
|
---|
| 305 | } // for
|
---|
| 306 |
|
---|
| 307 | // Third, if some components requested a delayed configuration, retry
|
---|
[201] | 308 | for (int i = 0, iend = componentsNodeList.size(); i < iend; ++i) {
|
---|
[89] | 309 | cfg.localCopy(componentsNodeList.item(i).toElement());
|
---|
| 310 | QString componentName = cfg.getComponentName();
|
---|
| 311 |
|
---|
| 312 | ComponentBase * component = getComponent(componentName);
|
---|
| 313 | if (NULL == component) {
|
---|
| 314 | LOG_WARN("component '" << componentName << "' does not exist");
|
---|
[201] | 315 | continue;
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | // Pacpus 2.0 : add inputs and outputs
|
---|
| 319 | component->addInputs();
|
---|
| 320 | component->addOutputs();
|
---|
[120] | 321 |
|
---|
[201] | 322 | if (ComponentBase::CONFIGURATION_DELAYED == component->configurationState()) {
|
---|
| 323 | LOG_DEBUG("try to configure component '" << componentName << "'");
|
---|
[89] | 324 |
|
---|
[201] | 325 | // copy locally the config parameters of the component
|
---|
| 326 | component->param.localCopy(cfg.qDomElement());
|
---|
| 327 | component->setConfigurationState(component->configureComponent(cfg));
|
---|
| 328 | }
|
---|
[89] | 329 |
|
---|
[201] | 330 | if (ComponentBase::CONFIGURED_OK == component->configurationState()) {
|
---|
| 331 | --componentsToConfigureCount;
|
---|
| 332 | } else {
|
---|
| 333 | LOG_ERROR("cannot configure component '" << componentName << "'"
|
---|
| 334 | << ". Dependencies with other components are too complex"
|
---|
| 335 | << ". It was not configured, please review your configuration and/or your component"
|
---|
| 336 | );
|
---|
| 337 | component->setConfigurationState(ComponentBase::CONFIGURED_FAILED);
|
---|
[89] | 338 | }
|
---|
| 339 | } // for
|
---|
| 340 |
|
---|
| 341 | LOG_INFO(componentMap_.count() << " component(s) were loaded");
|
---|
| 342 | if (componentsToConfigureCount > 0) {
|
---|
| 343 | LOG_WARN(componentsToConfigureCount << " component(s) were not configured");
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 | // Fourthly, create connections find in the XML list
|
---|
| 347 | QDomNodeList connectionsNodeList = xmlTree_->getAllConnections();
|
---|
| 348 |
|
---|
[201] | 349 | for (int i = 0, iend = connectionsNodeList.size(); i < iend; ++i) {
|
---|
[89] | 350 | cfg.localCopy(connectionsNodeList.item(i).toElement());
|
---|
| 351 | QString connectionInput = cfg.getConnectionInput();
|
---|
| 352 | QString connectionOutput = cfg.getConnectionOutput();
|
---|
| 353 | QString connectionType = cfg.getConnectionType();
|
---|
| 354 | int connectionPriority = cfg.getConnectionPriority();
|
---|
| 355 |
|
---|
[120] | 356 | //TODO set connection mode from string
|
---|
| 357 |
|
---|
| 358 | //InputInterfaceBase::GetLast;
|
---|
| 359 | //InputInterfaceBase::NeverSkip;
|
---|
| 360 | //InputInterfaceBase::TimeBounded;
|
---|
| 361 |
|
---|
[89] | 362 | if (!createConnection(connectionOutput, connectionInput, connectionType,connectionPriority)) {
|
---|
| 363 | LOG_ERROR("cannot create connection '" << connectionOutput+"=>"+connectionInput << "'");
|
---|
| 364 | continue;
|
---|
| 365 | }
|
---|
[120] | 366 | } // for
|
---|
[89] | 367 |
|
---|
| 368 | return componentMap_.count();
|
---|
| 369 | }
|
---|
| 370 |
|
---|
| 371 | bool ComponentManager::start()
|
---|
| 372 | {
|
---|
| 373 | LOG_TRACE("start()");
|
---|
| 374 |
|
---|
| 375 | bool result = true;
|
---|
[146] | 376 | for (ComponentMap::iterator it = componentMap_.begin(), itend = componentMap_.end(); it != itend; ++it) {
|
---|
[89] | 377 | result &= start(it.key());
|
---|
[146] | 378 | }
|
---|
[89] | 379 |
|
---|
| 380 | return result;
|
---|
| 381 | }
|
---|
| 382 |
|
---|
[201] | 383 | bool ComponentManager::start(const QString & componentName)
|
---|
[89] | 384 | {
|
---|
| 385 | LOG_TRACE("start(component=" << componentName << ")");
|
---|
| 386 |
|
---|
| 387 | ComponentBase* component = getComponent(componentName);
|
---|
[153] | 388 | if (!component) {
|
---|
[89] | 389 | LOG_WARN("cannot start component '" << componentName << "'. It does not exist!");
|
---|
| 390 | return false;
|
---|
| 391 | }
|
---|
| 392 |
|
---|
[201] | 393 | if (ComponentBase::CONFIGURED_OK != component->configurationState()) {
|
---|
| 394 | LOG_WARN("cannot start component '" << componentName << "'. It has not been configured properly!");
|
---|
| 395 | return false;
|
---|
| 396 | }
|
---|
| 397 |
|
---|
[89] | 398 | LOG_INFO("starting component '" << componentName << "'...");
|
---|
[141] | 399 | if (!component->startComponent()) {
|
---|
[89] | 400 | LOG_WARN("cannot start component '" << componentName << "'. It can already be started");
|
---|
[141] | 401 | }
|
---|
[153] | 402 | LOG_INFO("successfully started component '" << componentName << "'");
|
---|
[89] | 403 | return true;
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 | bool ComponentManager::stop()
|
---|
| 407 | {
|
---|
| 408 | LOG_TRACE("stop()");
|
---|
| 409 |
|
---|
| 410 | bool result = true;
|
---|
[146] | 411 | for (ComponentMap::iterator it = componentMap_.begin(), itend = componentMap_.end(); it != itend; ++it) {
|
---|
| 412 | result &= stop(*it);
|
---|
| 413 | }
|
---|
[89] | 414 |
|
---|
| 415 | return result;
|
---|
| 416 | }
|
---|
| 417 |
|
---|
[201] | 418 | bool ComponentManager::stop(ComponentBase * component) const
|
---|
[146] | 419 | {
|
---|
| 420 | if (!component) {
|
---|
| 421 | LOG_WARN("NULL component pointer");
|
---|
| 422 | return false;
|
---|
| 423 | }
|
---|
| 424 | if (!component->stopComponent()) {
|
---|
| 425 | return false;
|
---|
| 426 | }
|
---|
| 427 | return true;
|
---|
| 428 | }
|
---|
| 429 |
|
---|
[201] | 430 | bool ComponentManager::stop(const QString & componentName)
|
---|
[89] | 431 | {
|
---|
| 432 | LOG_TRACE("stop(component=" << componentName << ")");
|
---|
| 433 |
|
---|
| 434 | ComponentBase* component = getComponent(componentName);
|
---|
[146] | 435 | if (!component) {
|
---|
[89] | 436 | LOG_WARN("cannot stop component '" << componentName << "'" << ". It does not exist");
|
---|
| 437 | return false;
|
---|
| 438 | }
|
---|
| 439 |
|
---|
| 440 | LOG_INFO("stopping component '" << componentName << "'...");
|
---|
[146] | 441 | if (!stop(component)) {
|
---|
[89] | 442 | LOG_WARN("cannot stop component '" << componentName << "'" << ". It can be already stopped");
|
---|
[141] | 443 | }
|
---|
[89] | 444 |
|
---|
| 445 | return true;
|
---|
| 446 | }
|
---|
| 447 |
|
---|
[201] | 448 | ComponentBase * ComponentManager::getComponent(const QString & name)
|
---|
[89] | 449 | {
|
---|
| 450 | LOG_TRACE("getComponent(name=" << name << ")");
|
---|
| 451 |
|
---|
| 452 | ComponentMap::iterator it = componentMap_.find(name);
|
---|
[141] | 453 | if (it != componentMap_.end()) {
|
---|
[89] | 454 | return *it;
|
---|
[141] | 455 | }
|
---|
[89] | 456 |
|
---|
| 457 | LOG_WARN("cannot retrieve component '" << name << "'" << ". It does not exist");
|
---|
| 458 | return NULL;
|
---|
| 459 | }
|
---|
| 460 |
|
---|
| 461 | QStringList ComponentManager::getAllComponentsName() const
|
---|
| 462 | {
|
---|
| 463 | LOG_TRACE("getAllComponentsName()");
|
---|
| 464 | return xmlTree_->getAllComponentsNames();
|
---|
| 465 | }
|
---|