From 95a03242e4a6ce536c317c9fc3006dc21b9656ee Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 12 Oct 2023 12:19:21 -0700 Subject: [PATCH] move CrowReturnable and JsonCrowReturnable to Utils project --- OdbDesignLib/CMakeLists.txt | 2 +- OdbDesignLib/CrowReturnable.h | 29 ----------------- .../Controllers/StepsEdaDataController.cpp | 1 + Utils/CMakeLists.txt | 2 +- Utils/CrowReturnable.h | 31 +++++++++++++++++++ {OdbDesignLib => Utils}/JsonCrowReturnable.h | 6 ++-- 6 files changed, 37 insertions(+), 34 deletions(-) delete mode 100644 OdbDesignLib/CrowReturnable.h create mode 100644 Utils/CrowReturnable.h rename {OdbDesignLib => Utils}/JsonCrowReturnable.h (82%) diff --git a/OdbDesignLib/CMakeLists.txt b/OdbDesignLib/CMakeLists.txt index f9115c87..b288661a 100644 --- a/OdbDesignLib/CMakeLists.txt +++ b/OdbDesignLib/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeList.txt : CMake project for OdbDesignLib # -add_library(OdbDesign SHARED "odbdesign_export.h" "ComponentLayerDirectory.cpp" "ComponentLayerDirectory.h" "EdaDataFile.cpp" "EdaDataFile.h" "LayerDirectory.cpp" "LayerDirectory.h" "NetlistFile.cpp" "NetlistFile.h" "FileArchive.cpp" "FileArchive.h" "StepDirectory.cpp" "StepDirectory.h" "Net.h" "Net.cpp" "Component.h" "Component.cpp" "Pin.h" "Pin.cpp" "PinConnection.h" "PinConnection.cpp" "Package.h" "Package.cpp" "Part.h" "Part.cpp" "Via.h" "Via.cpp" "Design.h" "Design.cpp" "BoardSide.h" "OdbDesign.h" "DesignCache.h" "DesignCache.cpp" "win.h" "proto/edadatafile.pb.h" "proto/edadatafile.pb.cc" "IProtoBuffable.h" "crow_win.h" "OdbFile.h" "OdbFile.cpp" "OdbFileRecord.h" "OdbFileRecord.cpp" "CrowReturnable.h" "JsonCrowReturnable.h" "IOdbServerApp.h" "IOdbServerApp.cpp") +add_library(OdbDesign SHARED "odbdesign_export.h" "ComponentLayerDirectory.cpp" "ComponentLayerDirectory.h" "EdaDataFile.cpp" "EdaDataFile.h" "LayerDirectory.cpp" "LayerDirectory.h" "NetlistFile.cpp" "NetlistFile.h" "FileArchive.cpp" "FileArchive.h" "StepDirectory.cpp" "StepDirectory.h" "Net.h" "Net.cpp" "Component.h" "Component.cpp" "Pin.h" "Pin.cpp" "PinConnection.h" "PinConnection.cpp" "Package.h" "Package.cpp" "Part.h" "Part.cpp" "Via.h" "Via.cpp" "Design.h" "Design.cpp" "BoardSide.h" "OdbDesign.h" "DesignCache.h" "DesignCache.cpp" "win.h" "proto/edadatafile.pb.h" "proto/edadatafile.pb.cc" "IProtoBuffable.h" "crow_win.h" "OdbFile.h" "OdbFile.cpp" "OdbFileRecord.h" "OdbFileRecord.cpp" "IOdbServerApp.h" "IOdbServerApp.cpp") # required for SWIG set_property(TARGET OdbDesign PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/OdbDesignLib/CrowReturnable.h b/OdbDesignLib/CrowReturnable.h deleted file mode 100644 index c278920a..00000000 --- a/OdbDesignLib/CrowReturnable.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "crow_win.h" - - -template -class CrowReturnable : public crow::returnable -{ -public: - CrowReturnable(const T& t, const std::string& contentType) - : crow::returnable(contentType) - , m_t(t) - {} - -protected: - const T& m_t; - - // Inherited via returnable - std::string dump() const override; - - virtual std::string to_string() const = 0; - -}; - -template -inline std::string CrowReturnable::dump() const -{ - return to_string(); -} diff --git a/OdbDesignServer/Controllers/StepsEdaDataController.cpp b/OdbDesignServer/Controllers/StepsEdaDataController.cpp index 8e5d3e59..31a6f8bb 100644 --- a/OdbDesignServer/Controllers/StepsEdaDataController.cpp +++ b/OdbDesignServer/Controllers/StepsEdaDataController.cpp @@ -6,6 +6,7 @@ using namespace Odb::Lib; using namespace Odb::Lib::FileModel::Design; +using namespace Utils; namespace Odb::App::Server { diff --git a/Utils/CMakeLists.txt b/Utils/CMakeLists.txt index 52b42868..1daaed7b 100644 --- a/Utils/CMakeLists.txt +++ b/Utils/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeList.txt : CMake project for OdbDesignServer # -add_library(Utils SHARED "utils_export.h" "ExitCode.h" "ThreadSafeQueue.h" "WorkQueueLoopThread.h" "Logger.h" "Logger.cpp" "CommandLineArgs.h" "CommandLineArgs.cpp" "bin2ascii.h" "ArchiveExtractor.cpp" "ArchiveExtractor.h" "libarchive_extract.cpp" "libarchive_extract.h" "str_trim.cpp" "str_trim.h" "IJsonable.h" "IJsonable.cpp") +add_library(Utils SHARED "utils_export.h" "ExitCode.h" "ThreadSafeQueue.h" "WorkQueueLoopThread.h" "Logger.h" "Logger.cpp" "CommandLineArgs.h" "CommandLineArgs.cpp" "bin2ascii.h" "ArchiveExtractor.cpp" "ArchiveExtractor.h" "libarchive_extract.cpp" "libarchive_extract.h" "str_trim.cpp" "str_trim.h" "IJsonable.h" "IJsonable.cpp" "CrowReturnable.h" "JsonCrowReturnable.h") # state that anybody linking to us needs to include the current source dir, # while we don't. diff --git a/Utils/CrowReturnable.h b/Utils/CrowReturnable.h new file mode 100644 index 00000000..947e9dc0 --- /dev/null +++ b/Utils/CrowReturnable.h @@ -0,0 +1,31 @@ +#pragma once + +#include "crow_win.h" + +namespace Utils +{ + template + class CrowReturnable : public crow::returnable + { + public: + CrowReturnable(const T& t, const std::string& contentType) + : crow::returnable(contentType) + , m_t(t) + {} + + protected: + const T& m_t; + + // Inherited via returnable + std::string dump() const override; + + virtual std::string to_string() const = 0; + + }; + + template + inline std::string CrowReturnable::dump() const + { + return to_string(); + } +} diff --git a/OdbDesignLib/JsonCrowReturnable.h b/Utils/JsonCrowReturnable.h similarity index 82% rename from OdbDesignLib/JsonCrowReturnable.h rename to Utils/JsonCrowReturnable.h index 34592f5b..4434e4ce 100644 --- a/OdbDesignLib/JsonCrowReturnable.h +++ b/Utils/JsonCrowReturnable.h @@ -3,14 +3,14 @@ #include "IJsonable.h" #include "CrowReturnable.h" -namespace Odb::Lib +namespace Utils { template - class JsonCrowReturnable : public CrowReturnable + class JsonCrowReturnable : public Utils::CrowReturnable { public: JsonCrowReturnable(const TJsonable& odbObject) - : CrowReturnable(odbObject, CONTENT_TYPE) + : Utils::CrowReturnable(odbObject, CONTENT_TYPE) {} inline static const std::string CONTENT_TYPE = "application/json";