Commits

Frederic De Groef committed 6ab7e56

using utility::toString() in MaterialConverter for logging

Comments (0)

Files changed (2)

cologre-ng/include/MaterialConverter.h

 #include "ResourceConverter.h"
 #include <dom/domProfile_COMMON.h>
 
+#include <string>
 #include <Ogre.h>
 #include "common.h"
 
 
 protected:
     PathBasename _getPathBasenameFromUri(xsAnyURI _uri);
-
+    void _logMessage(const std::string &_msg) { m_pLog->logMessage(_msg);};
+    
 
 
 protected:

cologre-ng/src/MaterialConverter.cpp

 //-----------------------------------------------------------------------------
 int CMaterialConverter::convert(daeDatabase* pDatabase)
 {
-    m_pLog->logMessage("Converting materials");
-    m_pLog->logMessage("-------------------------------------------------");
+    _logMessage("Converting materials");
+    _logMessage("-------------------------------------------------");
 
 
     unsigned int numElements = pDatabase->getElementCount(NULL, "material", NULL);
         }
     }
 
-    m_pLog->logMessage("\n\n\n");
+    _logMessage("\n\n\n");
 
     return 0;
 }
         pNewparam = daeSafeCast<domCommon_newparam_type>(&(*elemRef));
     else
     {
-        std::stringstream s;
-        s << "Could not resolve to sampler2d for texture " << strTarget;
-        m_pLog->logMessage(s.str());
+        _logMessage(cologreng::utility::toString("Could not resolve to sampler2d for texture ", strTarget));
         return;
     }
 
         pNewparam = daeSafeCast<domCommon_newparam_type>(&(*elemRef));
     else
     {
-        std::stringstream s;
-        s << "Could not resolve to surface for sampler2d " << strTarget ;
-        m_pLog->logMessage(s.str());
+        _logMessage(cologreng::utility::toString("Could not resolve to surface for sampler2d ", strTarget));
         return;
     }
 
 
                 if(m_spLocations->find(pathBasename.first) == m_spLocations->end())
                 {
-                    std::stringstream s;
-                    s << "Adding location " << pathBasename.first << " to global resource manager";
-                    m_pLog->logMessage(s.str());
-
+                    _logMessage(cologreng::utility::toString("Adding location ", pathBasename.first, " to global resource manager"));
                     Ogre::ResourceGroupManager::getSingleton().addResourceLocation(pathBasename.first, "FileSystem", "DaeCustom");
                 }
                 else                
                 {
-                    std::stringstream s;
-                    s << "Location " << pathBasename.first << " already added to resource manager";
-                    m_pLog->logMessage(s.str());
+                    _logMessage(cologreng::utility::toString("Location ", pathBasename.first, " already added to resource manager"));
                 }
-
-                std::stringstream s;
-                s << "Loading 2D image : " << pathBasename.second;
-                m_pLog->logMessage(s.str());
-
+                    
+                _logMessage(cologreng::utility::toString("Loading 2D image : ", pathBasename.second));
 
                 pOgreTexture = Ogre::TextureManager::getSingleton().load(pathBasename.second, "DaeCustom", Ogre::TEX_TYPE_2D);
                 pOgreTextureUnitState = pOgrePass->createTextureUnitState(pathBasename.second, 0);
 
     return PathBasename(path, basename);
 }
-//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------