Initial commit

This commit is contained in:
user
2026-07-12 14:22:00 +04:00
commit 49ecd4784c
90 changed files with 6910 additions and 0 deletions
@@ -0,0 +1,27 @@
#ifndef CREATOR_FUNCTION_FAMILY_H
#define CREATOR_FUNCTION_FAMILY_H
#include "../creatorAbstract.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Family)
class Creator : public Abstract::Creator
{
protected:
Creator()
{
}
public:
virtual const Product &create() const = 0;
};
END_NAMESPACE // Family
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // CREATOR_FUNCTION_FAMILY_H
@@ -0,0 +1,25 @@
#ifndef CREATOR_FUNCTION_FNV1a_H
#define CREATOR_FUNCTION_FNV1a_H
#include "fnv1a.h"
#include "creatorFamily.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(FNV1a)
class Creator : public Family::Creator
{
public:
virtual const Product &create() const override {
return Product::getInstance();
}
};
END_NAMESPACE // FNV1a
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !CREATOR_FUNCTION_FNV1a_H
@@ -0,0 +1,39 @@
#ifndef FUNCTION_FAMILY_H
#define FUNCTION_FAMILY_H
#include "../abstract.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Family)
using function_type = std::function<size_t(size_t, size_t)>;
class Product : public Abstract::Product
{
protected:
const function_type m_function;
protected:
Product(const function_type& function) : m_function(function)
{
}
public:
const function_type &to_std() const {
return m_function;
}
size_t getHash(size_t first, size_t second) const {
// First - the value that is hashed
// Second - coefficient
return m_function(first, second);
}
};
END_NAMESPACE // Family
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // FUNCTION_FAMILY_H
@@ -0,0 +1,40 @@
#ifndef FUNCTION_FNV1a_H
#define FUNCTION_FNV1a_H
#include "family.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(FNV1a)
using Singleton = BusinessLogic::Pattern::Singleton<Product>;
class Product final : public Family::Product, public Singleton
{
private:
const int32_t m_p;
private:
friend const Product &Singleton::getInstance();
Product()
: Family::Product(
[this](size_t value, size_t i) -> size_t {
size_t result = (0x811C9DC5 xor i) xor static_cast<int32_t>(value);
return static_cast<int32_t>(result * m_p);
}
)
, m_p(0x01000193)
{
}
public:
using Singleton::getInstance;
};
END_NAMESPACE // FNV1a
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !FUNCTION_FNV1a_H
@@ -0,0 +1,25 @@
#ifndef CREATOR_FUNCTION_EQUIVALENT_H
#define CREATOR_FUNCTION_EQUIVALENT_H
#include "creatorOne.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Equivalent)
class Creator : public One::Creator
{
public:
virtual const Product &create() const override {
return Product::getInstance();
}
};
END_NAMESPACE // Equivalent
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !CREATOR_FUNCTION_EQUIVALENT_H
@@ -0,0 +1,27 @@
#ifndef CREATOR_FUNCTION_ONE_H
#define CREATOR_FUNCTION_ONE_H
#include "../creatorAbstract.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(One)
class Creator : public Abstract::Creator
{
protected:
Creator()
{
}
public:
virtual const Product &create() const = 0;
};
END_NAMESPACE // One
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !CREATOR_FUNCTION_ONE_H
@@ -0,0 +1,24 @@
#ifndef CREATOR_FUNCTION_STANDART_H
#define CREATOR_FUNCTION_STANDART_H
#include "creatorOne.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Standart)
class Creator : public One::Creator
{
public:
virtual const Product &create() const override {
return Product::getInstance();
}
};
END_NAMESPACE // Standart
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !CREATOR_FUNCTION_FNV1a_H
@@ -0,0 +1,35 @@
#ifndef FUNCTION_EQUIVALENT_H
#define FUNCTION_EQUIVALENT_H
#include "one.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Equivalent)
using Singleton = BusinessLogic::Pattern::Singleton<Product>;
class Product final : public One::Product, public Singleton
{
private:
friend const Product &Singleton::getInstance();
Product() :
One::Product(
[](size_t value) -> size_t {
return value;
}
)
{
}
public:
using Singleton::getInstance;
};
END_NAMESPACE // Equivalent
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !FUNCTION_EQUIVALENT_H
@@ -0,0 +1,37 @@
#ifndef FUNCTION_ONE_H
#define FUNCTION_ONE_H
#include "../abstract.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(One)
using function_type = std::function<size_t(size_t)>;
class Product : public Abstract::Product
{
protected:
const function_type m_function;
protected:
Product(const function_type& function) : m_function(function)
{
}
public:
const function_type& to_std() const {
return m_function;
}
size_t getHash(size_t value) const {
return m_function(value);
}
};
END_NAMESPACE // One
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !FUNCTION_ONE_H
@@ -0,0 +1,37 @@
#ifndef FUNCTION_STANDART_H
#define FUNCTION_STANDART_H
#include "one.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Standart)
using Singleton = BusinessLogic::Pattern::Singleton<Product>;
class Product final : public One::Product, public Singleton
{
private:
std::hash<size_t> m_standartHashFunction;
private:
friend const Product &Singleton::getInstance();
Product()
: One::Product(
std::bind(&std::hash<size_t>::operator(), &m_standartHashFunction, std::placeholders::_1)
)
, m_standartHashFunction()
{
}
public:
using Singleton::getInstance;
};
END_NAMESPACE // Standart
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !FUNCTION_FNV1a_H
@@ -0,0 +1,36 @@
#ifndef CREATOR_ADAPTER_FAMILY_TO_ONE_H
#define CREATOR_ADAPTER_FAMILY_TO_ONE_H
#include "familyToOne.h"
#include "../One/creatorOne.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Pattern)
BEGIN_NAMESPACE(FamilyToOne)
class Creator final : public One::Creator
{
private:
Product m_product; // To support the interface
public:
Creator(std::shared_ptr<Family::Creator> adaptee, size_t coefficient)
: m_product(adaptee->create(), coefficient)
{
}
public:
virtual const Product &create() const override {
return m_product;
}
};
END_NAMESPACE // FamilyToOne
END_NAMESPACE // Pattern
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !CREATOR_ADAPTER_FAMILY_TO_ONE_H
@@ -0,0 +1,30 @@
#ifndef ADAPTER_FAMILY_TO_ONE_H
#define ADAPTER_FAMILY_TO_ONE_H
#include "../Family/family.h"
#include "../One/one.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Pattern)
BEGIN_NAMESPACE(FamilyToOne)
class Product final : public One::Product
{
public:
Product(const Family::Product &adaptee, size_t coefficient)
: One::Product(
std::bind(adaptee.to_std(), std::placeholders::_1, coefficient)
)
{
}
};
END_NAMESPACE // FamilyToOne
END_NAMESPACE // Pattern
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !ADAPTER_FAMILY_TO_ONE_H
@@ -0,0 +1,30 @@
#ifndef FUNCTION_ABSTRACT_H
#define FUNCTION_ABSTRACT_H
#include "../../businessLogic.h"
#include "../../Pattern/singleton.h"
#include <memory>
#include <functional>
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Abstract)
class Product
{
protected:
Product()
{
}
/* With the virtual destructor, the compiler considers this class to be polymorphic */
virtual ~Product() = default;
};
END_NAMESPACE // Abstract
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !FUNCTION_ABSTRACT_H
@@ -0,0 +1,27 @@
#ifndef CREATOR_FUNCTION_ABSTRACT_H
#define CREATOR_FUNCTION_ABSTRACT_H
#include "../../businessLogic.h"
BEGIN_NAMESPACE(BusinessLogic)
BEGIN_NAMESPACE(Hash)
BEGIN_NAMESPACE(Function)
BEGIN_NAMESPACE(Abstract)
class Creator
{
protected:
Creator()
{
}
public:
virtual const Product &create() const = 0;
};
END_NAMESPACE // Abstract
END_NAMESPACE // Function
END_NAMESPACE // Hash
END_NAMESPACE // BusinessLogic
#endif // !CREATOR_FUNCTION_ABSTRACT_H