refactoring
This commit is contained in:
parent
a1759a3574
commit
e6e778e45f
13
src/check.h
13
src/check.h
|
@ -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
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
// Register this check class (by creating a static instance of it)
|
||||
namespace
|
||||
{
|
||||
CheckStl instance;
|
||||
CheckStl instance;
|
||||
}
|
||||
|
||||
void CheckStl::iterators()
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue