OpenStudio:utilities
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
List of all members
openstudio::BCLMeasure Class Reference

#include <BCLMeasure.hpp>

Public Member Functions

Destructor
virtual ~BCLMeasure ()=default
 Virtual destructor. More...
 
Getters
openstudio::path directory () const
 
boost::optional< std::string > error () const
 
std::string uid () const
 
UUID uuid () const
 
std::string versionId () const
 
UUID versionUUID () const
 
boost::optional< DateTimeversionModified () const
 
std::string xmlChecksum () const
 
std::string xmlString () const
 
std::string name () const
 
std::string displayName () const
 
std::string className () const
 
std::string description () const
 
std::string modelerDescription () const
 
std::vector< BCLMeasureArgumentarguments () const
 
std::vector< BCLMeasureOutputoutputs () const
 
std::vector< std::string > tags () const
 
std::vector< Attributeattributes () const
 
std::vector< BCLFileReferencefiles () const
 
Setters
void setError (const std::string &error)
 
void resetError ()
 
void setName (const std::string &name)
 
void setDisplayName (const std::string &displayName)
 
void setClassName (const std::string &className)
 
void setDescription (const std::string &description)
 
void setModelerDescription (const std::string &modelerDescription)
 
void setArguments (const std::vector< BCLMeasureArgument > &arguments)
 
void setOutputs (const std::vector< BCLMeasureOutput > &outputs)
 

Constructors

 BCLMeasure (const std::string &name, const std::string &className, const openstudio::path &dir, const std::string &taxonomyTag, MeasureType measureType, const std::string &description, const std::string &modelerDescription, MeasureLanguage measureLanguage=MeasureLanguage::Ruby)
 Constructor for a new measure with required data Will throw exception unless dir is a directory that does not exist or an empty directory. More...
 
 BCLMeasure (const openstudio::path &dir)
 Constructor for downloaded measures, path is to directory containing "measure.xml" file Will throw exception if directory does not exist or does not represent a valid measure. More...
 
static std::string makeClassName (const std::string &name)
 Convert a measure name to a valid Ruby class name. More...
 
static boost::optional
< BCLMeasure
load (const openstudio::path &dir)
 Try to load a BCLMeasure from a directory containing a "measure.xml" file. More...
 
static std::vector< std::string > suggestedIntendedSoftwareTools ()
 Suggested values for "Intended Software Tool" attribute. More...
 
static std::vector< std::string > suggestedIntendedUseCases ()
 Suggested values for "Intended Use Case" attribute. More...
 
static std::vector< std::string > suggestedFirstLevelTaxonomyTerms ()
 Suggested values for the first level taxonomy tag. More...
 
static std::vector< std::string > suggestedSecondLevelTaxonomyTerms (const std::string &firstLevelTaxonomyTerm)
 Suggested values for the second level taxonomy tag. More...
 
static bool isIgnoredFileName (const std::string &fileName)
 
static bool isApprovedFile (const openstudio::path &absoluteFilePath, const openstudio::path &measureDir)
 

Operators

std::string taxonomyTag () const
 Returns the single taxonomy tag allowed. More...
 
void setTaxonomyTag (const std::string &taxonomyTag)
 Sets the single taxonomy tag allowed. More...
 
MeasureType measureType () const
 Returns value of the "Measure Type" attribute. More...
 
MeasureLanguage measureLanguage () const
 
void setMeasureType (const MeasureType &measureType)
 Sets value of the "Measure Type" attribute. More...
 
void setMeasureLanguage (const MeasureLanguage &measureLanguage)
 
std::vector< std::string > intendedSoftwareTools () const
 Returns values of any "Intended Software Tool" attributes. More...
 
std::vector< std::string > intendedUseCases () const
 Returns values of any "Intended Use Case" attributes. More...
 
boost::optional< openstudio::path > primaryRubyScriptPath () const
 Returns the path of the primary Ruby script if the file exists and is a regular file. More...
 
