OpenStudio:utilities
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Protected Types | Protected Member Functions | Related Functions | List of all members
openstudio::Workspace Class Reference

#include <Workspace.hpp>

Public Member Functions

Constructors and Destructors
 Workspace ()
 Default constructor assumes StrictnessLevel::Draft and IddFileType::EnergyPlus. More...
 
 Workspace (StrictnessLevel level)
 Construct IddFileType::EnergyPlus Workspace at StrictnessLevel level. More...
 
 Workspace (StrictnessLevel level, IddFileType iddFileType)
 Default constructor. More...
 
 Workspace (const IdfFile &idfFile, StrictnessLevel level=StrictnessLevel::None)
 Construct from idfFile. More...
 
 Workspace (const Workspace &other)
 Copy constructor, shares data with other Workspace. More...
 
Workspace clone (bool keepHandles=false) const
 Create a deep copy (clone) of all data in this Workspace and return the result in a new Workspace object. More...
 
Workspace cloneSubset (const std::vector< Handle > &handles, bool keepHandles=false, StrictnessLevel level=StrictnessLevel::Draft) const
 Clone just the objects referenced by handles into a new Workspace. More...
 
void swap (Workspace &other)
 Swaps underlying data between this workspace and other. More...
 
virtual ~Workspace ()
 
Getters
StrictnessLevel strictnessLevel () const
 Returns the strictness level under which this Workspace is currently operating. More...
 
VersionString version () const
 Returns the version of this model, as determined by the IddFile header. More...
 
IddFile iddFile () const
 Returns the underlying IddFile (the schema for this Workspace). More...
 
IddFileType iddFileType () const
 Returns the underlying IddFile's IddFileType. More...
 
boost::optional< IddObjectgetIddObject (const IddObjectType &type) const
 Returns the IddObject corresponding to type if it is available from the underlying IddFile. More...
 
boost::optional< std::string > name (const Handle &handle) const
 Returns the object name associated with handle. More...
 
boost::optional< WorkspaceObjectgetObject (Handle handle) const
 Get an object from its handle. More...
 
std::vector< WorkspaceObjectobjects (bool sorted=false) const
 Returns all the objects in this Workspace, excluding any version objects. More...
 
std::vector< Handlehandles (bool sorted=false) const
 Returns the handles of all the objects in this Workspace, excluding those of any version objects. More...
 
std::vector< WorkspaceObjectobjectsWithURLFields () const
 Get all the objects in the current workspace that can have a URL entry, that is, they have a URL IddField in their iddObject(). More...
 
boost::optional< WorkspaceObjectversionObject () const
 Return the version object in this Workspace, if it exists and is unique. More...
 
std::vector< WorkspaceObjectgetObjects (const std::vector< Handle > &handles) const
 Get objects from their handles. More...
 
std::vector< WorkspaceObjectgetObjectsByName (const std::string &name, bool exactMatch=true) const
 Returns all objects named name (case insensitive). More...
 
