ExaTN
tensor_op_factory.hpp
1 
11 #ifndef EXATN_NUMERICS_TENSOR_OP_FACTORY_HPP_
12 #define EXATN_NUMERICS_TENSOR_OP_FACTORY_HPP_
13 
14 #include "tensor_basic.hpp"
15 #include "tensor_operation.hpp"
16 #include "tensor_op_create.hpp"
17 #include "tensor_op_destroy.hpp"
18 #include "tensor_op_transform.hpp"
19 #include "tensor_op_add.hpp"
20 #include "tensor_op_contract.hpp"
21 
22 #include <memory>
23 #include <map>
24 
25 namespace exatn{
26 
27 namespace numerics{
28 
30 public:
31 
32  TensorOpFactory(const TensorOpFactory &) = delete;
33  TensorOpFactory & operator=(const TensorOpFactory &) = delete;
34  TensorOpFactory(TensorOpFactory &&) noexcept = default;
35  TensorOpFactory & operator=(TensorOpFactory &&) noexcept = default;
36  ~TensorOpFactory() = default;
37 
39  void registerTensorOp(TensorOpCode opcode, createTensorOpFn creator);
40 
42  std::unique_ptr<TensorOperation> createTensorOp(TensorOpCode opcode);
44  std::shared_ptr<TensorOperation> createTensorOpShared(TensorOpCode opcode);
45 
47  static TensorOpFactory * get();
48 
49 private:
50 
51  TensorOpFactory(); //private ctor
52 
53  std::map<TensorOpCode,createTensorOpFn> factory_map_;
54 
55 };
56 
57 } //namespace numerics
58 
59 } //namespace exatn
60 
61 #endif //EXATN_NUMERICS_TENSOR_OP_FACTORY_HPP_
exatn::numerics::TensorOpFactory::createTensorOp
std::unique_ptr< TensorOperation > createTensorOp(TensorOpCode opcode)
Definition: tensor_op_factory.cpp:28
exatn
Definition: DriverClient.hpp:10
exatn::numerics::TensorOpFactory::createTensorOpShared
std::shared_ptr< TensorOperation > createTensorOpShared(TensorOpCode opcode)
Definition: tensor_op_factory.cpp:35
exatn::numerics::TensorOpFactory::registerTensorOp
void registerTensorOp(TensorOpCode opcode, createTensorOpFn creator)
Definition: tensor_op_factory.cpp:22
exatn::numerics::TensorOpFactory
Definition: tensor_op_factory.hpp:29
exatn::numerics::TensorOpFactory::get
static TensorOpFactory * get()
Definition: tensor_op_factory.cpp:40