boost::optional< openstudio::path > primaryPythonScriptPath () const
 
boost::optional< openstudio::path > primaryScriptPath () const
 Returns the path of the primary script path, based on MeasureLanguage. More...
 
FileReferenceType inputFileType () const
 Returns the input file type for this measure. More...
 
FileReferenceType outputFileType () const
 Returns the output file type for this measure. More...
 
void clearFiles ()
 Clears all files. More...
 
void addAttribute (const Attribute &attribute)
 Adds attribute to attribute list. More...
 
std::vector< AttributegetAttributes (const std::string &name) const
 get attributes by name More...
 
bool removeAttributes (const std::string &name)
 Removes attribute by name, returns true if attribute was found and removed. More...
 
void clearAttributes ()
 Removes all attributes. More...
 
bool missingRequiredFields () const
 Check for all required fields, return true if any are missing Does not update the XML. More...
 
bool checkForUpdatesFiles ()
 Check for updates to files, will increment versionID and return true if any files have changed, been added, or removed from the measure The measure must still be saved to disk to preserve the new versionID Typical usage is 1) checkForUpdatesFiles, 2) update content using embedded ruby interpreter, 3) checkForUpdatesXML. More...
 
bool checkForUpdatesXML ()
 Check for updates to the xml, will increment versionID and xmlChecksum then return true if any xml fields (other than uid, version id, or xml checksum) have changed The xml file must still be saved to disk to preserve the new versionID. More...
 
bool operator== (const BCLMeasure &other) const
 Equality test - Compares the uids and versionIds of two separate measures. More...
 
bool operator!= (const BCLMeasure &other) const
 
bool operator< (const BCLMeasure &other) const
 Less than. More...
 
bool save () const
 Save the measure.xml back to the directory. More...
 
boost::optional< BCLMeasureclone (const openstudio::path &newDir) const
 Clone the measure from the original location to the new location newDir is a directory which either does not exist or is empty If the copy is successful a new BCLMeasure is returned. More...
 
void changeUID ()
 Change the UID for this measure. More...
 
void incrementVersionId ()
 Change the Version ID for this measure. More...
 
bool updateMeasureScript (const MeasureType &oldMeasureType, const MeasureType &newMeasureType, const MeasureLanguage &oldMeasureLanguage, const MeasureLanguage &newMeasureLanguage, const std::string &oldClassName, const std::string &newClassName, const std::string &name, const std::string &description, const std::string &modelerDescription)
 Update's the ruby measure script to have this new information. More...
 
bool updateMeasureTests (const std::string &oldClassName, const std::string &newClassName)
 Update's the ruby measure tests to have this new information. More...
 
Json::Value toJSON () const
 
std::string toJSONString () const
 
static std::vector< BCLMeasuregetMeasuresInDir (const openstudio::path &dir)
 get all measures in an input directory More...
 

Detailed Description

BCLMeasure is a class for managing the contents of a BCL Measure directory including the xml description file.

Constructor & Destructor Documentation

openstudio::BCLMeasure::BCLMeasure ( const std::string &  name,
const std::string &  className,
const openstudio::path &  dir,
const std::string &  taxonomyTag,
MeasureType  measureType,
const std::string &  description,
const std::string &  modelerDescription,
MeasureLanguage  measureLanguage = MeasureLanguage::Ruby 
)

Constructor for a new measure with required data Will throw exception unless dir is a directory that does not exist or an empty directory.

A template measure will be created, including a blank user script.

openstudio::BCLMeasure::BCLMeasure ( const openstudio::path &  dir)

Constructor for downloaded measures, path is to directory containing "measure.xml" file Will throw exception if directory does not exist or does not represent a valid measure.

virtual openstudio::BCLMeasure::~BCLMeasure ( )
virtualdefault

Virtual destructor.

Member Function Documentation

void openstudio::BCLMeasure::addAttribute ( const Attribute attribute)

Adds attribute to attribute list.

