-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperandFactory.cpp
More file actions
56 lines (46 loc) · 2.1 KB
/
Copy pathOperandFactory.cpp
File metadata and controls
56 lines (46 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* OperandFactory.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yfarini <yfarini@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/09 12:47:46 by yfarini #+# #+# */
/* Updated: 2023/01/10 16:26:02 by yfarini ### ########.fr */
/* */
/* ************************************************************************** */
#include "OperandFactory.hpp"
#include "Operand.hpp"
OperandFactory& OperandFactory::operator=(const OperandFactory&)
{
return *this;
}
IOperand const * OperandFactory::createOperand( eOperandType type, std::string const & value ) const {
member_factory_function_t mb_methods[] {
&OperandFactory::createInt8,
&OperandFactory::createInt16,
&OperandFactory::createInt32,
&OperandFactory::createFloat,
&OperandFactory::createDouble
};
return (this->*mb_methods[type])(value);
}
IOperand const * OperandFactory::createInt8( std::string const & value ) const {
return new Operand<int8_t>(value);
}
IOperand const * OperandFactory::createInt16( std::string const & value ) const {
return new Operand<int16_t>(value);
}
IOperand const * OperandFactory::createInt32( std::string const & value ) const {
return new Operand<int32_t>(value);
}
IOperand const * OperandFactory::createFloat( std::string const & value ) const {
return new Operand<float>(value);
}
IOperand const * OperandFactory::createDouble( std::string const & value ) const {
return new Operand<double>(value);
}
const OperandFactory& get_facory() {
static const OperandFactory factory;
return factory;
}