std::vector< WorkspaceObjectgetObjectsByType (IddObjectType objectType) const
 Returns all objects of type objectType (e.g. More...
 
std::vector< WorkspaceObjectgetObjectsByType (const IddObject &objectType) const
 Returns all objects with .iddObject() == objectType. More...
 
boost::optional< WorkspaceObjectgetObjectByTypeAndName (IddObjectType objectType, const std::string &name) const
 Returns the first object found of type objectType and named name (case insensitive, exact match). More...
 
std::vector< WorkspaceObjectgetObjectsByTypeAndName (IddObjectType objectType, const std::string &name) const
 Returns all objects named name or name plus an integer suffix (case insensitive). More...
 
std::vector< WorkspaceObjectgetObjectsByReference (const std::string &referenceName) const
 Returns all objects in the reference list referenceName. More...
 
std::vector< WorkspaceObjectgetObjectsByReference (const std::vector< std::string > &referenceNames) const
 Returns all objects in at least one of the reference lists in referenceNames. More...
 
boost::optional< WorkspaceObjectgetObjectByNameAndReference (std::string name, const std::vector< std::string > &referenceNames) const
 Returns the first object found that is in at least one of the reference lists in referenceNames and named name (case insensitive, but exact match). More...
 
bool fastNaming () const
 Returns true if fast naming is enabled. More...
 
Setters
bool setStrictnessLevel (StrictnessLevel level)
 Set the StrictnessLevel to level. More...
 
boost::optional< WorkspaceObjectaddObject (const IdfObject &idfObject)
 Add a clone of idfObject to Workspace. More...
 
boost::optional< WorkspaceObjectinsertObject (const IdfObject &idfObject)
 Insert idfObject into this Workspace. More...
 
std::vector< WorkspaceObjectaddObjects (const std::vector< IdfObject > &idfObjects, bool checkNames=true)
 Add clones of idfObjects to Workspace, if possible. More...
 
std::vector< WorkspaceObjectinsertObjects (const std::vector< IdfObject > &idfObjects)
 Insert idfObjects into Workspace, if possible. More...
 
std::vector< WorkspaceObjectaddAndInsertObjects (const std::vector< IdfObject > &objectsToAdd, const std::vector< IdfObject > &objectsToInsert)
 Adds objectToAdd and inserts objectsToInsert into Workspace, if possible. More...
 
std::vector< WorkspaceObjectaddObjects (const std::vector< WorkspaceObject > &objects, bool checkNames=true)
 Add objects to this Workspace, if possible. More...
 
std::vector< WorkspaceObjectinsertObjects (const std::vector< WorkspaceObject > &objects)
 Insert objects into this Workspace, if possible. More...
 
std::vector< WorkspaceObjectaddAndInsertObjects (const std::vector< WorkspaceObject > &objectsToAdd, const std::vector< WorkspaceObject > &objectsToInsert)
 Add objectsToAdd and insert objectToInsert into this Workspace. More...
 
std::vector< WorkspaceObjectaddAndInsertObjects (const std::vector< WorkspaceObject > &objectsToAdd, const std::vector< std::vector< WorkspaceObject > > &objectsToInsert)
 Add objectsToAdd and insert objectsToInsert into this Workspace. More...
 
bool swap (WorkspaceObject &currentObject, IdfObject &newObject, bool keepTargets=false)
 Swap currentObject and newObject. More...
 
bool removeObject (const Handle &handle)
 Remove object from Workspace with the expectation that it will be destructed. More...
 
bool removeObjects (const std::vector< Handle > &handles)
 Remove objects from Workspace with the expectation that they will be destructed. More...
 
void setFastNaming (bool fastNaming)
 Setting fast naming to true reduces the time taken to create and verify the uniqueness of names by using a UUID as the name. More...
 
Object Order
WorkspaceObjectOrder order ()
 Access the WorkspaceOrderObject used by the workspace to provide user-specified ordering of objects. More...
 
const WorkspaceObjectOrder order () const
 Access the WorkspaceOrderObject used by the workspace to provide user-specified ordering of objects. More...
 
std::vector< WorkspaceObjectsort (const std::vector< WorkspaceObject > &objects) const
 Sort objects using order(). More...
 
std::vector< Handlesort (const std::vector< Handle > &handles) const
 Sort handles using order(). More...
 
Queries
unsigned numObjects () const
 Return the total number of objects in the workspace, ignoring version objects. More...
 
unsigned numObjectsOfType (IddObjectType type) const
 Return the number of objects of IddObjectType type in the workspace. More...
 
unsigned numObjectsOfType (const IddObject &objectType) const
 Return the number of objects by full IddObject type. More...
 
bool isMember (const Handle &handle) const
 True if handle corresponds to an object in this workspace. More...
 
bool canBeTarget (const Handle &handle, const std::set< std::string > &referenceListNames) const
 True if an \object-list field referencing the given names can point to this object. More...
 
bool isInIddFile (IddObjectType type) const
 True if the IddObject of type is in iddFile(). More...
 
std::string nextName (const std::string &name, bool fillIn) const
 Returns the next name in the pattern 'name << " " << int'. More...
 
std::string nextName (const IddObjectType &iddObjectType, bool fillIn) const
 Returns the next name in the pattern 'iddObject().name() << " " << int' for iddObjectType. More...
 
bool isValid () const
 Returns true if this Workspace is valid at strictnessLevel(). More...
 
bool isValid (StrictnessLevel level) const
 Returns true if this Workspace is valid, that is, has no errors at or below level. More...
 
ValidityReport validityReport () const
 Returns a ValidityReport for this IdfFile containing all errors at or below strictnessLevel(). More...
 
ValidityReport validityReport (StrictnessLevel level) const
 Returns a ValidityReport for this Workspace containing all errors at or below level. More...
 
bool operator== (const Workspace &other) const
 
bool operator!= (const Workspace &other) const
 
GUI Helpers
bool connectProgressBar (openstudio::ProgressBar &progressBar)
 
bool disconnectProgressBar (openstudio::ProgressBar &progressBar)
 
Type Casing
template<typename T >
cast () const
 Cast to type T. More...
 
template<typename T >
boost::optional< T > optionalCast () const
 Cast to boost::optional<T>. More...
 

Protected Types

typedef detail::Workspace_Impl ImplType
 

Protected Member Functions

virtual void addVersionObject ()
 
std::vector< WorkspaceObjectallObjects () const
 Returns all objects, including the versionObject. More...
 
 Workspace (std::shared_ptr< detail::Workspace_Impl > impl)
 Protected constructor from impl. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, const Workspace &workspace)
 