std::vector<BCLMeasureArgument> openstudio::BCLMeasure::arguments ( ) const
std::vector<Attribute> openstudio::BCLMeasure::attributes ( ) const
void openstudio::BCLMeasure::changeUID ( )

Change the UID for this measure.

bool openstudio::BCLMeasure::checkForUpdatesFiles ( )

Check for updates to files, will increment versionID and return true if any files have changed, been added, or removed from the measure The measure must still be saved to disk to preserve the new versionID Typical usage is 1) checkForUpdatesFiles, 2) update content using embedded ruby interpreter, 3) checkForUpdatesXML.

bool openstudio::BCLMeasure::checkForUpdatesXML ( )

Check for updates to the xml, will increment versionID and xmlChecksum then return true if any xml fields (other than uid, version id, or xml checksum) have changed The xml file must still be saved to disk to preserve the new versionID.

std::string openstudio::BCLMeasure::className ( ) const
void openstudio::BCLMeasure::clearAttributes ( )

Removes all attributes.

void openstudio::BCLMeasure::clearFiles ( )

Clears all files.

boost::optional<BCLMeasure> openstudio::BCLMeasure::clone ( const openstudio::path &  newDir) const

Clone the measure from the original location to the new location newDir is a directory which either does not exist or is empty If the copy is successful a new BCLMeasure is returned.

std::string openstudio::BCLMeasure::description ( ) const
openstudio::path openstudio::BCLMeasure::directory ( ) const
std::string openstudio::BCLMeasure::displayName ( ) const
boost::optional<std::string> openstudio::BCLMeasure::error ( ) const
std::vector<BCLFileReference> openstudio::BCLMeasure::files ( ) const
std::vector<Attribute> openstudio::BCLMeasure::getAttributes ( const std::string &  name) const

get attributes by name

static std::vector<BCLMeasure> openstudio::BCLMeasure::getMeasuresInDir ( const openstudio::path &  dir)
static

get all measures in an input directory

void openstudio::BCLMeasure::incrementVersionId ( )

Change the Version ID for this measure.

FileReferenceType openstudio::BCLMeasure::inputFileType ( ) const

Returns the input file type for this measure.

std::vector<std::string> openstudio::BCLMeasure::intendedSoftwareTools ( ) const

Returns values of any "Intended Software Tool" attributes.

std::vector<std::string> openstudio::BCLMeasure::intendedUseCases ( ) const

Returns values of any "Intended Use Case" attributes.

static bool openstudio::BCLMeasure::isApprovedFile ( const openstudio::path &  absoluteFilePath,
const openstudio::path &  measureDir 
)
static
static bool openstudio::BCLMeasure::isIgnoredFileName ( const std::string &  fileName)
static
static boost::optional<BCLMeasure> openstudio::BCLMeasure::load ( const openstudio::path &  dir)
static

Try to load a BCLMeasure from a directory containing a "measure.xml" file.

static std::string openstudio::BCLMeasure::makeClassName ( const std::string &  name)
static

Convert a measure name to a valid Ruby class name.

MeasureLanguage openstudio::BCLMeasure::measureLanguage ( ) const
MeasureType openstudio::BCLMeasure::measureType ( ) const

Returns value of the "Measure Type" attribute.

bool openstudio::BCLMeasure::missingRequiredFields ( ) const

Check for all required fields, return true if any are missing Does not update the XML.

std::string openstudio::BCLMeasure::modelerDescription ( ) const
std::string openstudio::BCLMeasure::name ( ) const
bool openstudio::BCLMeasure::operator!= ( const BCLMeasure other) const
bool openstudio::BCLMeasure::operator< ( const BCLMeasure other) const

Less than.

bool openstudio::BCLMeasure::operator== ( const BCLMeasure other) const

Equality test - Compares the uids and versionIds of two separate measures.

FileReferenceType openstudio::BCLMeasure::outputFileType ( ) const

Returns the output file type for this measure.

