Commit 3bdafcdd by lvzhengyang

add code structure for db_mgr

parent 61411121
......@@ -89,4 +89,5 @@ add_compile_options(
add_subdirectory(main)
add_subdirectory(utl)
add_subdirectory(odb)
add_subdirectory(db_mgr)
include("swig_lib")
# swig_lib()
add_library(db_mgr)
target_sources(db_mgr
PRIVATE
src/db_mgr.cpp
)
target_include_directories(db_mgr
PUBLIC
include
)
target_link_libraries(db_mgr
PRIVATE
odb
utl
)
......@@ -15,6 +15,7 @@ namespace utl {
class Logger;
}
namespace eda {
/* DB Manager: for hierarchical design. A hierarchical design
* contains multiple sub-block within the 'top' module. Because
* dbBlock class in OpenDB only supports two-levels of hierarchy,
......@@ -42,10 +43,14 @@ public:
DbMgr();
void deleteDbMgr(); // dbDatadase::destroy()
bool readLibDB();
/*
bool readBlockDBs();
bool addBlockDB();
bool deleteBlockDB();
*/
bool haveBlockDB(std::string block);
void setLogger(utl::Logger* logger);
private:
/* all Blocks share the same lib (.lef files)
......@@ -59,9 +64,10 @@ private:
* check if there exists duplicate name when inserting
* blocks.
*/
std::unordered_map<std::string, odb::dbDatabase> block_dbs_;
std::unordered_map<std::string, odb::dbDatabase*> block_dbs_;
utl::Logger* logger_;
};
} // namespace eda
#endif // _DB_MGR_H_
#include "db_mgr/db_mgr.h"
#include "db.h"
#include "utl/Logger.h"
namespace eda {
DbMgr::DbMgr()
: lib_db_(nullptr),
logger_(nullptr)
{
block_dbs_.clear();
}
void DbMgr::deleteDbMgr()
{
if (lib_db_ != nullptr) {
lib_db_->destroy(lib_db_);
}
if (!block_dbs_.empty()) {
for (auto item : block_dbs_) {
odb::dbDatabase* block_db = item.second;
block_db->destroy(block_db);
}
block_dbs_.clear();
}
}
bool DbMgr::haveBlockDB(std::string block)
{
if (block_dbs_.empty()) return false;
return block_dbs_.find(block) != block_dbs_.end();
}
void DbMgr::setLogger(utl::Logger* logger)
{
logger_ = logger;
}
bool DbMgr::readLibDB()
{
return true;
}
} // namespace eda
......@@ -24,6 +24,7 @@ target_link_libraries(minieda_swig
PRIVATE
utl
odb
db_mgr
)
# swig_lib(NAME util_swig)
......@@ -57,6 +58,7 @@ target_link_libraries(minieda
minieda_swig
utl
odb
db_mgr
${CMAKE_THREAD_LIBS_INIT}
${TCL_LIBRARY}
)
......
Markdown is supported
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