typedef boost::optional
< Workspace
OptionalWorkspace
 
typedef std::vector< WorkspaceWorkspaceVector
 

Serialization and File Management

bool save (const openstudio::path &p, bool overwrite=false)
 Save this Workspace to path p. More...
 
IdfFile toIdfFile () const
 Returns an IdfFile equivalent to this Workspace. More...
 
std::vector< std::pair< QUrl,
openstudio::path > > 
locateUrls (const std::vector< URLSearchPath > &t_paths, bool t_create_relative_paths, const openstudio::path &t_infile)
 Find and update all relative (and remote) URLs to well defined locations based on the search paths supplied. More...
 
static boost::optional< Workspaceload (const openstudio::path &p)
 Load a Workspace from path using the IddFactory, and choosing iddFileType based on file extension, if possible. More...
 
static boost::optional< Workspaceload (const openstudio::path &p, const IddFileType &iddFileType)
 Load a Workspace from path using the IddFactory and iddFileType. More...
 
static boost::optional< Workspaceload (const openstudio::path &p, const IddFile &iddFile)
 Load a Workspace from path using iddFile. More...
 

Detailed Description

Workspace holds a collection of interconnected WorkspaceObjects.

Similar to IdfFile, Workspace represents data (typically a whole or partial building energy model) in EnergyPlus Input Data File (IDF) format, and each instance of Workspace is constructed from a specific IddFile (either explicitly or using the IddFactory plus an IddFileType.) Workspace is shared so that changes to a copy of a Workspace changes the original as well.

Workspace contains the following types of WorkspaceObjects:

Although Workspace and IdfFile share many important characteristics, there is no direct inheritance relationship between the two since their implementations are fundamentally different.

Member Typedef Documentation

typedef detail::Workspace_Impl openstudio::Workspace::ImplType
protected

Constructor & Destructor Documentation

openstudio::Workspace::Workspace ( )

Default constructor assumes StrictnessLevel::Draft and IddFileType::EnergyPlus.

Adds a versionObject with the version identifier set according to the version registered for iddFileType in the IddFactory.

openstudio::Workspace::Workspace ( StrictnessLevel  level)

Construct IddFileType::EnergyPlus Workspace at StrictnessLevel level.

Adds a versionObject with the version identifier set according to the version registered for iddFileType in the IddFactory. If level == StrictnessLevel::Final, Workspace can be invalid post-construction.

openstudio::Workspace::Workspace ( StrictnessLevel  level,
IddFileType  iddFileType 
)

Default constructor.

User can specify IddFileType (IddFileType::EnergyPlus or IddFileType::OpenStudio) and StrictnessLevel. Adds a versionObject with the version identifier set according to the version registered for iddFileType in the IddFactory. If level == StrictnessLevel::Final, Workspace can be invalid post-construction.

openstudio::Workspace::Workspace ( const IdfFile idfFile,
StrictnessLevel  level = StrictnessLevel::None 
)

Construct from idfFile.

The new Workspace inherits idfFile's IddFile. Each IdfObject in idfFile is used to construct a WorkspaceObject that is held by the new Workspace, and is equivalent to, but completely separate from, the IdfObject. (All object data is cloned.)

