Skip to content

Site:GroundTemperature:XXX are unique-objects but constructor is public #5482

@jmarrec

Description

@jmarrec

Issue overview

I found this through openstudio-standards: NREL/openstudio-standards#2006

Current Behavior

You CAN instantiate these objects manually currently when you really should not.

Expected Behavior

All unique-objects should have a protected constructor so it doesn't end up in swig.

This one for eg:

explicit SiteGroundTemperatureDeep(Model& model);

Steps to Reproduce

m = OpenStudio::Model::Model.new

obj_types = factory.objects.select{|o| o.name.start_with?('OS:Site:Ground') && o.properties.unique }.map(&:name)
=> ["OS:Site:GroundTemperature:BuildingSurface", "OS:Site:GroundTemperature:FCfactorMethod", "OS:Site:GroundTemperature:Shallow", "OS:Site:GroundTemperature:Deep", "OS:Site:GroundReflectance"]

obj_types.each do |obj_type|
  class_name = "OpenStudio::Model::#{obj_type.gsub('OS:', '').gsub(':', '')}"
  klass = Object.const_get(class_name)
  begin
     obj = klass.new(m)
     puts "Failed for #{class_name}"
  rescue
     puts "Ok for #{class_name}"
  end
end
Failed for OpenStudio::Model::SiteGroundTemperatureBuildingSurface
Failed for OpenStudio::Model::SiteGroundTemperatureFCfactorMethod
Failed for OpenStudio::Model::SiteGroundTemperatureShallow
Failed for OpenStudio::Model::SiteGroundTemperatureDeep
Ok for OpenStudio::Model::SiteGroundReflectance

Possible Solution

Make the ctors protected if unique object. I would advise to check all others unique objects really.

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version): All
  • Version of OpenStudio (if using an intermediate build, include SHA): 3.10.0

Context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions