OpenStudioCore:project
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
openstudio::project::AttributeRecord Class Reference

#include <AttributeRecord.hpp>

+ Inheritance diagram for openstudio::project::AttributeRecord:

Public Types

typedef AttributeRecordColumns ColumnsType
 
typedef
detail::AttributeRecord_Impl 
ImplType
 
typedef AttributeRecord ObjectRecordType
 
- Public Types inherited from openstudio::project::ObjectRecord
typedef detail::ObjectRecord_Impl ImplType
 

Public Member Functions

Constructors and Destructors
 AttributeRecord (const Attribute &attribute, const FileReferenceRecord &fileReferenceRecord)
 
 AttributeRecord (const Attribute &attribute, const AttributeRecord &parentAttributeRecord, int attributeVectorIndex)
 
 AttributeRecord (const Attribute &attribute, const AlgorithmRecord &algorithmRecord)
 
 AttributeRecord (const Attribute &attribute, const VariableRecord &variableRecord)
 
 AttributeRecord (const Attribute &attribute, const DataPointRecord &dataPointRecord)
 
 AttributeRecord (const QSqlQuery &query, ProjectDatabase &database)
 constructor from query, throws if bad query More...
 
virtual ~AttributeRecord ()
 
boost::optional
< FileReferenceRecord
fileReferenceRecord () const
 Getters. More...
 
boost::optional< AttributeRecordparentAttributeRecord () const
 Returns the AttributeRecord that parents this AttributeRecord. More...
 
boost::optional< AlgorithmRecordalgorithmRecord () const
 Returns the AlgorithmRecord that parents this AttributeRecord. More...
 
boost::optional< VariableRecordvariableRecord () const
 Returns the VariableRecord that parents this AttributeRecord. More...
 
boost::optional< DataPointRecorddataPointRecord () const
 Returns the DataPointRecord that parents this AttributeRecord. More...
 
boost::optional< int > parentAttributeRecordId () const
 
AttributeValueType attributeValueType () const
 get the attribute value type More...
 
bool attributeValueAsBoolean () const
 get value as a bool More...
 
int attributeValueAsInteger () const
 get value as int More...
 
unsigned attributeValueAsUnsigned () const
 get value as unsigned More...
 
double attributeValueAsDouble () const
 get value as double More...
 
Quantity attributeValueAsQuantity () const
 get value as Quantity More...
 
Unit attributeValueAsUnit () const
 get value as Unit More...
 
std::string attributeValueAsString () const
 get value as string More...
 
std::vector< Attribute > attributeValueAsAttributeVector () const
 get value as attribute vector More...
 
boost::optional< std::string > attributeUnits () const
 get the attribute units More...
 
Attribute attribute () const
 get equivalent attribute More...
 
Setters
bool setParentAttributeRecordId (int parentAttributeRecordId)
 
- Public Member Functions inherited from openstudio::project::ObjectRecord
std::string description () const
 get the description More...
 
std::string displayName () const
 get the display name More...
 
std::string name () const
 get the name More...
 
bool setDescription (const std::string &description)
 set the description More...
 
bool setDisplayName (const std::string &displayName)
 set the display name More...
 
bool setName (const std::string &name)
 set the name More...
 
DateTime timestampCreate () const
 get the timestamp the object was created at More...
 
DateTime timestampLast () const
 get the timestamp the object was last edited at More...
 
void updatePathData (const openstudio::path &originalBase, const openstudio::path &newBase)
 Update any path data stored under originalBase to newBase. More...
 
UUID uuidLast () const
 get the UUID of the object at last edit More...
 
virtual ~ObjectRecord ()
 
- Public Member Functions inherited from openstudio::project::Record
std::vector< ObjectRecordchildren () const
 Returns all child Records in the database. More...
 
bool connect (const std::string &signal, const QObject *qObject, const std::string &slot, Qt::ConnectionType type=Qt::AutoConnection) const
 Connect signal from this Records implementation object to slot on qObject. More...
 
std::string databaseTableName () const
 Returns the name of the database table. More...
 
std::vector< JoinRecordjoinRecords () const
 Returns all join Records in the database. More...
 
void moveToThread (QThread *targetThread)
 Move the implementation object to target thread. More...
 
ProjectDatabase projectDatabase () const
 Returns the ProjectDatabase, will throw if ProjectDatabase has been destructed. More...
 
std::vector< ObjectRecordresources () const
 Returns all resource Records in the database. More...
 
unsigned useCount () const
 Returns number of shared references to this Records implementation object. More...
 
int id () const
 Returns the id. More...
 
UUID handle () const
 Returns the handle. More...
 
template<typename T >
cast () const
 Cast to Record of type T, can throw std::bad_cast. More...
 
template<typename T >
boost::optional< T > optionalCast () const
 Cast to optional Record of type T. More...
 
virtual ~Record ()
 

Static Public Member Functions

static void createIndices (QSqlDatabase &qSqlDatabase, const std::string &databaseTableName)
 
static std::string databaseTableName ()
 
static boost::optional
< AttributeRecord
factoryFromQuery (const QSqlQuery &query, ProjectDatabase &database)
 
static boost::optional
< AttributeRecord
getAttributeRecord (int id, ProjectDatabase &database)
 
static std::vector
< AttributeRecord
getAttributeRecords (ProjectDatabase &database)
 
static UpdateByIdQueryData updateByIdQueryData ()
 
static void updatePathData (ProjectDatabase database, const openstudio::path &originalBase, const openstudio::path &newBase)
 
- Static Public Member Functions inherited from openstudio::project::ObjectRecord
static void createIndices (QSqlDatabase &qSqlDatabase, const std::string &databaseTableName)
 

Protected Member Functions

void constructRelatedRecords (const Attribute &attribute)
 
- Protected Member Functions inherited from openstudio::project::ObjectRecord
 ObjectRecord (std::shared_ptr< detail::ObjectRecord_Impl > impl, ProjectDatabase projectDatabase)
 constructor More...
 
 ObjectRecord (std::shared_ptr< detail::ObjectRecord_Impl > impl)
 constructor, does not register in database, use with caution More...
 
- Protected Member Functions inherited from openstudio::project::Record
void bindValues (QSqlQuery &query) const
 Bind values to a query for saving. More...
 
bool compareValues (const QSqlQuery &query) const
 Checks that values (except id) are same as query. More...
 
bool databaseCompare (const ProjectDatabase &projectDatabase) const
 Compares just this Record to the one in the database and check if they are exactly equal except for id, does not check children. More...
 
boost::optional< int > findIdByHandle () const
 Try to find this Record's id in the database by using its handle. More...
 
bool haveLastValues () const
 Checks if last values are set for this Record to revert back to. More...
 
void insertRow (ProjectDatabase &projectDatabase)
 Inserts a row in the database for this Record and sets id. More...
 
void insertRow (const std::shared_ptr< QSqlDatabase > &db)
 Inserts a row in the database for this Record and sets id. More...
 
void makeDeleteByHandleQuery (QSqlQuery &query) const
 Makes a query to delete Record with this handle from this Record's database table. More...
 
void makeDeleteByIdQuery (QSqlQuery &query) const
 Makes a query to delete Record with this id from this Record's database table. More...
 
void makeSelectAllQuery (QSqlQuery &query) const
 Makes a query to select all Records in this Record's database table. More...
 
void makeSelectByHandleQuery (QSqlQuery &query) const
 Makes a query to select Record with this handle in this Record's database table. More...
 
void makeSelectByIdQuery (QSqlQuery &query) const
 Makes a query to select Record with this id in this Record's database table. More...
 
void onChange ()
 Method called whenever the Record changes, emits onChange signal. More...
 
void removeRow (ProjectDatabase &projectDatabase)
 Removes just this Record from the database, does not remove children. More...
 
void removeRow (const std::shared_ptr< QSqlDatabase > &db)
 Removes just this Record from the database, does not remove children. More...
 
bool revertRow (ProjectDatabase &projectDatabase)
 Reverts just this Record then saves it in the database, does not revert children. More...
 
void revertToLastValues ()
 Revert values back to last state. More...
 
void saveLastValues ()
 Saves current values as last state. More...
 
void saveRow (ProjectDatabase &projectDatabase)
 Saves just this Record in the database, does not save children. More...
 
void saveRow (const std::shared_ptr< QSqlDatabase > &db)
 Saves just this Record in the database, does not save children. More...
 
void setLastValues (const QSqlQuery &query, ProjectDatabase &projectDatabase)
 Set the last state of this object from the query (including id). More...
 
void setLastValues (ProjectDatabase &projectDatabase)
 Sets the last state of just this Record from the database (including id), does not affect children. More...
 
 Record (std::shared_ptr< detail::Record_Impl > impl, ProjectDatabase projectDatabase)
 Constructs a new Record. More...
 
 Record (std::shared_ptr< detail::Record_Impl > impl)
 Constructs a new Record but does not create or save to a row in the database, use with caution. More...
 

Related Functions

(Note that these are not member functions.)

typedef std::vector
< AttributeRecord
AttributeRecordVector
 
typedef boost::optional
< AttributeRecord
OptionalAttributeRecord
 

Detailed Description

AttributeRecord is an ObjectRecord that serializes an Attribute.

An Attribute is a name-value pair where the value can be a bool, double, int, string, or vector of other attributes. The ability for an attribute value to be a vector of other attributes allows for hierarchical attribute structures.