If the Workspace so constructed is not valid at the specified StrictnessLevel, all of the newly created objects are removed, and the constructor returns an empty Workspace with StrictnessLevel None. Problems may be diagnosed by calling idfFile.validityReport(level).

openstudio::Workspace::Workspace ( const Workspace other)

Copy constructor, shares data with other Workspace.

virtual openstudio::Workspace::~Workspace ( )
inlinevirtual
openstudio::Workspace::Workspace ( std::shared_ptr< detail::Workspace_Impl >  impl)
protected

Protected constructor from impl.

Member Function Documentation

std::vector<WorkspaceObject> openstudio::Workspace::addAndInsertObjects ( const std::vector< IdfObject > &  objectsToAdd,
const std::vector< IdfObject > &  objectsToInsert 
)

Adds objectToAdd and inserts objectsToInsert into Workspace, if possible.

If successful, returned vector is of the same size, and is in the same order, as the concatenation of objectsToAdd and objectsToInsert. Otherwise, return value will be .empty(). If IdfObjects have handles they will be preserved.

std::vector<WorkspaceObject> openstudio::Workspace::addAndInsertObjects ( const std::vector< WorkspaceObject > &  objectsToAdd,
const std::vector< WorkspaceObject > &  objectsToInsert 
)

Add objectsToAdd and insert objectToInsert into this Workspace.

All objects from both vectors are assumed to be from the same workspace, possibly this one. All relationships between the objects in both vectors (within and between vectors) are retained. Returns the resulting objects in the order implied by concatenating objectsToAdd and objectsToInsert. A new object is always created for each object in objectsToAdd; equivalent objects (dataFieldsEqual and managedObjectListsNonConflicting) may be returned for objectsToInsert.

std::vector<WorkspaceObject> openstudio::Workspace::addAndInsertObjects ( const std::vector< WorkspaceObject > &  objectsToAdd,
const std::vector< std::vector< WorkspaceObject > > &  objectsToInsert 
)

Add objectsToAdd and insert objectsToInsert into this Workspace.

This method differs from the basic addAndInsertObjects for WorkspaceObjects in that the objectsToInsert are grouped. Equivalent objects are evaluated as a whole for each group (sub-vector) of objectsToInsert. That is, if no equivalent is found for any one object in a given group, the whole group is added to the workspace.

boost::optional<WorkspaceObject> openstudio::Workspace::addObject ( const IdfObject idfObject)

Add a clone of idfObject to Workspace.

May rename the new object to avoid name conflicts with exiting objects. If IdfObject has handle it will be preserved.

std::vector<WorkspaceObject> openstudio::Workspace::addObjects ( const std::vector< IdfObject > &  idfObjects,
bool  checkNames = true 
)

Add clones of idfObjects to Workspace, if possible.

Use this function to add multiple objects at once to avoid losing pointer (name/UUID reference) information. If successful, returned vector is of the same size, and is in the same order, as idfObjects. Otherwise, return value will be .empty(). If IdfObjects have handles they will be preserved.

std::vector<WorkspaceObject> openstudio::Workspace::addObjects ( const std::vector< WorkspaceObject > &  objects,
bool  checkNames = true 
)

Add objects to this Workspace, if possible.

All objects are assumed to be from the same workspace, possibly this one. All data is cloned. Upon successful completion, the returned vector is of the same size, and is in the same order, as objects. Pointers are handled as follows:

  • objects[i] -> objects[j] becomes result[i] -> result[j]
  • objects[i] -> external object becomes NULL or result[i] -> external object depending on whether objects[0].workspace() == *this.
  • external object -> objects[i] is not in any way duplicated in result
virtual void openstudio::Workspace::addVersionObject ( )
protectedvirtual
std::vector<WorkspaceObject> openstudio::Workspace::allObjects ( ) const
protected

Returns all objects, including the versionObject.

Protected in public class.

bool openstudio::Workspace::canBeTarget ( const Handle handle,
const std::set< std::string > &  referenceListNames 
) const

True if an \object-list field referencing the given names can point to this object.

template<typename T >
T openstudio::Workspace::cast ( ) const
inline

Cast to type T.

Throws std::bad_cast() if this is not a T.

Workspace openstudio::Workspace::clone ( bool  keepHandles = false) const

Create a deep copy (clone) of all data in this Workspace and return the result in a new Workspace object.

