Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix Broken C# bindings workflow due to Alfalfa addition #5291

Merged
merged 10 commits into from
Nov 7, 2024
4 changes: 2 additions & 2 deletions .github/workflows/buildCSharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
name: [Ubuntu, macOS, macOS_arm64, Windows64, Windows32]
include:
- name: Ubuntu
os: ubuntu-20.04
os: ubuntu-22.04
- name: macOS
os: macos-11
os: macos-13
- name: macOS_arm64
os: macos-14
- name: Windows64
Expand Down
1 change: 1 addition & 0 deletions ProjectMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ macro(MAKE_SWIG_TARGET NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PARENT_S

set( model_names
OpenStudioMeasure
OpenStudioAlfalfa
OpenStudioModel
OpenStudioModelAirflow
OpenStudioModelAvailabilityManager
Expand Down
1 change: 1 addition & 0 deletions csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ set(translator_wrappers

set(model_wrappers
csharp_OpenStudioMeasure_wrap.cxx
csharp_OpenStudioAlfalfa_wrap.cxx
csharp_OpenStudioModel_wrap.cxx
csharp_OpenStudioModelAirflow_wrap.cxx
csharp_OpenStudioModelAvailabilityManager_wrap.cxx
Expand Down
8 changes: 4 additions & 4 deletions src/alfalfa/Alfalfa.i
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
#endif

%include <utilities/UtilitiesAPI.hpp>
#define ALFALFA_API

%include <utilities/core/CommonInclude.i>
%import <utilities/core/CommonImport.i>
%import <utilities/Utilities.i>

%ignore openstudio::alfalfa::detail;

%{
#include <alfalfa/AlfalfaAPI.hpp>
#include <alfalfa/AlfalfaComponent.hpp>
#include <alfalfa/AlfalfaActuator.hpp>
#include <alfalfa/AlfalfaConstant.hpp>
Expand All @@ -33,15 +34,14 @@
using namespace openstudio::alfalfa;
%}

%ignore openstudio::alfalfa::ComponentBase;
%ignore openstudio::alfalfa::AlfalfaComponentBase;
%ignore openstudio::alfalfa::AlfalfaActuator::clone;
%ignore openstudio::alfalfa::AlfalfaConstant::clone;
%ignore openstudio::alfalfa::AlfalfaMeter::clone;
%ignore openstudio::alfalfa::AlfalfaGlobalVariable::clone;
%ignore openstudio::alfalfa::AlfalfaOutputVariable::clone;

%include <alfalfa/AlfalfaAPI.hpp>
%include <alfalfa/ComponentBase.hpp>
%include <alfalfa/AlfalfaComponentBase.hpp>
%include <alfalfa/AlfalfaComponent.hpp>
%include <alfalfa/AlfalfaActuator.hpp>
%include <alfalfa/AlfalfaConstant.hpp>
Expand Down
14 changes: 7 additions & 7 deletions src/alfalfa/AlfalfaActuator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#define ALFALFA_COMPONENT_ACTUATOR_HPP

#include "AlfalfaAPI.hpp"
#include "ComponentBase.hpp"
#include "AlfalfaComponentBase.hpp"

#include "../utilities/idf/IdfObject.hpp"

namespace openstudio {
namespace alfalfa {
class ALFALFA_API AlfalfaActuator : public ComponentBase
class ALFALFA_API AlfalfaActuator : public AlfalfaComponentBase
{
public:
/**
Expand All @@ -26,15 +26,15 @@ namespace alfalfa {

Json::Value toJSON() const override;

ComponentCapability capability() const override {
return ComponentCapability::Bidirectional;
AlfalfaComponentCapability capability() const override {
return AlfalfaComponentCapability::Bidirectional;
}

ComponentType type() const override {
return ComponentType::Actuator;
AlfalfaComponentType type() const override {
return AlfalfaComponentType::Actuator;
}

std::unique_ptr<ComponentBase> clone() const override {
std::unique_ptr<AlfalfaComponentBase> clone() const override {
return std::make_unique<AlfalfaActuator>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/alfalfa/AlfalfaComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ namespace alfalfa {
return m_component->toJSON();
}

ComponentCapability AlfalfaComponent::capability() const {
AlfalfaComponentCapability AlfalfaComponent::capability() const {
return m_component->capability();
}

ComponentType AlfalfaComponent::type() const {
AlfalfaComponentType AlfalfaComponent::type() const {
return m_component->type();
}

Expand Down
10 changes: 5 additions & 5 deletions src/alfalfa/AlfalfaComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include <type_traits>

#include "AlfalfaAPI.hpp"
#include "ComponentBase.hpp"
#include "AlfalfaComponentBase.hpp"

namespace openstudio {
namespace alfalfa {
class ALFALFA_API AlfalfaComponent
{
public:
template <typename T, std::enable_if_t<std::is_base_of<ComponentBase, T>::value, bool> = true>
template <typename T, std::enable_if_t<std::is_base_of<AlfalfaComponentBase, T>::value, bool> = true>
AlfalfaComponent(T component) : m_component(std::make_unique<T>(std::move(component))) {}

AlfalfaComponent(const AlfalfaComponent& other) : m_component(other.m_component->clone()) {}
Expand All @@ -32,9 +32,9 @@ namespace alfalfa {

Json::Value toJSON() const;

ComponentCapability capability() const;
AlfalfaComponentCapability capability() const;

ComponentType type() const;
AlfalfaComponentType type() const;

std::string typeName() const;

Expand All @@ -46,7 +46,7 @@ namespace alfalfa {

private:
AlfalfaComponent() = default;
std::unique_ptr<ComponentBase> m_component;
std::unique_ptr<AlfalfaComponentBase> m_component;
};

inline bool operator==(const AlfalfaComponent& lhs, const AlfalfaComponent& rhs) {
Expand Down
15 changes: 15 additions & 0 deletions src/alfalfa/AlfalfaComponentBase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "AlfalfaComponentBase.hpp"

namespace openstudio {
namespace alfalfa {

bool AlfalfaComponentBase::canInput() const {
return capability() == AlfalfaComponentCapability::Bidirectional || capability() == AlfalfaComponentCapability::Input;
}

bool AlfalfaComponentBase::canOutput() const {
return capability() == AlfalfaComponentCapability::Bidirectional || capability() == AlfalfaComponentCapability::Output;
}

} // namespace alfalfa
} // namespace openstudio
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,31 @@

#include "AlfalfaAPI.hpp"

#include "../utilities/core/Enum.hpp"
#include "../utilities/data/DataEnums.hpp"

#include <json/json.h>

namespace openstudio {
namespace alfalfa {

OPENSTUDIO_ENUM(ComponentCapability, ((Input))((Output))((Bidirectional)))

OPENSTUDIO_ENUM(ComponentType, ((Actuator))((Constant))((Meter))((OutputVariable))((GlobalVariable)))

class ALFALFA_API ComponentBase
class ALFALFA_API AlfalfaComponentBase
{
public:
virtual ~ComponentBase() = default;
virtual ~AlfalfaComponentBase() = default;

virtual Json::Value toJSON() const = 0;

virtual ComponentCapability capability() const = 0;
virtual AlfalfaComponentCapability capability() const = 0;

virtual ComponentType type() const = 0;
virtual AlfalfaComponentType type() const = 0;

virtual std::string typeName() const {
return type().valueName();
}

virtual std::string deriveName() const = 0;

virtual std::unique_ptr<ComponentBase> clone() const = 0;
virtual std::unique_ptr<AlfalfaComponentBase> clone() const = 0;

virtual bool canInput() const;

Expand Down
14 changes: 7 additions & 7 deletions src/alfalfa/AlfalfaConstant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

#include "AlfalfaAPI.hpp"

#include "ComponentBase.hpp"
#include "AlfalfaComponentBase.hpp"

namespace openstudio {
namespace alfalfa {
class ALFALFA_API AlfalfaConstant : public ComponentBase
class ALFALFA_API AlfalfaConstant : public AlfalfaComponentBase
{
public:
/**
Expand All @@ -19,15 +19,15 @@ namespace alfalfa {

Json::Value toJSON() const override;

ComponentCapability capability() const override {
return ComponentCapability::Output;
AlfalfaComponentCapability capability() const override {
return AlfalfaComponentCapability::Output;
}

ComponentType type() const override {
return ComponentType::Constant;
AlfalfaComponentType type() const override {
return AlfalfaComponentType::Constant;
}

std::unique_ptr<ComponentBase> clone() const override {
std::unique_ptr<AlfalfaComponentBase> clone() const override {
return std::make_unique<AlfalfaConstant>(*this);
}

Expand Down
14 changes: 7 additions & 7 deletions src/alfalfa/AlfalfaGlobalVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include "AlfalfaAPI.hpp"

#include "ComponentBase.hpp"
#include "AlfalfaComponentBase.hpp"

#include "../utilities/idf/IdfObject.hpp"

namespace openstudio {
namespace alfalfa {
class ALFALFA_API AlfalfaGlobalVariable : public ComponentBase
class ALFALFA_API AlfalfaGlobalVariable : public AlfalfaComponentBase
{
public:
/**
Expand All @@ -27,15 +27,15 @@ namespace alfalfa {

Json::Value toJSON() const override;

ComponentCapability capability() const override {
return ComponentCapability::Bidirectional;
AlfalfaComponentCapability capability() const override {
return AlfalfaComponentCapability::Bidirectional;
}

ComponentType type() const override {
return ComponentType::GlobalVariable;
AlfalfaComponentType type() const override {
return AlfalfaComponentType::GlobalVariable;
}

std::unique_ptr<ComponentBase> clone() const override {
std::unique_ptr<AlfalfaComponentBase> clone() const override {
return std::make_unique<AlfalfaGlobalVariable>(*this);
}

Expand Down
14 changes: 7 additions & 7 deletions src/alfalfa/AlfalfaMeter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include "AlfalfaAPI.hpp"

#include "ComponentBase.hpp"
#include "AlfalfaComponentBase.hpp"

#include "../utilities/idf/IdfObject.hpp"

namespace openstudio {
namespace alfalfa {
class ALFALFA_API AlfalfaMeter : public ComponentBase
class ALFALFA_API AlfalfaMeter : public AlfalfaComponentBase
{
public:
/**
Expand All @@ -27,15 +27,15 @@ namespace alfalfa {

Json::Value toJSON() const override;

ComponentCapability capability() const override {
return ComponentCapability::Output;
AlfalfaComponentCapability capability() const override {
return AlfalfaComponentCapability::Output;
}

ComponentType type() const override {
return ComponentType::Meter;
AlfalfaComponentType type() const override {
return AlfalfaComponentType::Meter;
}

std::unique_ptr<ComponentBase> clone() const override {
std::unique_ptr<AlfalfaComponentBase> clone() const override {
return std::make_unique<AlfalfaMeter>(*this);
}

Expand Down
14 changes: 7 additions & 7 deletions src/alfalfa/AlfalfaOutputVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include "AlfalfaAPI.hpp"

#include "ComponentBase.hpp"
#include "AlfalfaComponentBase.hpp"

#include "../utilities/idf/IdfObject.hpp"

namespace openstudio {
namespace alfalfa {
class ALFALFA_API AlfalfaOutputVariable : public ComponentBase
class ALFALFA_API AlfalfaOutputVariable : public AlfalfaComponentBase
{
public:
/**
Expand All @@ -27,15 +27,15 @@ namespace alfalfa {

Json::Value toJSON() const override;

ComponentCapability capability() const override {
return ComponentCapability::Output;
AlfalfaComponentCapability capability() const override {
return AlfalfaComponentCapability::Output;
}

ComponentType type() const override {
return ComponentType::OutputVariable;
AlfalfaComponentType type() const override {
return AlfalfaComponentType::OutputVariable;
}

std::unique_ptr<ComponentBase> clone() const override {
std::unique_ptr<AlfalfaComponentBase> clone() const override {
return std::make_unique<AlfalfaOutputVariable>(*this);
}

Expand Down
6 changes: 3 additions & 3 deletions src/alfalfa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/)

set(${target_name}_src
AlfalfaAPI.hpp
ComponentBase.cpp
ComponentBase.hpp
AlfalfaComponentBase.cpp
AlfalfaComponentBase.hpp
AlfalfaComponent.hpp
AlfalfaComponent.cpp
AlfalfaConstant.hpp
Expand Down Expand Up @@ -58,4 +58,4 @@ if(BUILD_TESTING)
endif()


MAKE_SWIG_TARGET(OpenStudioAlfalfa alfalfa "${CMAKE_CURRENT_SOURCE_DIR}/Alfalfa.i" "${${target_name}_swig_src}" ${target_name} OpenStudioModel)
MAKE_SWIG_TARGET(OpenStudioAlfalfa alfalfa "${CMAKE_CURRENT_SOURCE_DIR}/Alfalfa.i" "${${target_name}_swig_src}" ${target_name} OpenStudioOSVersion)
15 changes: 0 additions & 15 deletions src/alfalfa/ComponentBase.cpp

This file was deleted.

Loading