Skip to content
Permalink
Browse files

additional macro for logger, more std::cout cleans

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5177 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Apr 5, 2006
1 parent 30d4b24 commit df6922e4f7ce56bc727c9b48241e2b7c377424af
Showing with 110 additions and 192 deletions.
  1. +6 −3 src/core/qgslogger.h
  2. +11 −32 src/gui/qgsmaplayerregistry.cpp
  3. +56 −95 src/gui/qgsspatialrefsys.cpp
  4. +37 −62 src/gui/qgsvectorlayer.cpp
@@ -15,17 +15,20 @@
* *
***************************************************************************/

#ifndef QGSLOGGER
#define QGSLOGGER
#ifndef QGSLOGGER_H
#define QGSLOGGER_H

#include <iostream>
#include <sstream>
#include <QString>

#ifdef QGISDEBUG
#define QgsDebugMsg(str) QgsLogger::debug(QString(str), 1, __FILE__, __FUNCTION__, __LINE__);
#define QgsDebugMsgLevel(str, level) QgsLogger::debug(QString(str), level,\
__FILE__, __FUNCTION__, __LINE__);
#else
#define QgsDebugMsg(str)
#define QgsDebugMsg(str)
#define QgsDebugMsgVal(str, val, level)
#endif

/**QgsLogger is a class to print debug/warning/error messages to the console. The advantage of this class over std::cout, std::cerr & co. is that the output can be controlled with environment variables:
@@ -19,6 +19,7 @@
#include <iostream>

#include "qgsmaplayerregistry.h"
#include "qgslogger.h"
#include "qgsproject.h"


@@ -41,9 +42,7 @@ QgsMapLayerRegistry *QgsMapLayerRegistry::instance()

QgsMapLayerRegistry::QgsMapLayerRegistry(QObject *parent, const char *name) : QObject(parent,name)
{
#ifdef QGISDEBUG
std::cout << "QgsMapLayerRegistry created!" << std::endl;
#endif
QgsDebugMsg("QgsMapLayerRegistry created!");
// constructor does nothing
}
// get the layer count (number of registered layers)
@@ -93,9 +92,7 @@ QgsMapLayer * QgsMapLayerRegistry::mapLayer(QString theLayerId)
QgsMapLayer *
QgsMapLayerRegistry::addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal )
{
#ifdef QGISDEBUG
std::cout << "QgsMapLayerRegistry::addMaplayer - '" << theMapLayer->name().toLocal8Bit().data() << "'."<< std::endl;
#endif
QgsDebugMsg("QgsMapLayerRegistry::addMaplayer - '" + theMapLayer->name());
//check the layer is not already registered!
std::map<QString,QgsMapLayer*>::iterator myIterator = mMapLayers.find(theMapLayer->getLayerID());
//if myIterator returns mMapLayers.end() then it does not exist in registry and its safe to add it
@@ -113,10 +110,7 @@ QgsMapLayer *
}
else
{

#ifdef QGISDEBUG
std::cout << "addMaplayer - " << theMapLayer->name().toLocal8Bit().data() << " already registered" << std::endl;
#endif
QgsDebugMsg("addMaplayer - " + theMapLayer->name() + " already registered");
return 0x0;
}
} // QgsMapLayerRegistry::addMapLayer
@@ -125,31 +119,21 @@ QgsMapLayer *

void QgsMapLayerRegistry::removeMapLayer(QString theLayerId, bool theEmitSignal)
{
#ifdef QGISDEBUG
std::cout << "QgsMapLayerRegistry::removemaplayer - emitting signal to notify all users of this layer to release it." << std::endl;
#endif
QgsDebugMsg("QgsMapLayerRegistry::removemaplayer - emitting signal to notify all users of this layer to release it.");
if (theEmitSignal)
emit layerWillBeRemoved(theLayerId);
#ifdef QGISDEBUG
std::cout << "QgsMapLayerRegistry::removemaplayer - deleting map layer." << std::endl;
#endif
QgsDebugMsg("QgsMapLayerRegistry::removemaplayer - deleting map layer.");
delete mMapLayers[theLayerId];
#ifdef QGISDEBUG
std::cout << "QgsMapLayerRegistry::removemaplayer - unregistering map layer." << std::endl;
#endif
QgsDebugMsg("QgsMapLayerRegistry::removemaplayer - unregistering map layer.");
mMapLayers.erase(theLayerId);
#ifdef QGISDEBUG
std::cout << "QgsMapLayerRegistry::removemaplayer - operation complete." << std::endl;
#endif
QgsDebugMsg("QgsMapLayerRegistry::removemaplayer - operation complete.");
// notify the project we've made a change
QgsProject::instance()->dirty(true);
}

void QgsMapLayerRegistry::removeAllMapLayers()
{
#ifdef QGISDEBUG
std::cout << "QgsMapLayerRegistry::removeAllMapLayers"<< std::endl;
#endif
QgsDebugMsg("QgsMapLayerRegistry::removeAllMapLayers");

// moved before physically removing the layers
emit removedAll(); // now let all canvas Observers know to clear
@@ -175,18 +159,13 @@ void QgsMapLayerRegistry::removeAllMapLayers()

std::map<QString,QgsMapLayer*> & QgsMapLayerRegistry::mapLayers()
{
#ifdef QGISDEBUG
std::cout << "QgsMapLayerRegistry::mapLayers"<< std::endl;
#endif

QgsDebugMsg("QgsMapLayerRegistry::mapLayers");
return mMapLayers;
}



void QgsMapLayerRegistry::connectNotify( const char * signal )
{
#ifdef QGISDEBUG
std::cerr << "QgsMapLayerRegistry connected to " << signal << "\n";
#endif
QgsDebugMsg("QgsMapLayerRegistry connected to " + QString(signal));
} // QgsMapLayerRegistry::connectNotify

0 comments on commit df6922e

Please sign in to comment.
You can’t perform that action at this time.