Virtual implementation preserves original Workspace type. Example usage for derived class:

model::Model model;
Workspace clonedModelAsWorkspace = model.clone();
model::Model clonedModel = clonedModelAsWorkspace.cast<model::Model>();

If keepHandles, then new handles will not be assigned to the cloned objects. This feature should be used with care, as reuse of unique object identifiers could lead to changing data in the wrong Workspace.

Workspace openstudio::Workspace::cloneSubset ( const std::vector< Handle > &  handles,
bool  keepHandles = false,
StrictnessLevel  level = StrictnessLevel::Draft 
) const

Clone just the objects referenced by handles into a new Workspace.

All non-object data is also cloned. If keepHandles, then new handles will not be assigned to the cloned objects. Virtual implementation, and similar usage to clone.

bool openstudio::Workspace::connectProgressBar ( openstudio::ProgressBar progressBar)
bool openstudio::Workspace::disconnectProgressBar ( openstudio::ProgressBar progressBar)
bool openstudio::Workspace::fastNaming ( ) const

Returns true if fast naming is enabled.

Fast naming creates UUID-based names for new objects and does not do any name conflict checking.

boost::optional<IddObject> openstudio::Workspace::getIddObject ( const IddObjectType type) const

Returns the IddObject corresponding to type if it is available from the underlying IddFile.

Otherwise the return value evaluates to false.

boost::optional<WorkspaceObject> openstudio::Workspace::getObject ( Handle  handle) const

Get an object from its handle.

boost::optional<WorkspaceObject> openstudio::Workspace::getObjectByNameAndReference ( std::string  name,
const std::vector< std::string > &  referenceNames 
) const

Returns the first object found that is in at least one of the reference lists in referenceNames and named name (case insensitive, but exact match).

Does not look for conflicts.

boost::optional<WorkspaceObject> openstudio::Workspace::getObjectByTypeAndName ( IddObjectType  objectType,
const std::string &  name 
) const

Returns the first object found of type objectType and named name (case insensitive, exact match).

std::vector<WorkspaceObject> openstudio::Workspace::getObjects ( const std::vector< Handle > &  handles) const

Get objects from their handles.

std::vector<WorkspaceObject> openstudio::Workspace::getObjectsByName ( const std::string &  name,
bool  exactMatch = true 
) const

Returns all objects named name (case insensitive).

If exactMatch == false, will return all objects with name or name plus an integer suffix.

std::vector<WorkspaceObject> openstudio::Workspace::getObjectsByReference ( const std::string &  referenceName) const

Returns all objects in the reference list referenceName.

std::vector<WorkspaceObject> openstudio::Workspace::getObjectsByReference ( const std::vector< std::string > &  referenceNames) const

Returns all objects in at least one of the reference lists in referenceNames.

std::vector<WorkspaceObject> openstudio::Workspace::getObjectsByType ( IddObjectType  objectType) const

Returns all objects of type objectType (e.g.

IddObjectType::Zone, IddObjectType("OS:Construction")).

std::vector<WorkspaceObject> openstudio::Workspace::getObjectsByType ( const IddObject objectType) const

Returns all objects with .iddObject() == objectType.

std::vector<WorkspaceObject> openstudio::Workspace::getObjectsByTypeAndName ( IddObjectType  objectType,
const std::string &  name 
) const

Returns all objects named name or name plus an integer suffix (case insensitive).

std::vector<Handle> openstudio::Workspace::handles ( bool  sorted = false) const

Returns the handles of all the objects in this Workspace, excluding those of any version objects.

If sorted, the handles are returned in the preferred order.

IddFile openstudio::Workspace::iddFile ( ) const

Returns the underlying IddFile (the schema for this Workspace).

IddFileType openstudio::Workspace::iddFileType ( ) const

Returns the underlying IddFile's IddFileType.

boost::optional<WorkspaceObject> openstudio::Workspace::insertObject ( const IdfObject idfObject)

Insert idfObject into this Workspace.

Looks for an equivalent object first, only adding a clone if necessary. Implementation is equivalent to inserting a Workspace with only idfObject added to it. If successful (equivalent object found, or object successfully added), the new object is returned. Otherwise, the return value evaluates to false. If IdfObjects has handle it will be preserved.

