-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
967 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ PyOdbDesignServer/PyOdbDesignLib/ | |
/cmake-build-debug | ||
build/ | ||
/vcpkg_installed | ||
/OdbDesignServer/designs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "CrowReturnable.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include "crow.h" | ||
|
||
|
||
class CrowReturnable : public crow::returnable | ||
{ | ||
CrowReturnable() | ||
: returnable("text/plain") | ||
{} | ||
|
||
// | ||
virtual std::string as_string() const = 0; | ||
|
||
std::string dump() const override | ||
{ | ||
return this->as_string(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "DesignCache.h" | ||
#include <filesystem> | ||
|
||
|
||
namespace Odb::Lib | ||
{ | ||
DesignCache::DesignCache() | ||
: DesignCache(".") | ||
{ | ||
} | ||
|
||
DesignCache::DesignCache(std::string directory) : | ||
m_directory(directory) | ||
{ | ||
} | ||
|
||
DesignCache::~DesignCache() | ||
{ | ||
m_fileArchivesByName.clear(); | ||
m_designsByName.clear(); | ||
} | ||
|
||
std::shared_ptr<ProductModel::Design> DesignCache::GetDesign(std::string designName) | ||
{ | ||
auto findIt = m_designsByName.find(designName); | ||
if (findIt == m_designsByName.end()) | ||
{ | ||
auto pDesign = LoadDesign(designName); | ||
return pDesign; | ||
} | ||
|
||
return m_designsByName[designName]; | ||
} | ||
|
||
std::shared_ptr<FileModel::Design::FileArchive> DesignCache::GetFileArchive(std::string designName) | ||
{ | ||
auto findIt = m_fileArchivesByName.find(designName); | ||
if (findIt == m_fileArchivesByName.end()) | ||
{ | ||
auto pFileArchive = LoadFileArchive(designName); | ||
return pFileArchive; | ||
} | ||
|
||
return m_fileArchivesByName[designName]; | ||
} | ||
|
||
std::shared_ptr<ProductModel::Design> DesignCache::LoadDesign(std::string designName) | ||
{ | ||
std::filesystem::path dir(m_directory); | ||
|
||
for (const auto& entry : std::filesystem::directory_iterator(dir)) | ||
{ | ||
if (entry.is_regular_file()) | ||
{ | ||
if (entry.path().stem() == designName) | ||
{ | ||
auto pDesign = std::make_shared<ProductModel::Design>(); | ||
if (pDesign->Build(entry.path().string())) | ||
{ | ||
m_designsByName.emplace(designName, pDesign); | ||
return pDesign; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
std::shared_ptr<FileModel::Design::FileArchive> DesignCache::LoadFileArchive(std::string designName) | ||
{ | ||
std::filesystem::path dir(m_directory); | ||
|
||
for (const auto& entry : std::filesystem::directory_iterator(dir)) | ||
{ | ||
if (entry.is_regular_file()) | ||
{ | ||
if (entry.path().stem() == designName) | ||
{ | ||
auto pFileArchive = std::make_shared<FileModel::Design::FileArchive>(entry.path().string()); | ||
if (pFileArchive->ParseFileModel()) | ||
{ | ||
m_fileArchivesByName.emplace(designName, pFileArchive); | ||
return pFileArchive; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return nullptr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "FileArchive.h" | ||
#include "Design.h" | ||
#include "export.h" | ||
|
||
|
||
namespace Odb::Lib | ||
{ | ||
class DECLSPEC DesignCache | ||
{ | ||
public: | ||
DesignCache(); | ||
DesignCache(std::string directory); | ||
~DesignCache(); | ||
|
||
std::shared_ptr<ProductModel::Design> GetDesign(std::string designName); | ||
std::shared_ptr<FileModel::Design::FileArchive> GetFileArchive(std::string designName); | ||
|
||
private: | ||
std::string m_directory; | ||
|
||
FileModel::Design::FileArchive::StringMap m_fileArchivesByName; | ||
ProductModel::Design::StringMap m_designsByName; | ||
|
||
std::shared_ptr<ProductModel::Design> LoadDesign(std::string designName); | ||
std::shared_ptr<FileModel::Design::FileArchive> LoadFileArchive(std::string designName); | ||
|
||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.