Index: trunk/src/PacpusLib/ComponentManager.cpp
===================================================================
--- trunk/src/PacpusLib/ComponentManager.cpp	(revision 31)
+++ trunk/src/PacpusLib/ComponentManager.cpp	(revision 47)
@@ -28,9 +28,12 @@
     LOG_TRACE("getInstance()");
     LOG_TRACE("before:  mInstance = " << mInstance);
-    if (NULL == mInstance) {
+
+    if (!mInstance)
+    {
         LOG_INFO("creating new instance...");
         mInstance = new ComponentManager();
         LOG_DEBUG("mInstance = " << mInstance);
     }
+
     LOG_TRACE("after:   mInstance = " << mInstance);
     return mInstance;
@@ -58,7 +61,7 @@
 
     QMutableMapIterator<ComponentMap::key_type, ComponentMap::mapped_type> it(componentMap_);
-    while (it.hasNext()) {
+    while (it.hasNext())
         unRegisterComponent(it.next().key());
-    }
+
     LOG_DEBUG("component manager was deleted");
 }
@@ -68,14 +71,13 @@
     LOG_TRACE("registerComponentFactory(type="<< type << ")");
 
-    if (factoryMap_.contains(type)) {
-        LOG_WARN("cannot register a component factory of type '" << type << "'"
-                 << ". It already belongs to the manager"
-                 );
+    if (factoryMap_.contains(type))
+    {
+        LOG_WARN("cannot register a component factory of type '" << type << "'. It already belongs to the manager");
         return false;
     }
 
     factoryMap_[type] = addr;
-    LOG_INFO("registered component factory '" << type << "'"
-             );
+    LOG_INFO("registered component factory '" << type << "'");
+
     return true;
 }
@@ -85,13 +87,13 @@
     LOG_TRACE("unRegisterComponentFactory(type="<< type << ")");
 
-    if (!factoryMap_.contains(type)) {
-        LOG_WARN("cannot unregister component factory '" << type << "'"
-                 << ". It was not registered"
-                 );
-        return false;
-    }
+    if (!factoryMap_.contains(type))
+    {
+        LOG_WARN("cannot unregister component factory '" << type << "'. It was not registered");
+        return false;
+    }
+
     factoryMap_.remove(type);
-    LOG_INFO("unregistered component factory '" << type << "'"
-             );
+    LOG_INFO("unregistered component factory '" << type << "'");
+
     return true;
 }
@@ -101,13 +103,13 @@
     LOG_TRACE("registerComponent(name="<< name << ")");
 
-    if (componentMap_.contains(name)) {
-        LOG_WARN("cannot register component '" << name << "'"
-                 << ". A component with the same name exists already"
-                 );
-        return false;
-    }
+    if (componentMap_.contains(name))
+    {
+        LOG_WARN("cannot register component '" << name << "'. A component with the same name exists already");
+        return false;
+    }
+
     componentMap_[name] = addr;
-    LOG_INFO("registered component " << name
-             );
+    LOG_INFO("registered component " << name);
+
     return true;
 }
@@ -117,15 +119,15 @@
     LOG_TRACE("unRegisterComponent(name="<< name << ")");
 
-    if (!componentMap_.contains(name)) {
-        LOG_WARN("cannot unregister component '" << name << "'"
-                 << ". It was not registered"
-                 );
-        return false;
-    }
+    if (!componentMap_.contains(name))
+    {
+        LOG_WARN("cannot unregister component '" << name << "'. It was not registered");
+        return false;
+    }
+
     // FIXME: delete component
     //delete componentMap_[name];
     componentMap_.remove(name);
-    LOG_INFO("unregistered component '" << name << "'"
-             );
+    LOG_INFO("unregistered component '" << name << "'");
+
     return true;
 }
@@ -135,8 +137,11 @@
     LOG_TRACE("createComponent(type=" << type << ", " << "name="<< name << ")");
 
