Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ This should be somewhat self-explanatory since the functions are well-named, but
2. If not, try to either find a compatible `ScheduleTypeLimits` or create a new one to set it to the `Schedule`
* **That part can be quite confusing the first time you realize it happens behind the scenes when you call a setter and your `Schedule` now has a `ScheduleTypeLimits`. This is also why you can't have a setter take in a `const Schedule&`**: `bool setOpeningAreaFractionSchedule(Schedule&);` works, but `bool setOpeningAreaFractionSchedule(const Schedule&);` doesn't, since the `Schedule` passed can be modified.

Both of these flow branches will call into `getScheduleType`, which uses the entries you have manually set in the ScheduleTypeRegistrySingleton around [here](https://github.com/NREL/OpenStudio/blob/develop/src/model/ScheduleTypeRegistry.cpp#L118-L125):
Both of these flow branches will call into `getScheduleType`, which uses the entries you have manually set in the ScheduleTypeRegistry around [here](https://github.com/NREL/OpenStudio/blob/develop/src/model/ScheduleTypeRegistry.cpp#L118-L125):

```c++
ScheduleTypeRegistrySingleton::ScheduleTypeRegistrySingleton()
ScheduleTypeRegistry::ScheduleTypeRegistry()
{
// className, scheduleDisplayName, scheduleRelationshipName, isContinuous, unitType, lowerLimitValue, upperLimitValue;

Expand All @@ -133,6 +133,6 @@ For 1) above , the definition of [isCompatible](https://github.com/NREL/OpenStud

### When you don't already have a `ScheduleTypeLimits` assigned

For 2) when you are using a `Schedule` that doesn't already have a `ScheduleTypeLimits`, it'll loop on all `ScheduleTypeLimits` in the model, and call `isCompatible` on them and return the first one that matches the requirements.
For 2) when you are using a `Schedule` that doesn't already have a `ScheduleTypeLimits`, it'll loop on all `ScheduleTypeLimits` in the model, and call `isCompatible` on them and return the first one that matches the requirements.

**If not it'll create a new one with the requirements**. cf [ScheduleTypeRegistrySingleton::getOrCreateScheduleTypeLimits](https://github.com/NREL/OpenStudio/blob/8ae4d883ed1a6ba704aa8b60003646de69a00f39/src/model/ScheduleTypeRegistry.cpp#L77-L116)
**If not it'll create a new one with the requirements**. cf [ScheduleTypeRegistry::getOrCreateScheduleTypeLimits](https://github.com/NREL/OpenStudio/blob/8ae4d883ed1a6ba704aa8b60003646de69a00f39/src/model/ScheduleTypeRegistry.cpp#L77-L116)
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ def gtestGetterSetters
def aux()
result = String.new
if @hasScheduleFields
result << "// TODO: Copy-paste this starter text into ScheduleTypeRegistry.cpp, in the ScheduleTypeRegistrySingleton\n"
result << "// TODO: Copy-paste this starter text into ScheduleTypeRegistry.cpp\n"
result << "// constructor. Read the EnergyPlus Input-Output reference and fill out the ScheduleTypeLimits information\n"
result << "// accordingly.\n"
@nonextensibleFields.each { |field|
Expand Down
1 change: 0 additions & 1 deletion src/energyplus/EnergyPlus.i
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

// Ignore Static Initializers
%ignore openstudio::energyplus::detail;
%ignore StaticInitializer;
%ignore ForwardTranslatorInitializer;
%ignore openstudio::energyplus::detail::ForwardTranslatorInitializer;

Expand Down
480 changes: 238 additions & 242 deletions src/generateiddfactory/GenerateIddFactory.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/generateiddfactory/IddFileFactoryData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void IddFileFactoryData::parseFile(const path& outPath, const std::string& outFi
}

// register objects with CallbackMap
cxxFile->tempFile << "void IddFactorySingleton::register" << fileName() << "ObjectsInCallbackMap() {" << '\n';
cxxFile->tempFile << "void IddFactory::register" << fileName() << "ObjectsInCallbackMap() {" << '\n';
for (const StringPair& objectName : objectNames()) {
cxxFile->tempFile << " m_callbackMap.insert(IddObjectCallbackMap::value_type(IddObjectType::" << objectName.first << ",create"
<< objectName.first << "IddObject));" << '\n';
Expand Down
2 changes: 0 additions & 2 deletions src/model/OutputMeter_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "ModelObject_Impl.hpp"
#include "OutputMeter.hpp"

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

namespace openstudio {

class EndUseType;
Expand Down
2 changes: 1 addition & 1 deletion src/model/Schedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace model {
* \li OS:Schedule:VariableInterval
*
* For detailed information on ScheduleTypeLimits, please see ScheduleBase and
* \link ScheduleTypeRegistrySingleton ScheduleTypeRegistry \endlink. In general, ModelObject
* \link ScheduleTypeRegistry ScheduleTypeRegistry \endlink. In general, ModelObject
* setters that take a Schedule will fail if the ScheduleTypeLimits are set and are incompatible
* with the proposed use. This ensures that the Schedule is written using units and bounds
* expected by the user object (e.g. fractional for lighting schedules, W for people activity
Expand Down
2 changes: 1 addition & 1 deletion src/model/ScheduleBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace model {
/** ScheduleBase is a ResourceObject that serves as a base class for Schedule and ScheduleDay,
* that is, objects with ScheduleTypeLimits. This class provides getters and setters for
* ScheduleTypeLimits. Note that while users can explicitly set their own ScheduleTypeLimits,
* we recommend using the \link ScheduleTypeRegistrySingleton ScheduleTypeRegistry\endlink and
* we recommend using the \link ScheduleTypeRegistry ScheduleTypeRegistry\endlink and
* related non-member functions, or letting user \link ModelObject ModelObjects\endlink set
* this field, instead. */
class MODEL_API ScheduleBase : public ResourceObject
Expand Down
17 changes: 11 additions & 6 deletions src/model/ScheduleTypeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
namespace openstudio {
namespace model {

std::vector<std::string> ScheduleTypeRegistrySingleton::classNames() const {
std::vector<std::string> ScheduleTypeRegistry::classNames() const {
StringVector result;
for (const ClassNameToScheduleTypesMap::value_type& p : m_classNameToScheduleTypesMap) {
result.push_back(p.first);
}
return result;
}

std::vector<ScheduleType> ScheduleTypeRegistrySingleton::getScheduleTypesByClassName(const std::string& className) const {
std::vector<ScheduleType> ScheduleTypeRegistry::getScheduleTypesByClassName(const std::string& className) const {
ScheduleTypeVector result;
auto it = m_classNameToScheduleTypesMap.find(className);
if (it != m_classNameToScheduleTypesMap.end()) {
Expand All @@ -34,7 +34,7 @@ namespace model {
return result;
}

ScheduleType ScheduleTypeRegistrySingleton::getScheduleType(const std::string& className, const std::string& scheduleDisplayName) const {
ScheduleType ScheduleTypeRegistry::getScheduleType(const std::string& className, const std::string& scheduleDisplayName) const {
ScheduleTypeVector scheduleTypes = getScheduleTypesByClassName(className);
for (const ScheduleType& scheduleType : scheduleTypes) {
if (scheduleType.scheduleDisplayName == scheduleDisplayName) {
Expand All @@ -45,7 +45,7 @@ namespace model {
return {};
}

ScheduleTypeLimits ScheduleTypeRegistrySingleton::getOrCreateScheduleTypeLimits(const ScheduleType& scheduleType, Model& model) const {
ScheduleTypeLimits ScheduleTypeRegistry::getOrCreateScheduleTypeLimits(const ScheduleType& scheduleType, Model& model) const {
std::string defaultName = getDefaultName(scheduleType);

// DLM: I do not understand why both upper and lower limit have to be set to reuse this?
Expand Down Expand Up @@ -83,7 +83,12 @@ namespace model {
return scheduleTypeLimits;
}

ScheduleTypeRegistrySingleton::ScheduleTypeRegistrySingleton() {
ScheduleTypeRegistry& ScheduleTypeRegistry::instance() {
static ScheduleTypeRegistry instance;
return instance;
}

ScheduleTypeRegistry::ScheduleTypeRegistry() {
// className, scheduleDisplayName, scheduleRelationshipName, isContinuous, unitType, lowerLimitValue, upperLimitValue;

const ScheduleType scheduleTypes[] = {
Expand Down Expand Up @@ -604,7 +609,7 @@ namespace model {
}
}

std::string ScheduleTypeRegistrySingleton::getDefaultName(const ScheduleType& scheduleType) const {
std::string ScheduleTypeRegistry::getDefaultName(const ScheduleType& scheduleType) const {
std::string result = scheduleType.unitType;
if (result.empty()) {
if (scheduleType.isContinuous) {
Expand Down
38 changes: 18 additions & 20 deletions src/model/ScheduleTypeRegistry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "ModelAPI.hpp"

#include "../utilities/core/Singleton.hpp"
#include "../utilities/core/Logger.hpp"

#include <map>
Expand All @@ -30,7 +29,7 @@ namespace model {
{
/** The name of a class that can point to a schedule. */
std::string className;
/** The display name of that schedule (which is used as a key in ScheduleTypeRegistrySingleton,
/** The display name of that schedule (which is used as a key in ScheduleTypeRegistry,
* and is also intented for use in UI displays). */
std::string scheduleDisplayName;
/** The name of the Relationship that points from the user (of type className) to the Schedule. */
Expand All @@ -54,17 +53,17 @@ namespace model {
* \relates ScheduleType */
MODEL_API bool isCompatible(const ScheduleType& scheduleType, const ScheduleTypeLimits& candidate, bool isStringent = false);

/** Singleton class that contains a registry of all types of schedules that can exist in a Model.
* Do not use directly, but rather, use the ScheduleTypeRegistry typedef (e.g.
* \code
* ScheduleType st = ScheduleTypeRegistry::instance().getScheduleType("Lights","Lighting")
* \endcode
* ). */
class MODEL_API ScheduleTypeRegistrySingleton
/** Singleton class that contains a registry of all types of schedules that can exist in a Model. */
class MODEL_API ScheduleTypeRegistry
{
friend class Singleton<ScheduleTypeRegistrySingleton>;

public:
static ScheduleTypeRegistry& instance();

ScheduleTypeRegistry(const ScheduleTypeRegistry& other) = delete;
ScheduleTypeRegistry(ScheduleTypeRegistry&& other) = delete;
ScheduleTypeRegistry& operator=(const ScheduleTypeRegistry&) = delete;
ScheduleTypeRegistry& operator=(ScheduleTypeRegistry&&) = delete;

/** Returns the names of classes that have \link ScheduleType ScheduleTypes \endlink registered
* with the ScheduleTypeRegistry. */
std::vector<std::string> classNames() const;
Expand All @@ -85,34 +84,33 @@ namespace model {
std::string getDefaultName(const ScheduleType& scheduleType) const;

private:
ScheduleTypeRegistry();
~ScheduleTypeRegistry() = default;

REGISTER_LOGGER("openstudio.model.ScheduleTypeRegistry");
ScheduleTypeRegistrySingleton();

using ClassNameToScheduleTypesMap = std::map<std::string, std::vector<ScheduleType>>;
ClassNameToScheduleTypesMap m_classNameToScheduleTypesMap;
};

/** \relates ScheduleTypeRegistrySingleton */
using ScheduleTypeRegistry = openstudio::Singleton<ScheduleTypeRegistrySingleton>;

/** Returns true if candidate is consistent with the ScheduleType that corresponds to className
* and scheduleRelationshipName. Throws if there is no such ScheduleType.
* \relates ScheduleTypeRegistrySingleton */
* \relates ScheduleTypeRegistry */
MODEL_API bool isCompatible(const std::string& className, const std::string& scheduleDisplayName, const ScheduleTypeLimits& candidate);

/** If schedule.scheduleTypeLimtis(), returns true if that ScheduleTypeLimits isCompatible and
* otherwise returns false. Otherwise, uses
* ScheduleTypeRegistrySingleton::getOrCreateScheduleTypeLimits to find an appropriate
* ScheduleTypeRegistry::getOrCreateScheduleTypeLimits to find an appropriate
* ScheduleTypeLimits and then calls Schedule::setScheduleTypeLimtis, which should succeed in
* this case. This method is used by all of the ModelObject methods that set schedules.
* \relates ScheduleTypeRegistrySingleton */
* \relates ScheduleTypeRegistry */
MODEL_API bool checkOrAssignScheduleTypeLimits(const std::string& className, const std::string& scheduleDisplayName, Schedule& schedule);

/** Returns all of the ScheduleTypeLimtis already in model that are \link isCompatible
* compatible\endlink with className and scheduleDisplayName. May be used instead of
* ScheduleTypeRegistrySingleton::getOrCreateScheduleTypeLimits to reduce the number of
* ScheduleTypeRegistry::getOrCreateScheduleTypeLimits to reduce the number of
* ScheduleTypeLimits that are ultimately created and present in a model.
* \relates ScheduleTypeRegistrySingleton */
* \relates ScheduleTypeRegistry */
MODEL_API std::vector<ScheduleTypeLimits> getCompatibleScheduleTypeLimits(const Model& model, const std::string& className,
const std::string& scheduleDisplayName);

Expand Down
3 changes: 0 additions & 3 deletions src/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ set(core_src
core/Queue.hpp
core/RubyInterpreter.hpp
core/RubyException.hpp
core/Singleton.hpp
core/StaticInitializer.hpp
core/String.hpp
core/String.cpp
core/StringHelpers.hpp
Expand Down Expand Up @@ -398,7 +396,6 @@ set(${target_name}_swig_src
core/Exception.i
core/Logger.i
core/Path.i
core/Singleton.i
core/System.i
core/UUID.i
core/UnzipFile.i
Expand Down
1 change: 0 additions & 1 deletion src/utilities/core/Core.i
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
%include <OpenStudio.hxx>
%include <utilities/core/ApplicationPathHelpers.hpp>
%include <utilities/core/StringHelpers.hpp>
%include <utilities/core/Singleton.i>
%include <utilities/core/Logger.i>
%include <utilities/core/UUID.i>
%include <utilities/core/Checksum.i>
Expand Down
1 change: 0 additions & 1 deletion src/utilities/core/Enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <set>
#include <map>
#include <vector>
#include "StaticInitializer.hpp"
#include <boost/preprocessor.hpp>
#include <boost/optional.hpp>
#include <boost/algorithm/string/predicate.hpp>
Expand Down
4 changes: 1 addition & 3 deletions src/utilities/core/EnumBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#ifndef UTILITIES_CORE_ENUMBASE_HPP
#define UTILITIES_CORE_ENUMBASE_HPP

#include "StaticInitializer.hpp"

#include <boost/preprocessor.hpp>
#include <boost/optional.hpp>
#include <boost/algorithm/string/predicate.hpp>
Expand All @@ -20,7 +18,7 @@

/** Base class for OPENSTUDIO_ENUMs. Comparison operators use the underlying (integer) value. */
template <typename Enum>
class EnumBase : public ::StaticInitializer<Enum>
class EnumBase
{
public:
/** Default constructor. EnumBase default constructor never actually called; OPENSTUDIO_ENUM-
Expand Down
85 changes: 0 additions & 85 deletions src/utilities/core/Singleton.hpp

This file was deleted.

23 changes: 0 additions & 23 deletions src/utilities/core/Singleton.i

This file was deleted.

Loading
Loading