Skip to content

Commit

Permalink
Merge pull request #4912 from NREL/deprecation_handling
Browse files Browse the repository at this point in the history
Deprecation handling - better error messages + compile-time error when time to deprecate
  • Loading branch information
jmarrec authored Jun 29, 2023
2 parents 9daf524 + a1a3eef commit a84c101
Show file tree
Hide file tree
Showing 63 changed files with 987 additions and 853 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ set(ENERGYPLUS_REPO "NREL")
set(RADIANCE_VERSION "5.0.a.12")

# configure file with version information
configure_file(${PROJECT_SOURCE_DIR}/OpenStudio.in ${PROJECT_BINARY_DIR}/src/OpenStudio.hxx)
configure_file(${PROJECT_SOURCE_DIR}/OpenStudio.hxx.in ${PROJECT_BINARY_DIR}/src/OpenStudio.hxx)

# Deployment target
if(APPLE)
Expand Down
95 changes: 95 additions & 0 deletions OpenStudio.hxx.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#ifndef OPENSTUDIO_HXX
#define OPENSTUDIO_HXX

#include <string>
#include <string_view>

// Support for Ninja on Windows (Ninja isn't multi-configuration while MSVC is)
#cmakedefine NINJA

// Return the version in MAJOR.MINOR.PATCH format (eg '3.0.0')
inline std::string openStudioVersion() {
return "${OPENSTUDIO_VERSION}";
}

// Includes prerelease tag if any, and build sha, eg: '3.0.0-rc1+baflkdhsia'
inline std::string openStudioLongVersion() {
return "${OPENSTUDIO_LONG_VERSION}";
}

inline std::string openStudioVersionMajor() {
return "${PROJECT_VERSION_MAJOR}";
}

inline std::string openStudioVersionMinor() {
return "${PROJECT_VERSION_MINOR}";
}

inline std::string openStudioVersionPatch() {
return "${PROJECT_VERSION_PATCH}";
}

inline std::string openStudioVersionPrerelease() {
return "${PROJECT_VERSION_PRERELEASE}";
}

inline std::string openStudioVersionBuildSHA() {
return "${PROJECT_VERSION_BUILD}";
}

inline int energyPlusVersionMajor() {
return ${ENERGYPLUS_VERSION_MAJOR};
}

inline int energyPlusVersionMinor() {
return ${ENERGYPLUS_VERSION_MINOR};
}

inline int energyPlusVersionPatch() {
return ${ENERGYPLUS_VERSION_PATCH};
}

inline std::string energyPlusVersion() {
return "${ENERGYPLUS_VERSION}";
}

inline std::string energyPlusBuildSHA() {
return "${ENERGYPLUS_BUILD_SHA}";
}

inline std::string rubyLibDir() {
return "${PROJECT_SOURCE_DIR}/ruby/";
}

inline std::string rubyOpenStudioDir() {
#ifdef WIN32
# ifdef NINJA
return "${PROJECT_BINARY_DIR}/ruby/";
# else
return "${PROJECT_BINARY_DIR}/ruby/" + std::string(CMAKE_INTDIR) + "/";
# endif
#else
return "${PROJECT_BINARY_DIR}/ruby/";
#endif
}

namespace openstudio {
namespace detail {

inline constexpr int cx_openStudioVersionMajor() {
return ${PROJECT_VERSION_MAJOR};
}
inline constexpr int cx_openStudioVersionMinor() {
return ${PROJECT_VERSION_MINOR};
}
inline constexpr int cx_openStudioVersionPatch() {
return ${PROJECT_VERSION_PATCH};
}
inline constexpr std::string_view cx_openStudioVersion() {
return "${OPENSTUDIO_VERSION}";
}

} // namespace detail
} // namespace openstudio

#endif // OPENSTUDIO_HXX
89 changes: 0 additions & 89 deletions OpenStudio.in

This file was deleted.

