Commit f09268e6 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

Rename ThreadData -> Statistics

parent 6b13e0ab
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ set(CMAKE_CXX_FLAGS "-pedantic -Wall -std=c++11 -Wextra -O3 -fopenmp")
add_executable(cppack
				src/core/Statsgen.cpp
				src/core/Policy.cpp
				src/core/ThreadData.cpp
				src/core/Statistics.cpp
				src/core/Utils.cpp
				src/cli/Main.cpp)
target_link_libraries(cppack ${CMAKE_THREAD_LIBS_INIT})
@@ -43,7 +43,7 @@ if(Qt5Core_FOUND)
	    src/gui/MainGui.cpp
	    src/core/Statsgen.cpp
	    src/core/Policy.cpp
	    src/core/ThreadData.cpp
	    src/core/Statistics.cpp
	    src/core/Utils.cpp
	    ressources/logos.qrc
	)
@@ -58,7 +58,7 @@ add_test(cppack-test bin/cppack-test)
add_executable(cppack-test
				src/core/Statsgen.cpp
				src/core/Policy.cpp
				src/core/ThreadData.cpp
				src/core/Statistics.cpp
				src/core/Utils.cpp
				src/test/cppack-tests.cpp)
target_link_libraries(cppack-test ${CMAKE_THREAD_LIBS_INIT})
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
#include <string>
#include <map>

#include "ThreadData.h"
#include "Statistics.h"
#include "SecurityRules.h"

class Policy {
+5 −5
Original line number Diff line number Diff line
@@ -33,10 +33,10 @@ struct minMax {
	uint maxspecial = 0;
};

struct ThreadData {
	ThreadData operator+(const ThreadData& other) const;
	void operator+=(const ThreadData& other);
	bool operator==(const ThreadData& other) const;
struct Statistics {
	Statistics operator+(const Statistics& other) const;
	void operator+=(const Statistics& other);
	bool operator==(const Statistics& other) const;
	int thread_id;
	std::string filename;
	uint64_t lineBegin = 0;
@@ -62,6 +62,6 @@ struct ThreadData {
	SecurityRules sr;
};

#pragma omp declare reduction(dataSum: ThreadData : omp_out += omp_in ) initializer(omp_priv(omp_orig))
#pragma omp declare reduction(dataSum: Statistics : omp_out += omp_in ) initializer(omp_priv(omp_orig))

#endif // THREAD_DATA_H
 No newline at end of file
+5 −5
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@

#include "Policy.h"
#include "SecurityRules.h"
#include "ThreadData.h"
#include "Statistics.h"


struct PasswordStats {
@@ -51,7 +51,7 @@ public:
	inline void setLimitSimplemask(const int& limit) { limitSimplemask = limit; }
	inline void setLimitAdvancedmask(const int& limit) { limitAdvancedmask = limit; }
	inline void setNbThread(const int& nb) { nbThread = nb; }
	void configureThread(ThreadData& td) const;
	void configureThread(Statistics& td) const;
	void setSecurityRules(const uint& length, const uint& special, const uint& digit, const uint& upper, const uint& lower);
	inline void setOutfile(const std::string& outfile) { outfile_name = outfile; }
	inline void enableDebug() { debug_enabled = true; }
@@ -59,7 +59,7 @@ public:
	inline int getNbThreads() const { return nbThread; }
	inline uint64_t getNbLines() const { return nblines; }
	inline uint64_t getProcessed() const { return processed; }
	inline const ThreadData& getResults() const { return results; }
	inline const Statistics& getResults() const { return results; }
	inline bool allFinished() const { return finished; }
	inline bool allStarted() const { return started; }
	bool operator==(const Statsgen& other) const;
@@ -67,7 +67,7 @@ public:
private:
	std::string filename;
	// results of the computation
	ThreadData results;
	Statistics results;

	// Filters
	int hiderare = 0; 				// Hide low statistics
@@ -93,7 +93,7 @@ private:
	// all threads have been started
	bool started = false;

	void handle_password(const std::string& password, const uint64_t& nbPasswords, ThreadData& td) const;
	void handle_password(const std::string& password, const uint64_t& nbPasswords, Statistics& td) const;
	std::pair<uint, uint> get_masks(const std::string& password, PasswordStats& c) const;
};

+5 −5
Original line number Diff line number Diff line
#include "ThreadData.h"
#include "Statistics.h"

#include <iostream>

@@ -26,12 +26,12 @@ bool minMax::operator==(const minMax& m) const {
	&& maxspecial == m.maxspecial;
}

void ThreadData::operator+=(const ThreadData& other){
void Statistics::operator+=(const Statistics& other){
	*this = *this + other;
}

ThreadData ThreadData::operator+(const ThreadData& other) const {
	ThreadData td(*this);
Statistics Statistics::operator+(const Statistics& other) const {
	Statistics td(*this);
	td.total_counter = total_counter + other.total_counter;
	td.total_filter = total_filter + other.total_filter;

@@ -58,7 +58,7 @@ ThreadData ThreadData::operator+(const ThreadData& other) const {
	return td;
}

bool ThreadData::operator==(const ThreadData& o) const {
bool Statistics::operator==(const Statistics& o) const {
	return total_counter == o.total_counter
	&& total_filter == o.total_filter
	&& sr.nbSecurePassword == o.sr.nbSecurePassword
Loading