std::vector<WorkspaceObject> openstudio::Workspace::insertObjects ( const std::vector< IdfObject > &  idfObjects)

Insert idfObjects into Workspace, if possible.

Looks for equivalent objects first, then adds if necessary. If successful, new and equivalent objects will be returned in same order as idfObjects. Otherwise, return value will be .empty(). Equivalence is determined by creating a working Workspace with idfObjects as its contents, then looking for equivalence between the resulting WorkspaceObjects and this Workspace's objects. If IdfObjects have handles they will be preserved.

std::vector<WorkspaceObject> openstudio::Workspace::insertObjects ( const std::vector< WorkspaceObject > &  objects)

Insert objects into this Workspace, if possible.

All objects are assumed to be from the same workspace, possibly this one. Data is only cloned if no equivalent object is located in this Workspace. Equivalence is defined as dataFieldsEqual and managedObjectListsNonConflicting. (If objects[0].workspace() == *this, this method call is trivial and objects is returned directly.) Upon successful completion, the returned vector is of the same size, and is in the same order, as objects. Pointers are handled as follows:

  • objects[i] -> objects[j] becomes result[i] -> result[j]
  • objects[i] -> external object becomes NULL or result[i] -> external object depending on whether objects[0].workspace() == *this.
  • external object -> objects[i] only becomes external object -> result[i] if objects[0].workspace() == *this
bool openstudio::Workspace::isInIddFile ( IddObjectType  type) const

True if the IddObject of type is in iddFile().

bool openstudio::Workspace::isMember ( const Handle handle) const

True if handle corresponds to an object in this workspace.

bool openstudio::Workspace::isValid ( ) const

Returns true if this Workspace is valid at strictnessLevel().

bool openstudio::Workspace::isValid ( StrictnessLevel  level) const

Returns true if this Workspace is valid, that is, has no errors at or below level.

static boost::optional<Workspace> openstudio::Workspace::load ( const openstudio::path &  p)
static

Load a Workspace from path using the IddFactory, and choosing iddFileType based on file extension, if possible.

(IddFileType::OpenStudio if extension is modelFileExtension() or componentFileExtension(), IddFileType::EnergyPlus otherwise.)

static boost::optional<Workspace> openstudio::Workspace::load ( const openstudio::path &  p,
const IddFileType iddFileType 
)
static

Load a Workspace from path using the IddFactory and iddFileType.

static boost::optional<Workspace> openstudio::Workspace::load ( const openstudio::path &  p,
const IddFile iddFile 
)
static

Load a Workspace from path using iddFile.

std::vector<std::pair<QUrl, openstudio::path> > openstudio::Workspace::locateUrls ( const std::vector< URLSearchPath > &  t_paths,
bool  t_create_relative_paths,
const openstudio::path &  t_infile 
)

Find and update all relative (and remote) URLs to well defined locations based on the search paths supplied.

Parameters
[in]t_pathsPaths to search for relative urls
[in]t_create_relative_pathsIf true, update paths to relative locations on the local filesystem, else, make internal urls absolute
[in]t_infilePath of this workspace object. Used during the calculation/searching of relative search paths
Returns
Vector of source/target pairs. The user will be responsible for ensuring that the results are copied into place
boost::optional<std::string> openstudio::Workspace::name ( const Handle handle) const

Returns the object name associated with handle.

std::string openstudio::Workspace::nextName ( const std::string &  name,
bool  fillIn 
) const

Returns the next name in the pattern 'name << " " << int'.

If fillIn, will use unused integer values smaller than the largest one.

std::string openstudio::Workspace::nextName ( const IddObjectType iddObjectType,
bool  fillIn 
) const

Returns the next name in the pattern 'iddObject().name() << " " << int' for iddObjectType.

If fillIn, will use unused integer values smaller than the largest one.

unsigned openstudio::Workspace::numObjects ( ) const

Return the total number of objects in the workspace, ignoring version objects.

unsigned openstudio::Workspace::numObjectsOfType ( IddObjectType  type) const

Return the number of objects of IddObjectType type in the workspace.

unsigned openstudio::Workspace::numObjectsOfType ( const IddObject objectType) const

Return the number of objects by full IddObject type.

std::vector<WorkspaceObject> openstudio::Workspace::objects ( bool  sorted = false) const

Returns all the objects in this Workspace, excluding any version objects.