Member Typedef Documentation

typedef detail::AttributeRecord_Impl openstudio::project::AttributeRecord::ImplType

Constructor & Destructor Documentation

openstudio::project::AttributeRecord::AttributeRecord ( const Attribute &  attribute,
const FileReferenceRecord fileReferenceRecord 
)
openstudio::project::AttributeRecord::AttributeRecord ( const Attribute &  attribute,
const AttributeRecord parentAttributeRecord,
int  attributeVectorIndex 
)
openstudio::project::AttributeRecord::AttributeRecord ( const Attribute &  attribute,
const AlgorithmRecord algorithmRecord 
)
openstudio::project::AttributeRecord::AttributeRecord ( const Attribute &  attribute,
const VariableRecord variableRecord 
)
openstudio::project::AttributeRecord::AttributeRecord ( const Attribute &  attribute,
const DataPointRecord dataPointRecord 
)
openstudio::project::AttributeRecord::AttributeRecord ( const QSqlQuery &  query,
ProjectDatabase database 
)

constructor from query, throws if bad query

virtual openstudio::project::AttributeRecord::~AttributeRecord ( )
inlinevirtual

Member Function Documentation

boost::optional<AlgorithmRecord> openstudio::project::AttributeRecord::algorithmRecord ( ) const

Returns the AlgorithmRecord that parents this AttributeRecord.

Attribute openstudio::project::AttributeRecord::attribute ( ) const

get equivalent attribute

boost::optional<std::string> openstudio::project::AttributeRecord::attributeUnits ( ) const

get the attribute units

std::vector<Attribute> openstudio::project::AttributeRecord::attributeValueAsAttributeVector ( ) const

get value as attribute vector

bool openstudio::project::AttributeRecord::attributeValueAsBoolean ( ) const

get value as a bool

double openstudio::project::AttributeRecord::attributeValueAsDouble ( ) const

get value as double

int openstudio::project::AttributeRecord::attributeValueAsInteger ( ) const

get value as int

Quantity openstudio::project::AttributeRecord::attributeValueAsQuantity ( ) const

get value as Quantity

std::string openstudio::project::AttributeRecord::attributeValueAsString ( ) const

get value as string

Unit openstudio::project::AttributeRecord::attributeValueAsUnit ( ) const

get value as Unit

unsigned openstudio::project::AttributeRecord::attributeValueAsUnsigned ( ) const

get value as unsigned

AttributeValueType openstudio::project::AttributeRecord::attributeValueType ( ) const

get the attribute value type

void openstudio::project::AttributeRecord::constructRelatedRecords ( const Attribute &  attribute)
protected
static void openstudio::project::AttributeRecord::createIndices ( QSqlDatabase &  qSqlDatabase,
const std::string &  databaseTableName 
)
static
static std::string openstudio::project::AttributeRecord::databaseTableName ( )
static
boost::optional<DataPointRecord> openstudio::project::AttributeRecord::dataPointRecord ( ) const

Returns the DataPointRecord that parents this AttributeRecord.

static boost::optional<AttributeRecord> openstudio::project::AttributeRecord::factoryFromQuery ( const QSqlQuery &  query,
ProjectDatabase database 
)
static
boost::optional<FileReferenceRecord> openstudio::project::AttributeRecord::fileReferenceRecord ( ) const

Getters.

Returns the FileReferenceRecord that parents this AttributeRecord.

static boost::optional<AttributeRecord> openstudio::project::AttributeRecord::getAttributeRecord ( int  id,
ProjectDatabase database 
)
static
static std::vector<AttributeRecord> openstudio::project::AttributeRecord::getAttributeRecords ( ProjectDatabase database)
static
boost::optional<AttributeRecord> openstudio::project::AttributeRecord::parentAttributeRecord ( ) const

Returns the AttributeRecord that parents this AttributeRecord.

boost::optional<int> openstudio::project::AttributeRecord::parentAttributeRecordId ( ) const
bool openstudio::project::AttributeRecord::setParentAttributeRecordId ( int  parentAttributeRecordId)
static UpdateByIdQueryData openstudio::project::AttributeRecord::updateByIdQueryData ( )
static
static void openstudio::project::AttributeRecord::updatePathData ( ProjectDatabase  database,
const openstudio::path &  originalBase,
const openstudio::path &  newBase 
)
static
boost::optional<VariableRecord> openstudio::project::AttributeRecord::variableRecord ( ) const

Returns the VariableRecord that parents this AttributeRecord.

Friends And Related Function Documentation

typedef std::vector<AttributeRecord> AttributeRecordVector
related
typedef boost::optional<AttributeRecord> OptionalAttributeRecord
related