458 changes: 239 additions & 219 deletions developer/ruby/deprecated_methods.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/energyplus/ForwardTranslator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ namespace energyplus {

boost::optional<IdfObject> translateSwimmingPoolIndoor(model::SwimmingPoolIndoor& modelObject);

OS_DEPRECATED boost::optional<IdfObject> translateTableMultiVariableLookup(model::TableMultiVariableLookup& modelObject);
OS_DEPRECATED(3, 5, 0) boost::optional<IdfObject> translateTableMultiVariableLookup(model::TableMultiVariableLookup& modelObject);

boost::optional<IdfObject> translateTableLookup(model::TableLookup& modelObject);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
#include "../../model/GeneratorMicroTurbine.hpp"
#include "../../model/GeneratorMicroTurbine_Impl.hpp"
#include "../../utilities/data/DataEnums.hpp"
#include "../../utilities/core/DeprecatedHelpers.hpp"

using namespace openstudio::model;
using namespace openstudio::energyplus;
Expand Down Expand Up @@ -152,12 +153,14 @@ namespace energyplus {
}

openstudio::energyplus::ComponentType plantLoopType(const PlantLoop& plantLoop) {
LOG_FREE(Warn, "openstudio.energyplus.plantLoopType", "Method is deprecated. Use Loop::componentType instead");
auto logChannel = [] { return "openstudio::energyplus::plantLoopType"; };
DEPRECATED_AT_MSG(3, 6, 0, "Use Loop::componentType instead");
return convertOSEnumToEnum(plantLoop.componentType());
}

openstudio::energyplus::ComponentType componentType(const openstudio::model::HVACComponent& component) {
LOG_FREE(Warn, "openstudio.energyplus.componentType", "Method is deprecated. Use HVACComponent::componentType instead");
auto logChannel = [] { return "openstudio::energyplus::componentType"; };
DEPRECATED_AT_MSG(3, 6, 0, "Use HVACComponent::componentType instead");
return convertOSEnumToEnum(component.componentType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace energyplus {
NONE
};

OS_DEPRECATED ENERGYPLUS_API openstudio::energyplus::ComponentType componentType(const openstudio::model::HVACComponent& component);
OS_DEPRECATED(3, 6, 0) ENERGYPLUS_API openstudio::energyplus::ComponentType componentType(const openstudio::model::HVACComponent& component);

bool _isSetpointComponent(const openstudio::model::PlantLoop& plantLoop, const openstudio::model::ModelObject& comp);

Expand All @@ -54,7 +54,7 @@ namespace energyplus {
* * If there is no cooling, no heating, no "both": None
* * All other cases: "both"
*/
OS_DEPRECATED ENERGYPLUS_API openstudio::energyplus::ComponentType plantLoopType(const openstudio::model::PlantLoop& plantLoop);
OS_DEPRECATED(3, 6, 0) ENERGYPLUS_API openstudio::energyplus::ComponentType plantLoopType(const openstudio::model::PlantLoop& plantLoop);

/* Some plant components air in a containingHVACComponent() and it is that
* container which needs to go on the plant operation scheme. Here is a filter to figure that out.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <utilities/idd/Table_IndependentVariable_FieldEnums.hxx>
#include <utilities/idd/IddEnums.hxx>

#include "../../utilities/core/Deprecated.hpp"
#include "../../utilities/core/DeprecatedHelpers.hpp"

using namespace openstudio::model;

Expand All @@ -33,6 +33,7 @@ namespace energyplus {
#endif

boost::optional<IdfObject> ForwardTranslator::translateTableMultiVariableLookup(TableMultiVariableLookup& modelObject) {
DEPRECATED_AT_MSG(3, 5, 0, "The entire TableMultiVariableLookup will be removed.");
OptionalString s;
OptionalDouble d;
OptionalModelObject temp;
Expand Down
4 changes: 2 additions & 2 deletions src/measure/OSMeasure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ namespace measure {

/** Register this script with SketchUp. Deprecated in favor of registerWithApplication().
* Base class implementation does nothing and returns false. \deprecated */
OS_DEPRECATED virtual bool registerWithSketchUp() const;
OS_DEPRECATED(1, 13, 0) virtual bool registerWithSketchUp() const;

/** Register this script with an Application. Base class implementation does nothing and
* returns false. \deprecated */
OS_DEPRECATED virtual bool registerWithApplication() const;
OS_DEPRECATED(1, 13, 0) virtual bool registerWithApplication() const;

protected:
OSMeasure() = default;
Expand Down
16 changes: 16 additions & 0 deletions src/model/AirConditionerVariableRefrigerantFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include <utilities/idd/OS_AirConditioner_VariableRefrigerantFlow_FieldEnums.hxx>
#include <utilities/idd/IddEnums.hxx>

#include "../utilities/core/DeprecatedHelpers.hpp"

namespace openstudio {

namespace model {
Expand Down Expand Up @@ -3049,58 +3051,72 @@ namespace model {

// DEPRECATED
bool AirConditionerVariableRefrigerantFlow::setRatedTotalCoolingCapacity(double grossRatedTotalCoolingCapacity) {
DEPRECATED_AT_MSG(2, 9, 0, "Use setGrossRatedTotalCoolingCapacity instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->setGrossRatedTotalCoolingCapacity(grossRatedTotalCoolingCapacity);
}

void AirConditionerVariableRefrigerantFlow::autosizeRatedTotalCoolingCapacity() {
DEPRECATED_AT_MSG(2, 9, 0, "Use autosizeGrossRatedTotalCoolingCapacity instead.");
getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->autosizeGrossRatedTotalCoolingCapacity();
}

bool AirConditionerVariableRefrigerantFlow::setRatedCoolingCOP(double grossRatedCoolingCOP) {
DEPRECATED_AT_MSG(2, 9, 0, "Use setGrossRatedCoolingCOP instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->setGrossRatedCoolingCOP(grossRatedCoolingCOP);
}

boost::optional<double> AirConditionerVariableRefrigerantFlow::ratedTotalCoolingCapacity() const {
DEPRECATED_AT_MSG(2, 9, 0, "Use grossRatedTotalCoolingCapacity instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->grossRatedTotalCoolingCapacity();
}

bool AirConditionerVariableRefrigerantFlow::isRatedTotalCoolingCapacityAutosized() const {
DEPRECATED_AT_MSG(2, 9, 0, "Use isGrossRatedTotalCoolingCapacityAutosized instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->isGrossRatedTotalCoolingCapacityAutosized();
}

double AirConditionerVariableRefrigerantFlow::ratedCoolingCOP() const {
DEPRECATED_AT_MSG(2, 9, 0, "Use grossRatedCoolingCOP instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->grossRatedCoolingCOP();
}

boost::optional<double> AirConditionerVariableRefrigerantFlow::ratedTotalHeatingCapacity() const {
DEPRECATED_AT_MSG(2, 9, 0, "Use grossRatedHeatingCapacity instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->grossRatedHeatingCapacity();
}

bool AirConditionerVariableRefrigerantFlow::isRatedTotalHeatingCapacityAutosized() const {
DEPRECATED_AT_MSG(2, 9, 0, "Use isGrossRatedHeatingCapacityAutosized instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->isGrossRatedHeatingCapacityAutosized();
}

double AirConditionerVariableRefrigerantFlow::ratedTotalHeatingCapacitySizingRatio() const {
DEPRECATED_AT_MSG(2, 9, 0, "Use ratedHeatingCapacitySizingRatio instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->ratedHeatingCapacitySizingRatio();
}

bool AirConditionerVariableRefrigerantFlow::setRatedTotalHeatingCapacity(double grossRatedHeatingCapacity) {
DEPRECATED_AT_MSG(2, 9, 0, "Use setGrossRatedHeatingCapacity instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->setGrossRatedHeatingCapacity(grossRatedHeatingCapacity);
}

void AirConditionerVariableRefrigerantFlow::autosizeRatedTotalHeatingCapacity() {
DEPRECATED_AT_MSG(2, 9, 0, "Use autosizeGrossRatedHeatingCapacity instead.");
getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->autosizeGrossRatedHeatingCapacity();
}

bool AirConditionerVariableRefrigerantFlow::setRatedTotalHeatingCapacitySizingRatio(double ratedHeatingCapacitySizingRatio) {
DEPRECATED_AT_MSG(2, 9, 0, "Use setRatedHeatingCapacitySizingRatio instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->setRatedHeatingCapacitySizingRatio(ratedHeatingCapacitySizingRatio);
}

boost::optional<double> AirConditionerVariableRefrigerantFlow::autosizedRatedTotalCoolingCapacity() const {
DEPRECATED_AT_MSG(2, 9, 0, "Use autosizedGrossRatedTotalCoolingCapacity instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->autosizedGrossRatedTotalCoolingCapacity();
}

boost::optional<double> AirConditionerVariableRefrigerantFlow::autosizedRatedTotalHeatingCapacity() const {
DEPRECATED_AT_MSG(2, 9, 0, "Use autosizedGrossRatedHeatingCapacity instead.");
return getImpl<detail::AirConditionerVariableRefrigerantFlow_Impl>()->autosizedGrossRatedHeatingCapacity();
}

Expand Down
Loading

0 comments on commit a84c101

Please sign in to comment.