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

Implemented open/close Scope in NumServer.

parent a9d8dd8e
/** ExaTN::Numerics: Numerical server
REVISION: 2019/05/31
REVISION: 2019/06/05
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -10,6 +10,11 @@ namespace exatn{
namespace numerics{
NumServer::NumServer()
{
scopes_.push(std::pair<std::string,ScopeId>{"GLOBAL",0});
}
void NumServer::registerTensorMethod(std::shared_ptr<TensorMethod<Identifiable>> method)
{
ext_methods_.insert({method->name(),method});
......@@ -35,15 +40,18 @@ std::shared_ptr<BytePacket> NumServer::getExternalData(const std::string & tag)
ScopeId NumServer::openScope(const std::string & scope_name)
{
//`Finish
return 0;
assert(scope_name.length() > 0);
ScopeId new_scope_id = scopes_.size();
scopes_.push(std::pair<std::string,ScopeId>{scope_name,new_scope_id});
return new_scope_id;
}
ScopeId NumServer::closeScope()
{
auto prev_scope = scopes_.top();
const auto & prev_scope = scopes_.top();
ScopeId prev_scope_id = std::get<1>(prev_scope);
scopes_.pop();
return prev_scope;
return prev_scope_id;
}
......
/** ExaTN::Numerics: Numerical server
REVISION: 2019/05/31
REVISION: 2019/06/05
Copyright (C) 2018-2019 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2019 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -31,7 +31,7 @@ class NumServer{
public:
NumServer() = default;
NumServer();
NumServer(const NumServer &) = delete;
NumServer & operator=(const NumServer &) = delete;
NumServer(NumServer &&) noexcept = default;
......@@ -73,10 +73,10 @@ public:
returns its registered id, and, optionally, a non-owning pointer to it. **/
SubspaceId createSubspace(const std::string & subspace_name, //in: subspace name
const std::string & space_name, //in: containing vector space name
const std::pair<DimOffset,DimOffset> bounds, //in: range of basis vectors defining the created subspace: [
const std::pair<DimOffset,DimOffset> bounds, //in: range of basis vectors defining the created subspace
const Subspace ** subspace_ptr = nullptr); //out: non-owning pointer to the created subspace
/** Destroys a previously created named subspace. **/
/** Destroys a previously created named subspace of a named vector space. **/
void destroySubspace(const std::string & subspace_name); //in: name of the subspace to destroy
void destroySubspace(SubspaceId subspace_id);
......@@ -88,7 +88,7 @@ private:
std::map<std::string,std::shared_ptr<TensorMethod<Identifiable>>> ext_methods_; //external tensor methods
std::map<std::string,std::shared_ptr<BytePacket>> ext_data_; //external data
std::stack<ScopeId> scopes_; //TAProL scope stack
std::stack<std::pair<std::string,ScopeId>> scopes_; //TAProL scope stack: {Scope name, Scope Id}
};
......
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