std::vector<BCLMeasureOutput> openstudio::BCLMeasure::outputs ( ) const
boost::optional<openstudio::path> openstudio::BCLMeasure::primaryPythonScriptPath ( ) const
boost::optional<openstudio::path> openstudio::BCLMeasure::primaryRubyScriptPath ( ) const

Returns the path of the primary Ruby script if the file exists and is a regular file.

Otherwise returns boost::none.

boost::optional<openstudio::path> openstudio::BCLMeasure::primaryScriptPath ( ) const

Returns the path of the primary script path, based on MeasureLanguage.

bool openstudio::BCLMeasure::removeAttributes ( const std::string &  name)

Removes attribute by name, returns true if attribute was found and removed.

void openstudio::BCLMeasure::resetError ( )
bool openstudio::BCLMeasure::save ( ) const

Save the measure.xml back to the directory.

void openstudio::BCLMeasure::setArguments ( const std::vector< BCLMeasureArgument > &  arguments)
void openstudio::BCLMeasure::setClassName ( const std::string &  className)
void openstudio::BCLMeasure::setDescription ( const std::string &  description)
void openstudio::BCLMeasure::setDisplayName ( const std::string &  displayName)
void openstudio::BCLMeasure::setError ( const std::string &  error)
void openstudio::BCLMeasure::setMeasureLanguage ( const MeasureLanguage measureLanguage)
void openstudio::BCLMeasure::setMeasureType ( const MeasureType measureType)

Sets value of the "Measure Type" attribute.

void openstudio::BCLMeasure::setModelerDescription ( const std::string &  modelerDescription)
void openstudio::BCLMeasure::setName ( const std::string &  name)
void openstudio::BCLMeasure::setOutputs ( const std::vector< BCLMeasureOutput > &  outputs)
void openstudio::BCLMeasure::setTaxonomyTag ( const std::string &  taxonomyTag)

Sets the single taxonomy tag allowed.

static std::vector<std::string> openstudio::BCLMeasure::suggestedFirstLevelTaxonomyTerms ( )
static

Suggested values for the first level taxonomy tag.

static std::vector<std::string> openstudio::BCLMeasure::suggestedIntendedSoftwareTools ( )
static

Suggested values for "Intended Software Tool" attribute.

static std::vector<std::string> openstudio::BCLMeasure::suggestedIntendedUseCases ( )
static

Suggested values for "Intended Use Case" attribute.

static std::vector<std::string> openstudio::BCLMeasure::suggestedSecondLevelTaxonomyTerms ( const std::string &  firstLevelTaxonomyTerm)
static

Suggested values for the second level taxonomy tag.

std::vector<std::string> openstudio::BCLMeasure::tags ( ) const
std::string openstudio::BCLMeasure::taxonomyTag ( ) const

Returns the single taxonomy tag allowed.

Json::Value openstudio::BCLMeasure::toJSON ( ) const
std::string openstudio::BCLMeasure::toJSONString ( ) const
std::string openstudio::BCLMeasure::uid ( ) const
bool openstudio::BCLMeasure::updateMeasureScript ( const MeasureType oldMeasureType,
const MeasureType newMeasureType,
const MeasureLanguage oldMeasureLanguage,
const MeasureLanguage newMeasureLanguage,
const std::string &  oldClassName,
const std::string &  newClassName,
const std::string &  name,
const std::string &  description,
const std::string &  modelerDescription 
)

Update's the ruby measure script to have this new information.

bool openstudio::BCLMeasure::updateMeasureTests ( const std::string &  oldClassName,
const std::string &  newClassName 
)

Update's the ruby measure tests to have this new information.

UUID openstudio::BCLMeasure::uuid ( ) const
std::string openstudio::BCLMeasure::versionId ( ) const
boost::optional<DateTime> openstudio::BCLMeasure::versionModified ( ) const
UUID openstudio::BCLMeasure::versionUUID ( ) const
std::string openstudio::BCLMeasure::xmlChecksum ( ) const
std::string openstudio::BCLMeasure::xmlString ( ) const