From c0b4fdb4dfbbf21bbb8c0603092d90f832a3ac11 Mon Sep 17 00:00:00 2001 From: Victor Lindquist Date: Wed, 22 Jun 2022 18:52:47 -0600 Subject: [PATCH] Folder restructuring in software integration module --- modules/softwareintegration/CMakeLists.txt | 26 +++++----- .../{ => network}/messagehandler.cpp | 5 +- .../{ => network}/messagehandler.h | 5 +- .../{ => network}/messagehandler.inl | 0 .../softwareintegration/network/network.cpp | 3 +- modules/softwareintegration/network/network.h | 4 +- .../network/softwareconnection.cpp | 1 - .../network/softwareconnection.h | 2 +- .../rendering/renderablepointscloud.cpp | 2 +- .../{assethelper.cpp => session/session.cpp} | 12 ++--- .../{assethelper.h => session/session.h} | 18 ++++--- .../{utils.cpp => simp/simp.cpp} | 51 ++----------------- .../{utils.h => simp/simp.h} | 27 ++-------- .../{utils.inl => simp/simp.inl} | 0 .../softwareintegrationmodule.cpp | 2 +- .../softwareintegrationmodule.h | 10 ++-- .../softwareintegrationmodule_lua.inl | 6 +-- .../interruptibleconcurrentqueue.h | 0 .../interruptibleconcurrentqueue.inl | 0 .../{ => utils}/syncablestorage.cpp | 44 +++++++++++++++- .../{ => utils}/syncablestorage.h | 21 +++++++- .../{ => utils}/syncablestorage.inl | 0 22 files changed, 119 insertions(+), 120 deletions(-) rename modules/softwareintegration/{ => network}/messagehandler.cpp (99%) rename modules/softwareintegration/{ => network}/messagehandler.h (98%) rename modules/softwareintegration/{ => network}/messagehandler.inl (100%) rename modules/softwareintegration/{assethelper.cpp => session/session.cpp} (96%) rename modules/softwareintegration/{assethelper.h => session/session.h} (82%) rename modules/softwareintegration/{utils.cpp => simp/simp.cpp} (92%) rename modules/softwareintegration/{utils.h => simp/simp.h} (92%) rename modules/softwareintegration/{utils.inl => simp/simp.inl} (100%) rename modules/softwareintegration/{ => utils}/interruptibleconcurrentqueue.h (100%) rename modules/softwareintegration/{ => utils}/interruptibleconcurrentqueue.inl (100%) rename modules/softwareintegration/{ => utils}/syncablestorage.cpp (91%) rename modules/softwareintegration/{ => utils}/syncablestorage.h (92%) rename modules/softwareintegration/{ => utils}/syncablestorage.inl (100%) diff --git a/modules/softwareintegration/CMakeLists.txt b/modules/softwareintegration/CMakeLists.txt index 344c8f264c..cc7e2f3b68 100644 --- a/modules/softwareintegration/CMakeLists.txt +++ b/modules/softwareintegration/CMakeLists.txt @@ -27,31 +27,31 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/softwareintegrationmodule.h ${CMAKE_CURRENT_SOURCE_DIR}/softwareintegrationmodule.inl - ${CMAKE_CURRENT_SOURCE_DIR}/messagehandler.h - ${CMAKE_CURRENT_SOURCE_DIR}/messagehandler.inl + ${CMAKE_CURRENT_SOURCE_DIR}/network/messagehandler.h + ${CMAKE_CURRENT_SOURCE_DIR}/network/messagehandler.inl ${CMAKE_CURRENT_SOURCE_DIR}/network/network.h ${CMAKE_CURRENT_SOURCE_DIR}/network/softwareconnection.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablepointscloud.h - ${CMAKE_CURRENT_SOURCE_DIR}/utils.h - ${CMAKE_CURRENT_SOURCE_DIR}/utils.inl - ${CMAKE_CURRENT_SOURCE_DIR}/syncablestorage.h - ${CMAKE_CURRENT_SOURCE_DIR}/syncablestorage.inl - ${CMAKE_CURRENT_SOURCE_DIR}/interruptibleconcurrentqueue.h - ${CMAKE_CURRENT_SOURCE_DIR}/interruptibleconcurrentqueue.inl - ${CMAKE_CURRENT_SOURCE_DIR}/assethelper.h + ${CMAKE_CURRENT_SOURCE_DIR}/simp/simp.inl + ${CMAKE_CURRENT_SOURCE_DIR}/simp/simp.h + ${CMAKE_CURRENT_SOURCE_DIR}/utils/syncablestorage.h + ${CMAKE_CURRENT_SOURCE_DIR}/utils/syncablestorage.inl + ${CMAKE_CURRENT_SOURCE_DIR}/utils/interruptibleconcurrentqueue.h + ${CMAKE_CURRENT_SOURCE_DIR}/utils/interruptibleconcurrentqueue.inl + ${CMAKE_CURRENT_SOURCE_DIR}/session/session.h ) source_group("Header Files" FILES ${HEADER_FILES}) set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/softwareintegrationmodule.cpp ${CMAKE_CURRENT_SOURCE_DIR}/softwareintegrationmodule_lua.inl - ${CMAKE_CURRENT_SOURCE_DIR}/messagehandler.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/network/messagehandler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/network/network.cpp ${CMAKE_CURRENT_SOURCE_DIR}/network/softwareconnection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablepointscloud.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/syncablestorage.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/assethelper.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/simp/simp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils/syncablestorage.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/session/session.cpp ) source_group("Source Files" FILES ${SOURCE_FILES}) diff --git a/modules/softwareintegration/messagehandler.cpp b/modules/softwareintegration/network/messagehandler.cpp similarity index 99% rename from modules/softwareintegration/messagehandler.cpp rename to modules/softwareintegration/network/messagehandler.cpp index daa6d05911..266c355a11 100644 --- a/modules/softwareintegration/messagehandler.cpp +++ b/modules/softwareintegration/network/messagehandler.cpp @@ -22,10 +22,9 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include -#include -#include +#include +#include #include #include #include diff --git a/modules/softwareintegration/messagehandler.h b/modules/softwareintegration/network/messagehandler.h similarity index 98% rename from modules/softwareintegration/messagehandler.h rename to modules/softwareintegration/network/messagehandler.h index 062ebc73a7..1a142023c2 100644 --- a/modules/softwareintegration/messagehandler.h +++ b/modules/softwareintegration/network/messagehandler.h @@ -27,9 +27,10 @@ #include -#include - #include +#include + +#include namespace openspace::softwareintegration::messagehandler { diff --git a/modules/softwareintegration/messagehandler.inl b/modules/softwareintegration/network/messagehandler.inl similarity index 100% rename from modules/softwareintegration/messagehandler.inl rename to modules/softwareintegration/network/messagehandler.inl diff --git a/modules/softwareintegration/network/network.cpp b/modules/softwareintegration/network/network.cpp index 88ca8b3156..ff3716b0c2 100644 --- a/modules/softwareintegration/network/network.cpp +++ b/modules/softwareintegration/network/network.cpp @@ -24,8 +24,7 @@ #include -#include -#include +#include #include #include #include diff --git a/modules/softwareintegration/network/network.h b/modules/softwareintegration/network/network.h index ee6b1ba198..d3801dc487 100644 --- a/modules/softwareintegration/network/network.h +++ b/modules/softwareintegration/network/network.h @@ -26,9 +26,9 @@ #define __OPENSPACE_MODULE_SOFTWAREINTEGRATION___NETWORKENGINE___H__ #include -#include +#include #include -#include +#include #include #include diff --git a/modules/softwareintegration/network/softwareconnection.cpp b/modules/softwareintegration/network/softwareconnection.cpp index 952be9ebd3..08d4df7119 100644 --- a/modules/softwareintegration/network/softwareconnection.cpp +++ b/modules/softwareintegration/network/softwareconnection.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/modules/softwareintegration/network/softwareconnection.h b/modules/softwareintegration/network/softwareconnection.h index 5f892ba0ed..65e58c04ec 100644 --- a/modules/softwareintegration/network/softwareconnection.h +++ b/modules/softwareintegration/network/softwareconnection.h @@ -25,7 +25,7 @@ #ifndef __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SOFTWARECONNECTION___H__ #define __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SOFTWARECONNECTION___H__ -#include +#include #include #include #include diff --git a/modules/softwareintegration/rendering/renderablepointscloud.cpp b/modules/softwareintegration/rendering/renderablepointscloud.cpp index f62c76a7e2..61dca8422d 100644 --- a/modules/softwareintegration/rendering/renderablepointscloud.cpp +++ b/modules/softwareintegration/rendering/renderablepointscloud.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/modules/softwareintegration/assethelper.cpp b/modules/softwareintegration/session/session.cpp similarity index 96% rename from modules/softwareintegration/assethelper.cpp rename to modules/softwareintegration/session/session.cpp index 8dc42040cf..2ac668e2c0 100644 --- a/modules/softwareintegration/assethelper.cpp +++ b/modules/softwareintegration/session/session.cpp @@ -22,10 +22,10 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include #include -#include +#include #include #include #include @@ -38,7 +38,7 @@ namespace { -constexpr const char* _loggerCat = "SoftwareIntegrationAssetHelper"; +constexpr const char* _loggerCat = "SoftwareIntegrationSession"; } // namespace @@ -112,9 +112,9 @@ bool saveSessionData(SyncableStorage& storage, return true; } -} // namepsace +} // namespace -bool AssetHelper::loadSessionData(SoftwareIntegrationModule* module, +bool softwareintegration::Session::loadSessionData(SoftwareIntegrationModule* module, const std::string& filePathString, std::string& errorMessage ) { @@ -159,7 +159,7 @@ bool AssetHelper::loadSessionData(SoftwareIntegrationModule* module, return true; } -bool AssetHelper::saveSession(const std::string& wantedFileName, std::string& errorMessage) { +bool softwareintegration::Session::saveSession(const std::string& wantedFileName, std::string& errorMessage) { auto softwareIntegrationModule = global::moduleEngine->module(); if (!softwareIntegrationModule) { errorMessage = "Software Integration Module not found."; diff --git a/modules/softwareintegration/assethelper.h b/modules/softwareintegration/session/session.h similarity index 82% rename from modules/softwareintegration/assethelper.h rename to modules/softwareintegration/session/session.h index 55e4cd1d50..8a88b90614 100644 --- a/modules/softwareintegration/assethelper.h +++ b/modules/softwareintegration/session/session.h @@ -22,25 +22,29 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_SOFTWAREINTEGRATION___ASSETHELPER___H__ -#define __OPENSPACE_MODULE_SOFTWAREINTEGRATION___ASSETHELPER___H__ +#ifndef __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SOFTWAREINTEGRATIONSESSION___H__ +#define __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SOFTWAREINTEGRATIONSESSION___H__ namespace openspace { class SoftwareIntegrationModule; -class AssetHelper { +namespace softwareintegration { + +class Session { public: - AssetHelper() = delete; + Session() = delete; static bool loadSessionData(SoftwareIntegrationModule* module, - const std::string& filePathString, - std::string& errorMessage); + const std::string& filePathString, + std::string& errorMessage); static bool saveSession(const std::string& wantedFileName, std::string& errorMessage); }; +} // namespace softwareintegration + } // namespace openspace -#endif // __OPENSPACE_MODULE_SOFTWAREINTEGRATION___ASSETHELPER___H__ +#endif // __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SOFTWAREINTEGRATIONSESSION___H__ diff --git a/modules/softwareintegration/utils.cpp b/modules/softwareintegration/simp/simp.cpp similarity index 92% rename from modules/softwareintegration/utils.cpp rename to modules/softwareintegration/simp/simp.cpp index 35bb37e8ae..e23cfaa74e 100644 --- a/modules/softwareintegration/utils.cpp +++ b/modules/softwareintegration/simp/simp.cpp @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include #include #include @@ -33,52 +33,9 @@ namespace { constexpr const char* _loggerCat = "SoftwareIntegrationMessageFormat"; } // namespace -namespace openspace::softwareintegration { +namespace openspace::softwareintegration::simp { -namespace storage { - -// Anonymous namespace -namespace { - - const std::unordered_map _keyStringFromKey{ - { "DataPoints", Key::DataPoints }, - { "VelocityData", Key::VelocityData }, - { "Colormap", Key::Colormap }, - { "ColormapAttributeData", Key::ColormapAttrData }, - { "LinearSizeAttributeData", Key::LinearSizeAttrData }, - }; - -} // namespace - -bool hasStorageKey(const std::string& key) { - return _keyStringFromKey.count(key) > 0; -} - -Key getStorageKey(const std::string& key) { - if (hasStorageKey(key)) { - return _keyStringFromKey.at(key); - } - - return Key::Unknown; -} - -std::string getStorageKeyString(const Key key) { - auto it = std::find_if( - _keyStringFromKey.begin(), - _keyStringFromKey.end(), - [key](const std::pair& p) { - return key == p.second; - } - ); - if (it == _keyStringFromKey.end()) return ""; - return it->first; -} - -} // namespace storage - -namespace simp { - // Anonymous namespace namespace { @@ -425,6 +382,4 @@ void toByteBuffer(std::vector& byteBuffer, size_t& offset, const std: } -} // namespace simp - -} // namespace openspace::softwareintegration +} // namespace openspace::softwareintegration::simp diff --git a/modules/softwareintegration/utils.h b/modules/softwareintegration/simp/simp.h similarity index 92% rename from modules/softwareintegration/utils.h rename to modules/softwareintegration/simp/simp.h index 7a8bbe0023..a0003ccdf6 100644 --- a/modules/softwareintegration/utils.h +++ b/modules/softwareintegration/simp/simp.h @@ -27,28 +27,8 @@ #include -namespace openspace::softwareintegration { +namespace openspace::softwareintegration::simp { -namespace storage { - -enum class Key : uint8_t { - DataPoints = 0, - VelocityData, - Colormap, - ColormapAttrData, - LinearSizeAttrData, - Unknown -}; - -Key getStorageKey(const std::string& key); - -std::string getStorageKeyString(const Key key); - -bool hasStorageKey(const std::string& key); - -} // namespace storage - -namespace simp { namespace { @@ -189,10 +169,9 @@ void toByteBuffer(std::vector& byteBuffer, size_t& offset, const std: void toByteBuffer(std::vector& byteBuffer, const size_t& offset, const std::vector& value); void toByteBuffer(std::vector& byteBuffer, size_t& offset, const std::vector& value); -} // namespace simp -} // namespace openspace::softwareintegration +} // namespace openspace::softwareintegration::simp -#include "utils.inl" +#include "simp.inl" #endif // __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SIMP___H__ diff --git a/modules/softwareintegration/utils.inl b/modules/softwareintegration/simp/simp.inl similarity index 100% rename from modules/softwareintegration/utils.inl rename to modules/softwareintegration/simp/simp.inl diff --git a/modules/softwareintegration/softwareintegrationmodule.cpp b/modules/softwareintegration/softwareintegrationmodule.cpp index 4c54e0bfa5..fa15c754b6 100644 --- a/modules/softwareintegration/softwareintegrationmodule.cpp +++ b/modules/softwareintegration/softwareintegrationmodule.cpp @@ -24,7 +24,7 @@ #include -#include +#include #include #include #include diff --git a/modules/softwareintegration/softwareintegrationmodule.h b/modules/softwareintegration/softwareintegrationmodule.h index 6be95986bb..67dcf1647c 100644 --- a/modules/softwareintegration/softwareintegrationmodule.h +++ b/modules/softwareintegration/softwareintegrationmodule.h @@ -26,16 +26,20 @@ #define __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SOFTWAREINTEGRATIONMODULE___H__ #include -#include +#include #include #include namespace openspace { -class AssetHelper; +namespace softwareintegration { + +class Session; + +} // namespace softwareintegration class SoftwareIntegrationModule : public OpenSpaceModule { - friend class AssetHelper; + friend class softwareintegration::Session; public: constexpr static const char* Name = "SoftwareIntegration"; diff --git a/modules/softwareintegration/softwareintegrationmodule_lua.inl b/modules/softwareintegration/softwareintegrationmodule_lua.inl index cc1b0c6011..de57629f6e 100644 --- a/modules/softwareintegration/softwareintegrationmodule_lua.inl +++ b/modules/softwareintegration/softwareintegrationmodule_lua.inl @@ -22,7 +22,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include #include #include #include @@ -47,7 +47,7 @@ namespace { } std::string errorMessage; - if (!AssetHelper::loadSessionData(softwareIntegrationModule, filePath, errorMessage)) { + if (!softwareintegration::Session::loadSessionData(softwareIntegrationModule, filePath, errorMessage)) { return errorMessage; } else { @@ -67,7 +67,7 @@ namespace { } std::string errorMessage; - if (!AssetHelper::saveSession(wantedFilePath, errorMessage)) { + if (!softwareintegration::Session::saveSession(wantedFilePath, errorMessage)) { LERRORC("SoftwareIntegration::saveSession", errorMessage); return errorMessage; } diff --git a/modules/softwareintegration/interruptibleconcurrentqueue.h b/modules/softwareintegration/utils/interruptibleconcurrentqueue.h similarity index 100% rename from modules/softwareintegration/interruptibleconcurrentqueue.h rename to modules/softwareintegration/utils/interruptibleconcurrentqueue.h diff --git a/modules/softwareintegration/interruptibleconcurrentqueue.inl b/modules/softwareintegration/utils/interruptibleconcurrentqueue.inl similarity index 100% rename from modules/softwareintegration/interruptibleconcurrentqueue.inl rename to modules/softwareintegration/utils/interruptibleconcurrentqueue.inl diff --git a/modules/softwareintegration/syncablestorage.cpp b/modules/softwareintegration/utils/syncablestorage.cpp similarity index 91% rename from modules/softwareintegration/syncablestorage.cpp rename to modules/softwareintegration/utils/syncablestorage.cpp index 22490a35fb..8e78b4c214 100644 --- a/modules/softwareintegration/syncablestorage.cpp +++ b/modules/softwareintegration/utils/syncablestorage.cpp @@ -22,9 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include +#include -#include #include #include #include @@ -37,6 +36,47 @@ constexpr const char* _loggerCat = "SyncableStorage"; namespace openspace { +namespace softwareintegration::storage { + +// Anonymous namespace +namespace { + + const std::unordered_map _keyStringFromKey{ + { "DataPoints", Key::DataPoints }, + { "VelocityData", Key::VelocityData }, + { "Colormap", Key::Colormap }, + { "ColormapAttributeData", Key::ColormapAttrData }, + { "LinearSizeAttributeData", Key::LinearSizeAttrData }, + }; + +} // namespace + +bool hasStorageKey(const std::string& key) { + return _keyStringFromKey.count(key) > 0; +} + +Key getStorageKey(const std::string& key) { + if (hasStorageKey(key)) { + return _keyStringFromKey.at(key); + } + + return Key::Unknown; +} + +std::string getStorageKeyString(const Key key) { + auto it = std::find_if( + _keyStringFromKey.begin(), + _keyStringFromKey.end(), + [key](const std::pair& p) { + return key == p.second; + } + ); + if (it == _keyStringFromKey.end()) return ""; + return it->first; +} + +} // namespace softwareintegration::storage + using namespace softwareintegration; /* ============== SyncEngine functions ============== */ diff --git a/modules/softwareintegration/syncablestorage.h b/modules/softwareintegration/utils/syncablestorage.h similarity index 92% rename from modules/softwareintegration/syncablestorage.h rename to modules/softwareintegration/utils/syncablestorage.h index 4686b93576..3e6e08c75e 100644 --- a/modules/softwareintegration/syncablestorage.h +++ b/modules/softwareintegration/utils/syncablestorage.h @@ -27,13 +27,32 @@ #include -#include +#include #include #include namespace openspace { +namespace softwareintegration::storage { + +enum class Key : uint8_t { + DataPoints = 0, + VelocityData, + Colormap, + ColormapAttrData, + LinearSizeAttrData, + Unknown +}; + +Key getStorageKey(const std::string& key); + +std::string getStorageKeyString(const Key key); + +bool hasStorageKey(const std::string& key); + +} // namespace softwareintegration::storage + using namespace softwareintegration; class SyncableStorage : public Syncable { diff --git a/modules/softwareintegration/syncablestorage.inl b/modules/softwareintegration/utils/syncablestorage.inl similarity index 100% rename from modules/softwareintegration/syncablestorage.inl rename to modules/softwareintegration/utils/syncablestorage.inl