Initial commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#ifndef FACTORY_ABSTRACT_H
|
||||
#define FACTORY_ABSTRACT_H
|
||||
|
||||
#include "../Function/abstract.h"
|
||||
#include "../Algorithm/abstract.h"
|
||||
|
||||
BEGIN_NAMESPACE(BusinessLogic)
|
||||
BEGIN_NAMESPACE(Hash)
|
||||
BEGIN_NAMESPACE(Factory)
|
||||
|
||||
class Abstract
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* I used to use a constant link. This led to UB.
|
||||
*
|
||||
* https://eel.is/c++draft/class.temporary#6 (27.10.2021)
|
||||
*
|
||||
* The exceptions to this lifetime rule are:
|
||||
* (6.9) A temporary object bound to a reference parameter in a function call ([expr.call]) persists until the completion of the full-expression containing the call.
|
||||
*/
|
||||
using AFC_type = std::shared_ptr<Function::Abstract::Creator>;
|
||||
using AAC_type = std::shared_ptr<Algorithm::Abstract::Creator>;
|
||||
|
||||
protected:
|
||||
AFC_type m_functionCreator;
|
||||
AAC_type m_algorithmCreator;
|
||||
|
||||
protected:
|
||||
Abstract(AFC_type functionCreator, AAC_type algorithmCreator)
|
||||
: m_functionCreator(functionCreator), m_algorithmCreator(algorithmCreator)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
using AFP_type = Function::Abstract::Product;
|
||||
using AAP_type = Algorithm::Abstract::Product;
|
||||
|
||||
public:
|
||||
virtual const AFP_type &getFunction() const = 0;
|
||||
virtual std::unique_ptr<AAP_type> getAlgorithm() const = 0;
|
||||
};
|
||||
|
||||
END_NAMESPACE // Factory
|
||||
END_NAMESPACE // Hash
|
||||
END_NAMESPACE // BusinessLogic
|
||||
|
||||
#endif // !FACTORY_ABSTRACT_H
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef FACTORY_FAMILY_H
|
||||
#define FACTORY_FAMILY_H
|
||||
|
||||
#include "../Factory/abstract.h"
|
||||
|
||||
#include "../Function/Family/family.h"
|
||||
#include "../Function/Family/creatorFamily.h"
|
||||
|
||||
#include "../Algorithm/Family/family.h"
|
||||
#include "../Algorithm/Family/creatorFamily.h"
|
||||
|
||||
BEGIN_NAMESPACE(BusinessLogic)
|
||||
BEGIN_NAMESPACE(Hash)
|
||||
BEGIN_NAMESPACE(Factory)
|
||||
|
||||
class Family final : public Abstract
|
||||
{
|
||||
public:
|
||||
using FFC_type = std::shared_ptr<Function::Family::Creator>;
|
||||
using FAC_type = std::shared_ptr<Algorithm::Family::Creator>;
|
||||
|
||||
using FFP_type = Function::Family::Product;
|
||||
using FAP_type = Algorithm::Family::Product;
|
||||
|
||||
public:
|
||||
Family(const FFC_type functionCreator, const FAC_type algorithmCreator)
|
||||
: Abstract(functionCreator, algorithmCreator)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual const FFP_type &getFunction() const override {
|
||||
return dynamic_cast<const FFP_type &>(m_functionCreator->create());
|
||||
}
|
||||
virtual std::unique_ptr<AAP_type> getAlgorithm() const override {
|
||||
std::unique_ptr<AAP_type> algorithm = m_algorithmCreator->create();
|
||||
dynamic_cast<FAP_type *>(algorithm.get())->setHashFunction(getFunction());
|
||||
return algorithm;
|
||||
}
|
||||
};
|
||||
|
||||
END_NAMESPACE // Factory
|
||||
END_NAMESPACE // Hash
|
||||
END_NAMESPACE // BusinessLogic
|
||||
|
||||
#endif // !FACTORY_FAMILY_H
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef FACTORY_ONE_H
|
||||
#define FACTORY_ONE_H
|
||||
|
||||
#include "../Factory/abstract.h"
|
||||
|
||||
#include "../Function/One/one.h"
|
||||
#include "../Function/One/creatorOne.h"
|
||||
|
||||
#include "../Algorithm/One/one.h"
|
||||
#include "../Algorithm/One/creatorOne.h"
|
||||
|
||||
BEGIN_NAMESPACE(BusinessLogic)
|
||||
BEGIN_NAMESPACE(Hash)
|
||||
BEGIN_NAMESPACE(Factory)
|
||||
|
||||
class One final : public Abstract
|
||||
{
|
||||
public:
|
||||
using OFC_type = std::shared_ptr<Function::One::Creator>;
|
||||
using OAC_type = std::shared_ptr<Algorithm::One::Creator>;
|
||||
|
||||
using OFP_type = Function::One::Product;
|
||||
using OAP_type = Algorithm::One::Product;
|
||||
|
||||
public:
|
||||
One(OFC_type functionCreator, OAC_type algorithmCreator)
|
||||
: Abstract(functionCreator, algorithmCreator)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual const OFP_type &getFunction() const override {
|
||||
return dynamic_cast<const OFP_type &>(m_functionCreator->create());
|
||||
}
|
||||
virtual std::unique_ptr<AAP_type> getAlgorithm() const override {
|
||||
std::unique_ptr<AAP_type> algorithm = m_algorithmCreator->create();
|
||||
dynamic_cast<OAP_type *>(algorithm.get())->setHashFunction(getFunction());
|
||||
return algorithm;
|
||||
}
|
||||
};
|
||||
|
||||
END_NAMESPACE // Factory
|
||||
END_NAMESPACE // Hash
|
||||
END_NAMESPACE // BusinessLogic
|
||||
|
||||
#endif // !FACTORY_ONE_H
|
||||
Reference in New Issue
Block a user