-    if (factoryMap_.contains(type)) {
-        factoryMap_[type]->addComponent(name);
-        return true;
-    }
+    FactoryMap::iterator it = factoryMap_.find(type);
+    if (it != factoryMap_.end())
+    {
+      (*it)->addComponent(name);
+      return true;
+    }
+
     LOG_WARN("cannot create component '" << name << "'"
              << ". Component factory for type '" << type << "'"
@@ -178,5 +183,5 @@
 
     // load the components tree in memory
-    /*int loadedComponentsCount = */xmlTree_->loadFile(configFilename);
+    xmlTree_->loadFile(configFilename);
 
     {
@@ -264,65 +269,59 @@
 }
 
-int ComponentManager::start()
+bool ComponentManager::start()
 {
     LOG_TRACE("start()");
 
     bool result = true;
-    for (ComponentMap::iterator it = componentMap_.begin(), itend = componentMap_.end(); it != itend; ++it ) {
-        result &= (0 < start(it.key()));
-    }
+    for (ComponentMap::iterator it = componentMap_.begin(), itend = componentMap_.end(); it != itend; ++it )
+        result &= start(it.key());
+
     return result;
 }
 
-int ComponentManager::start(const QString& componentName)
+bool ComponentManager::start(const QString& componentName)
 {
     LOG_TRACE("start(component=" << componentName << ")");
 
-    ComponentBase * component = getComponent(componentName);
-    if (NULL == component) {
-        LOG_WARN("cannot start component '" << componentName << "'"
-                 << ".  It does not exist!"
-                 );
+    ComponentBase* component = getComponent(componentName);
+    if (!component)
+    {
+        LOG_WARN("cannot start component '" << componentName << "'.  It does not exist!");
         return false;
     }
 
     LOG_INFO("starting component '" << componentName << "'...");
-    if (!component->startComponent()) {
-        LOG_WARN("cannot start component '" << componentName << "'"
-                 ". It can already be started"
-                 );
-    }
-    return true;
-}
-
-int ComponentManager::stop()
+    if (!component->startComponent())
+        LOG_WARN("cannot start component '" << componentName << "'. It can already be started");
+
+    return true;
+}
+
+bool ComponentManager::stop()
 {
     LOG_TRACE("stop()");
 
     bool result = true;
-    for (ComponentMap::iterator it = componentMap_.begin(); it != componentMap_.end(); ++it) {
-        result &= (0 < stop(it.key()));
-    }
+    for (ComponentMap::iterator it = componentMap_.begin(); it != componentMap_.end(); ++it)
+        result &= stop(it.key());
+
     return result;
 }
 
-int ComponentManager::stop(const QString& componentName)
+bool ComponentManager::stop(const QString& componentName)
 {
     LOG_TRACE("stop(component=" << componentName << ")");
 
-    ComponentBase * component = getComponent(componentName);
-    if (NULL == component) {
-        LOG_WARN("cannot stop component '" << componentName << "'"
-                 << ". It does not exist"
-                 );
+    ComponentBase* component = getComponent(componentName);
+    if (!component)
+    {
+        LOG_WARN("cannot stop component '" << componentName << "'" << ". It does not exist");
         return false;
     }
 
     LOG_INFO("stopping component '" << componentName << "'...");
-    if (!component->stopComponent()) {
-        LOG_WARN("cannot stop component '" << componentName << "'"
-                 << ". It can be already stopped"
-                 );
-    }
+    if (!component->stopComponent())
+        LOG_WARN("cannot stop component '" << componentName << "'" << ". It can be already stopped");
+
     return true;
 }
@@ -332,17 +331,15 @@
     LOG_TRACE("getComponent(name=" << name << ")");
 
-    if (!componentMap_.contains(name)) {
-        LOG_WARN("cannot retrieve component '" << name << "'"
-                 << ". It does not exist"
-                 );
-        return NULL;
-    }
-	return componentMap_[name];
-}
-
-QStringList ComponentManager::getAllComponentsName()
+    ComponentMap::iterator it = componentMap_.find(name);
+    if (it != componentMap_.end())
+      return *it;
+
+    LOG_WARN("cannot retrieve component '" << name << "'" << ". It does not exist");
+    return NULL;
+}
+
+QStringList ComponentManager::getAllComponentsName() const
 {
     LOG_TRACE("getAllComponentsName()");
-
     return xmlTree_->getAllComponents();
 }