If sorted, the objects are returned in the preferred order.

std::vector<WorkspaceObject> openstudio::Workspace::objectsWithURLFields ( ) const

Get all the objects in the current workspace that can have a URL entry, that is, they have a URL IddField in their iddObject().

bool openstudio::Workspace::operator!= ( const Workspace other) const
bool openstudio::Workspace::operator== ( const Workspace other) const
template<typename T >
boost::optional<T> openstudio::Workspace::optionalCast ( ) const
inline

Cast to boost::optional<T>.

Returns boost::none on failure of cast.

WorkspaceObjectOrder openstudio::Workspace::order ( )

Access the WorkspaceOrderObject used by the workspace to provide user-specified ordering of objects.

const WorkspaceObjectOrder openstudio::Workspace::order ( ) const

Access the WorkspaceOrderObject used by the workspace to provide user-specified ordering of objects.

bool openstudio::Workspace::removeObject ( const Handle handle)

Remove object from Workspace with the expectation that it will be destructed.

This function removes only the object specified by handle it is not overridden to "do the right thing" for ModelObject.

bool openstudio::Workspace::removeObjects ( const std::vector< Handle > &  handles)

Remove objects from Workspace with the expectation that they will be destructed.

This function removes only the objects specified by handles it is not overridden to "do the right thing" for ModelObjects.

bool openstudio::Workspace::save ( const openstudio::path &  p,
bool  overwrite = false 
)

Save this Workspace to path p.

Will construct the parent folder if necessary and if its parent folder already exists. Will only overwrite an existing file if overwrite==true. If no extension is provided will use modelFileExtension() for files using IddFileType::OpenStudio, and 'idf' otherwise. Returns true if the save operation is successful; false otherwise.

void openstudio::Workspace::setFastNaming ( bool  fastNaming)

Setting fast naming to true reduces the time taken to create and verify the uniqueness of names by using a UUID as the name.

The name UUID is not the same as the object's handle.

bool openstudio::Workspace::setStrictnessLevel ( StrictnessLevel  level)

Set the StrictnessLevel to level.

If level > strictnessLevel(), this method may leave the strictness unchanged and return false to indicate that the collection does not satisfy those requirements. To diagnose any issues, print the validityReport(level).

std::vector<WorkspaceObject> openstudio::Workspace::sort ( const std::vector< WorkspaceObject > &  objects) const

Sort objects using order().

std::vector<Handle> openstudio::Workspace::sort ( const std::vector< Handle > &  handles) const

Sort handles using order().

StrictnessLevel openstudio::Workspace::strictnessLevel ( ) const

Returns the strictness level under which this Workspace is currently operating.

void openstudio::Workspace::swap ( Workspace other)

Swaps underlying data between this workspace and other.

Throws if other and this are not of the same type (must both be plain Workspaces, model::Models, or model::Components).

bool openstudio::Workspace::swap ( WorkspaceObject currentObject,
IdfObject newObject,
bool  keepTargets = false 
)

Swap currentObject and newObject.

To proceed, the objects must be compatible, that is, all source fields pointing to currentObject must be reset-able to newObject, and (if keepTargets), newObject must be able to point to the same target objects as currentObject. If successful, the return value is true, and the data in currentObject and newObject will have been swapped. Otherwise, the return value evaluates to false.

IdfFile openstudio::Workspace::toIdfFile ( ) const

Returns an IdfFile equivalent to this Workspace.

If the objects have handle fields (as in the OpenStudio IDD), pointers between objects are serialized as handles, otherwise they are serialized as names.

ValidityReport openstudio::Workspace::validityReport ( ) const

Returns a ValidityReport for this IdfFile containing all errors at or below strictnessLevel().

ValidityReport openstudio::Workspace::validityReport ( StrictnessLevel  level) const

Returns a ValidityReport for this Workspace containing all errors at or below level.

VersionString openstudio::Workspace::version ( ) const

Returns the version of this model, as determined by the IddFile header.

boost::optional<WorkspaceObject> openstudio::Workspace::versionObject ( ) const

Return the version object in this Workspace, if it exists and is unique.

Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  os,
const Workspace workspace 
)
related
typedef boost::optional<Workspace> OptionalWorkspace
related
typedef std::vector<Workspace> WorkspaceVector
related