Conversation
Previously, we used the openstudio::Singleton template to create the singleton named Logger. This implementation suffered a bug described in #4847, where the singleton was not global across the ScriptEngine DLL boundary. This change is a non templated implementation of Logger. The design is identical to openstudio::Singleton<LoggerSingleton>, but does not suffer the non-global issue. ref #4847
UtilitiesAPI.hpp needs to be included by SWIG so that the correct declspecs are used for the global logger. Previously, UTILITIES_API was just #define OPENSTUDIO_API, therefore the dll export decorator was not used.
8413d16 to
442cd38
Compare
jmarrec
commented
Mar 25, 2024
src/utilities/core/Logger.hpp
Outdated
Comment on lines
11
to
12
| #include "Compare.hpp" // NOTE that this this is not needed for this header but so many compilation errors if I omit it | ||
| // since other files transitively use Compare |
Collaborator
Author
There was a problem hiding this comment.
An unfortunate discovery. Cleaning up ours headers would be good, but that's not what I'm trying to achieve here.
src/utilities/core/Logger.hpp
Outdated
|
|
||
| private: | ||
| static std::shared_ptr<LoggerImpl> obj; | ||
| std::shared_ptr<detail::Logger_Impl> m_impl; |
Collaborator
Author
There was a problem hiding this comment.
Given that the Logger is a Meyers singleton, I'm not sure whether the Logger_Impl class is really needed at all. But it feels familiar at least, and can allow us to shorten the public includes.
The dowside is that there's an extra method call for each (the forward to impl)
Contributor
There was a problem hiding this comment.
I agree, I don't think we really need an Impl at all.
src/utilities/core/Logger.cpp
Outdated
Comment on lines
136
to
140
| Logger::Logger() : m_impl(std::shared_ptr<detail::Logger_Impl>(new detail::Logger_Impl())) {} | ||
|
|
||
| Logger& Logger::instance() { | ||
| static Logger instance; | ||
| return instance; |
Collaborator
Author
There was a problem hiding this comment.
Private constructor, and public ::instance()
Collaborator
|
CI Results for a13db45:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request overview
I just want CI to run on it to I'm targeting develop for now, but really this is just a modification of #5110
Pull Request Author
src/model/test)src/energyplus/Test)src/osversion/VersionTranslator.cpp)Labels:
IDDChangeAPIChangePull Request - Ready for CIso that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.