OpenStudio:model
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Member Functions | Related Functions | List of all members
openstudio::model::Relationship Class Reference

#include <Relationship.hpp>

Public Member Functions

bool clearRelatedModelObjects ()
 Clears all related ModelObjects, throws if Relationship is singular. More...
 
bool isSettable () const
 Returns true if there is a write method for this relationship. More...
 
bool isSingular () const
 Returns true if this Relationship concerns 0-1 other ModelObjects, otherwise this Relationship can access an unlimited number of other ModelObjects. More...
 
ModelObject modelObject () const
 Returns the primary ModelObject. More...
 
std::string name () const
 Returns the name of the relationship. More...
 
boost::optional< ModelObjectrelatedModelObject () const
 Return the related ModelObject if available, will throw if Relationship is not singular. More...
 
std::vector< ModelObjectrelatedModelObjects () const
 Return all related ModelObjects, will throw if Relationship is singular. More...
 
bool resetRelatedModelObject ()
 Resets the related ModelObject, throws if Relationship is not singular. More...
 
bool setRelatedModelObject (boost::optional< ModelObject > relatedModelObject)
 Resets the related ModelObject and forms relationship with the new ModelObject, throws if Relationship is not singular. More...
 
bool setRelatedModelObject (const Component &component)
 Inserts component into Model and sets related model object on the primary object. More...
 
bool setRelatedModelObjects (std::vector< ModelObject > relatedModelObjects)
 Clears all related ModelObjects and then forms relationships with the new ModelObjects, throws if Relationship is singular. More...
 

Protected Member Functions

 Relationship (const ModelObject &object, const std::string &name)
 Creates a Relationship object to access the named relationships of the given ModelObject. More...
 

Related Functions

(Note that these are not member functions.)

typedef boost::optional
< Relationship
OptionalRelationship
 
typedef std::vector< RelationshipRelationshipVector
 

Detailed Description

Relationship describes relationships that a ModelObject may have with other ModelObjects .

Relationships of a ModelObject are similar to Attributes of a ModelObject, they provide named access to object methods through the QObject Q_PROPERTY system. However, while Attributes of a ModelObject return simple data types (e.g. PlanarSurface has an Attribute named 'netArea' that returns a double), Relationships return related ModelObjects. A Relationship is constructed with a primary ModelObject and describes relationships that the primary ModelObject may have with other ModelObjects. A Relationship can be singular (e.g. a Surface object relates to 0 or 1 Construction objects) or plural (e.g. a Zone relates to any number of Lights objects). A Relationship object can be used to get these related ModelObjects by name.

Constructor & Destructor Documentation

openstudio::model::Relationship::Relationship ( const ModelObject object,
const std::string &  name 
)
protected

Creates a Relationship object to access the named relationships of the given ModelObject.

Member Function Documentation

bool openstudio::model::Relationship::clearRelatedModelObjects ( )

Clears all related ModelObjects, throws if Relationship is singular.

Equivalent to setRelatedModelObject(std::vector<ModelObject>())

bool openstudio::model::Relationship::isSettable ( ) const

Returns true if there is a write method for this relationship.

bool openstudio::model::Relationship::isSingular ( ) const

Returns true if this Relationship concerns 0-1 other ModelObjects, otherwise this Relationship can access an unlimited number of other ModelObjects.

ModelObject openstudio::model::Relationship::modelObject ( ) const

Returns the primary ModelObject.

std::string openstudio::model::Relationship::name ( ) const

Returns the name of the relationship.

boost::optional<ModelObject> openstudio::model::Relationship::relatedModelObject ( ) const

Return the related ModelObject if available, will throw if Relationship is not singular.

std::vector<ModelObject> openstudio::model::Relationship::relatedModelObjects ( ) const

Return all related ModelObjects, will throw if Relationship is singular.

bool openstudio::model::Relationship::resetRelatedModelObject ( )

Resets the related ModelObject, throws if Relationship is not singular.

Equivalent to setRelatedModelObject(boost::none)

bool openstudio::model::Relationship::setRelatedModelObject ( boost::optional< ModelObject relatedModelObject)

Resets the related ModelObject and forms relationship with the new ModelObject, throws if Relationship is not singular.

bool openstudio::model::Relationship::setRelatedModelObject ( const Component component)

Inserts component into Model and sets related model object on the primary object.

bool openstudio::model::Relationship::setRelatedModelObjects ( std::vector< ModelObject relatedModelObjects)

Clears all related ModelObjects and then forms relationships with the new ModelObjects, throws if Relationship is singular.

Friends And Related Function Documentation

typedef boost::optional<Relationship> OptionalRelationship
related
typedef std::vector<Relationship> RelationshipVector
related