Skip to content

Commit

Permalink
move CrowReturnable and JsonCrowReturnable to Utils project
Browse files Browse the repository at this point in the history
  • Loading branch information
nam20485 committed Oct 12, 2023
1 parent 5dac053 commit 95a0324
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 34 deletions.
2 changes: 1 addition & 1 deletion OdbDesignLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
29 changes: 0 additions & 29 deletions OdbDesignLib/CrowReturnable.h

This file was deleted.

1 change: 1 addition & 0 deletions OdbDesignServer/Controllers/StepsEdaDataController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using namespace Odb::Lib;
using namespace Odb::Lib::FileModel::Design;
using namespace Utils;

namespace Odb::App::Server
{
Expand Down
2 changes: 1 addition & 1 deletion Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
31 changes: 31 additions & 0 deletions Utils/CrowReturnable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include "crow_win.h"

namespace Utils
{
template <typename T>
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<typename T>
inline std::string CrowReturnable<T>::dump() const
{
return to_string();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
#include "IJsonable.h"
#include "CrowReturnable.h"

namespace Odb::Lib
namespace Utils
{
template<typename TJsonable>
class JsonCrowReturnable : public CrowReturnable<TJsonable>
class JsonCrowReturnable : public Utils::CrowReturnable<TJsonable>
{
public:
JsonCrowReturnable(const TJsonable& odbObject)
: CrowReturnable<TJsonable>(odbObject, CONTENT_TYPE)
: Utils::CrowReturnable<TJsonable>(odbObject, CONTENT_TYPE)
{}

inline static const std::string CONTENT_TYPE = "application/json";
Expand Down

0 comments on commit 95a0324

Please sign in to comment.