Commit edc81eed authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh
Browse files

Updated TensorOpFactory to return unique_ptr.

parent ff19ab63
/** ExaTN::Numerics: Register of vector spaces and their subspaces
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -39,7 +39,7 @@ public:
SubspaceRegEntry & operator=(const SubspaceRegEntry &) = default;
SubspaceRegEntry(SubspaceRegEntry &&) noexcept = default;
SubspaceRegEntry & operator=(SubspaceRegEntry &&) noexcept = default;
virtual ~SubspaceRegEntry() = default;
~SubspaceRegEntry() = default;
friend class SubspaceRegister;
......@@ -58,7 +58,7 @@ public:
SubspaceRegister & operator=(const SubspaceRegister &) = delete;
SubspaceRegister(SubspaceRegister &&) noexcept = default;
SubspaceRegister & operator=(SubspaceRegister &&) noexcept = default;
virtual ~SubspaceRegister() = default;
~SubspaceRegister() = default;
/** Registers a subspace of some vector space and returns its registered id.
If the subspace has already been registered before, returns its existing id.
......@@ -87,7 +87,7 @@ public:
SpaceRegEntry & operator=(const SpaceRegEntry &) = delete;
SpaceRegEntry(SpaceRegEntry &&) noexcept = default;
SpaceRegEntry & operator=(SpaceRegEntry &&) noexcept = default;
virtual ~SpaceRegEntry() = default;
~SpaceRegEntry() = default;
friend class SpaceRegister;
......@@ -107,7 +107,7 @@ public:
SpaceRegister & operator=(const SpaceRegister &) = delete;
SpaceRegister(SpaceRegister &&) noexcept = default;
SpaceRegister & operator=(SpaceRegister &&) noexcept = default;
virtual ~SpaceRegister() = default;
~SpaceRegister() = default;
/** Registers a named vector space and returns its registered id.
If it has already been registered before, returns its existing id.
......
/** ExaTN::Numerics: Tensor operation: Adds a tensor to another tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -21,9 +21,9 @@ bool TensorOpAdd::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands() && this->getIndexPattern().length() > 0);
}
TensorOperation * TensorOpAdd::createNew()
std::unique_ptr<TensorOperation> TensorOpAdd::createNew()
{
return new TensorOpAdd();
return std::unique_ptr<TensorOperation>(new TensorOpAdd());
}
} //namespace numerics
......
/** ExaTN::Numerics: Tensor operation: Adds a tensor to another tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -33,7 +33,7 @@ public:
virtual bool isSet() const override;
/** Create a new polymorphic instance of this subclass. **/
static TensorOperation * createNew();
static std::unique_ptr<TensorOperation> createNew();
private:
......
/** ExaTN::Numerics: Tensor operation: Contracts two tensors and accumulates the result into another tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -22,9 +22,9 @@ bool TensorOpContract::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands() && this->getIndexPattern().length() > 0);
}
TensorOperation * TensorOpContract::createNew()
std::unique_ptr<TensorOperation> TensorOpContract::createNew()
{
return new TensorOpContract();
return std::unique_ptr<TensorOperation>(new TensorOpContract());
}
} //namespace numerics
......
/** ExaTN::Numerics: Tensor operation: Contracts two tensors and accumulates the result into another tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -34,7 +34,7 @@ public:
virtual bool isSet() const override;
/** Create a new polymorphic instance of this subclass. **/
static TensorOperation * createNew();
static std::unique_ptr<TensorOperation> createNew();
private:
......
/** ExaTN::Numerics: Tensor operation: Creates a tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -20,9 +20,9 @@ bool TensorOpCreate::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands());
}
TensorOperation * TensorOpCreate::createNew()
std::unique_ptr<TensorOperation> TensorOpCreate::createNew()
{
return new TensorOpCreate();
return std::unique_ptr<TensorOperation>(new TensorOpCreate());
}
} //namespace numerics
......
/** ExaTN::Numerics: Tensor operation: Creates a tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -33,7 +33,7 @@ public:
virtual bool isSet() const override;
/** Create a new polymorphic instance of this subclass. **/
static TensorOperation * createNew();
static std::unique_ptr<TensorOperation> createNew();
private:
......
/** ExaTN::Numerics: Tensor operation: Destroys a tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -20,9 +20,9 @@ bool TensorOpDestroy::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands());
}
TensorOperation * TensorOpDestroy::createNew()
std::unique_ptr<TensorOperation> TensorOpDestroy::createNew()
{
return new TensorOpDestroy();
return std::unique_ptr<TensorOperation>(new TensorOpDestroy());
}
} //namespace numerics
......
/** ExaTN::Numerics: Tensor operation: Destroys a tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -33,7 +33,7 @@ public:
virtual bool isSet() const override;
/** Create a new polymorphic instance of this subclass. **/
static TensorOperation * createNew();
static std::unique_ptr<TensorOperation> createNew();
private:
......
/** ExaTN::Numerics: Tensor operation factory
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -25,11 +25,11 @@ void TensorOpFactory::registerTensorOp(TensorOpCode opcode, createTensorOpFn cre
return;
}
TensorOperation * TensorOpFactory::createTensorOp(TensorOpCode opcode)
std::unique_ptr<TensorOperation> TensorOpFactory::createTensorOp(TensorOpCode opcode)
{
auto it = factory_map_.find(opcode);
if(it != factory_map_.end()) return (it->second)();
return nullptr;
return std::unique_ptr<TensorOperation>(nullptr);
}
TensorOpFactory * TensorOpFactory::get()
......
/** ExaTN::Numerics: Tensor operation factory
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -33,13 +33,13 @@ public:
TensorOpFactory & operator=(const TensorOpFactory &) = delete;
TensorOpFactory(TensorOpFactory &&) noexcept = default;
TensorOpFactory & operator=(TensorOpFactory &&) noexcept = default;
virtual ~TensorOpFactory() = default;
~TensorOpFactory() = default;
/** Registers a new tensor operation subtype to produce instances of. **/
void registerTensorOp(TensorOpCode opcode, createTensorOpFn creator);
/** Creates a new instance of a desired subtype. **/
TensorOperation * createTensorOp(TensorOpCode opcode);
std::unique_ptr<TensorOperation> createTensorOp(TensorOpCode opcode);
/** Returns a pointer to the TensorOpFactory singleton. **/
static TensorOpFactory * get();
......
/** ExaTN::Numerics: Tensor operation: Transforms/initializes a tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -21,9 +21,9 @@ bool TensorOpTransform::isSet() const
return (this->getNumOperandsSet() == this->getNumOperands());
}
TensorOperation * TensorOpTransform::createNew()
std::unique_ptr<TensorOperation> TensorOpTransform::createNew()
{
return new TensorOpTransform();
return std::unique_ptr<TensorOperation>(new TensorOpTransform());
}
} //namespace numerics
......
/** ExaTN::Numerics: Tensor operation: Transforms/initializes a tensor
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -33,7 +33,7 @@ public:
virtual bool isSet() const override;
/** Create a new polymorphic instance of this subclass. **/
static TensorOperation * createNew();
static std::unique_ptr<TensorOperation> createNew();
private:
......
/** ExaTN::Numerics: Tensor operation
REVISION: 2019/05/31
REVISION: 2019/06/03
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -84,7 +84,7 @@ protected:
};
using createTensorOpFn = TensorOperation* (*)(void);
using createTensorOpFn = std::unique_ptr<TensorOperation> (*)(void);
} //namespace numerics
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment