refactoring

This commit is contained in:
Daniel Marjamäki 2009-03-20 17:15:51 +01:00
parent a1759a3574
commit e6e778e45f
3 changed files with 24 additions and 13 deletions

View File

@ -20,10 +20,10 @@
#ifndef checkH
#define checkH
#include "settings.h"
#include <list>
class Tokenizer;
class Settings;
class ErrorLogger;
class Check
@ -31,10 +31,16 @@ class Check
public:
// This constructor is used when registering the CheckClass
Check()
: _tokenizer(0), _settings(0), _errorLogger(0)
{
instances().push_back(this);
}
// This constructor is used when running checks..
Check(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: _tokenizer(tokenizer), _settings(settings), _errorLogger(errorLogger)
{ }
virtual ~Check()
{
instances().remove(this);
@ -49,6 +55,11 @@ public:
/** run checks.. */
virtual void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) = 0;
protected:
const Tokenizer * const _tokenizer;
const Settings * const _settings;
ErrorLogger * const _errorLogger;
};
#endif

View File

@ -25,7 +25,7 @@
// Register this check class (by creating a static instance of it)
namespace
{
CheckStl instance;
CheckStl instance;
}
void CheckStl::iterators()

View File

@ -30,17 +30,21 @@ class Token;
class CheckStl : public Check
{
public:
CheckStl() : Check()
{ }
CheckStl(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(tokenizer, settings, errorLogger)
{ }
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
{
_tokenizer = tokenizer;
_settings = settings;
_errorLogger = errorLogger;
CheckStl checkStl(tokenizer, settings, errorLogger);
stlOutOfBounds();
iterators();
erase();
pushback();
checkStl.stlOutOfBounds();
checkStl.iterators();
checkStl.erase();
checkStl.pushback();
}
@ -74,10 +78,6 @@ private:
* @param it iterator token
*/
void eraseCheckLoop(const Token *it);
const Tokenizer *_tokenizer;
const Settings *_settings;
ErrorLogger *_errorLogger;
};
//---------------------------------------------------------------------------