Skip to content

Commit

Permalink
add steps/netlist endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nam20485 committed Jan 13, 2024
1 parent acd9e67 commit 78a5152
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 5 deletions.
73 changes: 68 additions & 5 deletions OdbDesignServer/Controllers/FileModelController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ namespace Odb::App::Server
{
}

//FileArchive
//StepDirectory::StringMap m_stepsByName;
//LayerDirectory::StringMap m_layersByName;
//NetlistFile::StringMap m_netlistsByName;
//FileArchive *
//StepDirectory::StringMap m_stepsByName; *
//LayerDirectory::StringMap m_layersByName; *
// ComponentsFile m_componentsFile;
// FeaturesFile m_featuresFile;
// AttrListFile m_attrListFile;
//Netlist//File::StringMap m_netlistsByName; *

////EdaDataFile m_edaData;
////AttrListFile m_attrListFile;
////FeaturesFile m_profileFile;
////StepHdrFile m_stepHdrFile;

//SymbolsDirectory::StringMap m_symbolsDirectoriesByName;
//SymbolsDirectory::StringMap m_symbolsDirectoriesByName; *
// AttrList file
// features file

Expand All @@ -32,6 +36,8 @@ namespace Odb::App::Server
////StandardFontsFile m_standardFontsFile;
////AttrListFile m_miscAttrListFile;

// * need endpoints to list of keys of maps, i.e. available names to fetch

void FileModelController::register_routes()
{
CROW_ROUTE(m_serverApp.crow_app(), "/filemodel/<string>")
Expand Down Expand Up @@ -70,6 +76,12 @@ namespace Odb::App::Server
return this->steps_stephdr_route_handler(designName, stepName, req);
});

CROW_ROUTE(m_serverApp.crow_app(), "/filemodel/<string>/steps/<string>/netlist/<string>")
([&](const crow::request& req, std::string designName, std::string stepName, std::string netlistName)
{
return this->steps_netlist_route_handler(designName, stepName, netlistName, req);
});

CROW_ROUTE(m_serverApp.crow_app(), "/filemodel/<string>/symbols/<string>")
([&](const crow::request& req, std::string designName, std::string symbolName)
{
Expand Down Expand Up @@ -251,6 +263,57 @@ namespace Odb::App::Server
return crow::response(JsonCrowReturnable(stepHdrFile));
}

crow::response FileModelController::steps_netlist_route_handler(const std::string& designName, const std::string& stepName, const std::string& netlistName, const crow::request& req)
{
auto designNameDecoded = UrlEncoding::decode(designName);
if (designNameDecoded.empty())
{
return crow::response(crow::status::BAD_REQUEST, "design name not specified");
}

auto stepNameDecoded = UrlEncoding::decode(stepName);
if (stepNameDecoded.empty())
{
return crow::response(crow::status::BAD_REQUEST, "step name not specified");
}

auto netlistNameDecoded = UrlEncoding::decode(netlistName);
if (stepNameDecoded.empty())
{
return crow::response(crow::status::BAD_REQUEST, "netlist name not specified");
}

auto pFileArchive = m_serverApp.designs().GetFileArchive(designNameDecoded);
if (pFileArchive == nullptr)
{
std::stringstream ss;
ss << "design: \"" << designNameDecoded << "\" not found";
return crow::response(crow::status::NOT_FOUND, ss.str());
}

auto& stepsByName = pFileArchive->GetStepsByName();
auto findIt = stepsByName.find(stepNameDecoded);
if (findIt == stepsByName.end())
{
std::stringstream ss;
ss << "(design: \"" << designNameDecoded << "\")" << " step: \"" << stepNameDecoded << "\" not found";
return crow::response(crow::status::NOT_FOUND, ss.str());
}
auto& step = findIt->second;

auto& netlistsByName = step->GetNetlistsByName();
auto findIt2 = netlistsByName.find(netlistNameDecoded);
if (findIt2 == netlistsByName.end())
{
std::stringstream ss;
ss << "(design: \"" << designNameDecoded << "\")" << " step: \"" << stepNameDecoded << "\"" << " netlist: \"" << netlistNameDecoded << "\"" << " not found";
return crow::response(crow::status::NOT_FOUND, ss.str());
}
auto& netlist = findIt2->second;

return crow::response(JsonCrowReturnable(*netlist));
}

crow::response FileModelController::steps_route_handler(const std::string& designName, const std::string& stepName, const crow::request& req)
{
auto designNameDecoded = UrlEncoding::decode(designName);
Expand Down
1 change: 1 addition & 0 deletions OdbDesignServer/Controllers/FileModelController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Odb::App::Server
crow::response steps_attrlist_route_handler(const std::string& designName, const std::string& stepName, const crow::request& req);
crow::response steps_profile_route_handler(const std::string& designName, const std::string& stepName, const crow::request& req);
crow::response steps_stephdr_route_handler(const std::string& designName, const std::string& stepName, const crow::request& req);
crow::response steps_netlist_route_handler(const std::string& designName, const std::string& stepName, const std::string& netlistName, const crow::request& req);

crow::response symbols_route_handler(const std::string& designName, const std::string& symbolName, const crow::request& req);

Expand Down

0 comments on commit 78a5152

Please sign in to comment.