本文整理汇总了C++中ProjectDatabase类的典型用法代码示例。如果您正苦于以下问题:C++ ProjectDatabase类的具体用法?C++ ProjectDatabase怎么用?C++ ProjectDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProjectDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyOfThis
void InputVariableRecord::constructRelatedRecords(const analysis::InputVariable& inputVariable) {
AttributeVector attributes, dbAttributes;
InputVariableRecord copyOfThis(getImpl<detail::InputVariableRecord_Impl>());
if (analysis::OptionalUncertaintyDescription dbUDesc = uncertaintyDescription()) {
dbAttributes = dbUDesc->cast<analysis::GenericUncertaintyDescription>().attributes();
}
if (analysis::OptionalUncertaintyDescription udesc = inputVariable.uncertaintyDescription()) {
attributes = udesc->cast<analysis::GenericUncertaintyDescription>().attributes();
}
for (const Attribute& attribute : attributes) {
// find in dbOptions
auto dbIt = std::find_if(dbAttributes.begin(),dbAttributes.end(),
std::bind(uuidsEqual<Attribute,Attribute>,std::placeholders::_1,attribute));
// if not there, or if different versionUUID, save it
if ((dbIt == dbAttributes.end()) || (attribute.versionUUID() != dbIt->versionUUID())) {
AttributeRecord udescAttributeRecord(attribute,copyOfThis);
}
// if there, erase from dbOptions
if (dbIt != dbAttributes.end()) {
dbAttributes.erase(dbIt);
}
}
// any attributes left in dbAttributes should be removed from the database
ProjectDatabase database = projectDatabase();
for (const Attribute& toRemove : dbAttributes) {
AttributeRecord dbUDescAttributeRecord = database.getObjectRecordByHandle<AttributeRecord>(toRemove.uuid()).get();
database.removeRecord(dbUDescAttributeRecord);
}
}
示例2: projectDatabase
std::vector<WorkflowRecord> ProblemRecord_Impl::workflowRecords() const {
WorkflowRecordVector result;
ProjectDatabase database = projectDatabase();
QSqlQuery query(*(database.qSqlDatabase()));
query.prepare(toQString("SELECT * FROM " + WorkflowRecord::databaseTableName() +
" WHERE problemRecordId=:problemRecordId ORDER BY workflowIndex"));
query.bindValue(":problemRecordId",id());
assertExec(query);
OptionalInt previousIndex;
bool resort(false);
while (query.next()) {
result.push_back(WorkflowRecord::factoryFromQuery(query, database).get());
int index = result.back().workflowIndex();
if (previousIndex) {
if (index < previousIndex.get()) {
resort = true;
}
}
previousIndex = index;
}
if (resort) {
WorkflowRecordWorkflowIndexLess comparator;
std::sort(result.begin(),result.end(),comparator);
}
return result;
}
示例3: numMeasures
unsigned MeasureGroupRecord_Impl::numMeasures(bool selectedMeasuresOnly) const
{
unsigned result = 0;
ProjectDatabase database = this->projectDatabase();
QSqlQuery query(*(database.qSqlDatabase()));
if (selectedMeasuresOnly){
query.prepare(toQString("SELECT COUNT(*) FROM " + MeasureRecord::databaseTableName() +
" WHERE variableRecordId=:id AND isSelected=:isSelected"));
query.bindValue(":id", this->id());
query.bindValue(":isSelected", true);
}else{
query.prepare(toQString("SELECT COUNT(*) FROM " + MeasureRecord::databaseTableName() +
" WHERE variableRecordId=:id"));
query.bindValue(":id", this->id());
}
assertExec(query);
if (query.first()){
result = query.value(0).toUInt();
}
return result;
}
示例4: projectDatabase
std::vector<VariableRecord> FunctionRecord_Impl::variableRecords() const {
VariableRecordVector result;
ProjectDatabase database = projectDatabase();
QSqlQuery query(*(database.qSqlDatabase()));
query.prepare(toQString("SELECT * FROM " + VariableRecord::databaseTableName() +
" WHERE functionRecordId=:functionRecordId ORDER BY variableVectorIndex"));
query.bindValue(":functionRecordId",id());
assertExec(query);
OptionalInt previousIndex;
bool resort(false);
while (query.next()) {
result.push_back(VariableRecord::factoryFromQuery(query, database).get());
int index = result.back().variableVectorIndex();
if (previousIndex) {
if (index <= previousIndex.get()) {
resort = true; // if variables are changed around, order in database itself can
// get out of date (as compared to database + dirty records).
}
}
previousIndex = index;
}
if (resort) {
VariableRecordVariableVectorIndexLess comparator;
std::sort(result.begin(),result.end(),comparator);
}
return result;
}
示例5: projectDatabase
std::vector<FunctionRecord> OptimizationProblemRecord_Impl::objectiveRecords() const {
FunctionRecordVector result;
ProjectDatabase database = projectDatabase();
QSqlQuery query(*(database.qSqlDatabase()));
query.prepare(toQString("SELECT * FROM " + FunctionRecord::databaseTableName() +
" WHERE problemRecordId=:problemRecordId AND functionType=:functionType " +
"ORDER BY functionVectorIndex"));
query.bindValue(":problemRecordId", id());
query.bindValue(":functionType",FunctionType::Objective);
assertExec(query);
OptionalInt previousIndex;
bool resort(false);
while (query.next()) {
result.push_back(FunctionRecord::factoryFromQuery(query, database).get());
int index = result.back().functionVectorIndex();
if (previousIndex) {
if (index <= previousIndex.get()) {
resort = true; // if functions are moved around, order in database itself can
// get out of date (as compared to database + dirty records).
}
}
previousIndex = index;
}
if (resort) {
FunctionRecordFunctionVectorIndexLess comparator;
std::sort(result.begin(),result.end(),comparator);
}
return result;
}
示例6: getMeasureRecord
MeasureRecord MeasureGroupRecord_Impl::getMeasureRecord(int measureVectorIndex) const
{
ProjectDatabase database = this->projectDatabase();
OptionalMeasureRecord candidate;
QSqlQuery query(*(database.qSqlDatabase()));
query.prepare(toQString("SELECT * FROM " + MeasureRecord::databaseTableName() +
" WHERE variableRecordId=:variableRecordId AND measureVectorIndex=:measureVectorIndex"));
query.bindValue(":variableRecordId", this->id());
query.bindValue(":measureVectorIndex", measureVectorIndex);
assertExec(query);
if (query.first()) {
candidate = MeasureRecord::factoryFromQuery(query,database).get();
}
// check actual vector index. can get out of date during construction.
if ((!candidate) ||
(!candidate->measureVectorIndex()) ||
(candidate->measureVectorIndex().get() != measureVectorIndex))
{
// get all and look for index by hand
for (const MeasureRecord& dpr : measureRecords(false)) {
if (dpr.measureVectorIndex() && (dpr.measureVectorIndex().get() == measureVectorIndex)) {
return dpr;
}
}
}
else {
return *candidate;
}
LOG_AND_THROW("Invalid DiscretMeasure measureVectorIndex "
<< measureVectorIndex << " for MeasureGroup '" << name() << "'.");
return MeasureRecord(std::shared_ptr<detail::MeasureRecord_Impl>(),database);
}
示例7: TEST_F
TEST_F(ProjectFixture, AttributeRecord_ManyAnnualEndUses)
{
ProjectDatabase database = getCleanDatabase("AttributeRecord_ManyAnnualEndUses");
for (unsigned i = 0; i < 10; ++i){
EndUses endUses;
endUses.addEndUse(25.0, EndUseFuelType::Gas, EndUseCategoryType::Heating);
endUses.addEndUse(2.0, EndUseFuelType::Electricity, EndUseCategoryType::Cooling);
endUses.addEndUse(1.0, EndUseFuelType::Electricity, EndUseCategoryType::InteriorLights);
endUses.addEndUse(10.0, EndUseFuelType::Electricity, EndUseCategoryType::Fans, "Fan Energy");
endUses.addEndUse(10.0, EndUseFuelType::Water, EndUseCategoryType::Humidifier);
std::stringstream ss;
ss << "model " << i;
FileReferenceRecord model(FileReference(toPath("./in.osm")),database);
AttributeRecord attributeRecord(endUses.attribute(), model);
ASSERT_TRUE(model.getAttributeRecord(EndUses::attributeName()));
EXPECT_TRUE(endUses.attribute() == model.getAttributeRecord(EndUses::attributeName()).get().attribute());
}
database.save();
}
示例8: projectDatabase
std::vector<UrlRecord> CloudSessionRecord_Impl::workerUrlRecords() const {
UrlRecordVector result;
// return UrlRecords for which this CloudSessionRecord is the parent and the id is not
// equal to m_serverUrlRecordId.
ProjectDatabase database = projectDatabase();
QSqlQuery query(*(database.qSqlDatabase()));
std::stringstream ss;
ss << "SELECT * FROM " << UrlRecord::databaseTableName();
ss << " WHERE parentDatabaseTableName=:parentDatabaseTableName AND ";
ss << "parentRecordId=:parentRecordId";
if (m_serverUrlRecordId) {
ss << " AND (NOT id=:id)";
}
query.prepare(toQString(ss.str()));
query.bindValue(":parentDatabaseTableName",toQString(databaseTableName()));
query.bindValue(":parentRecordId",id());
if (m_serverUrlRecordId) {
query.bindValue(":id",*m_serverUrlRecordId);
}
assertExec(query);
while (query.next()) {
UrlRecord workerUrlRecord(query,database);
result.push_back(workerUrlRecord);
}
return result;
}
示例9: projectDatabase
void ProjectDatabaseRecord_Impl::updatePathData(const openstudio::path& originalBase,
const openstudio::path& newBase)
{
// don't use arguments -- go to the source
ProjectDatabase database = projectDatabase();
setName(toString(database.path()));
setRunManagerDBPath(completeAndNormalize(database.runManager().dbPath()));
}
示例10: toString
ProjectDatabaseRecord_Impl::ProjectDatabaseRecord_Impl(const std::string& version,
const openstudio::path& runManagerDBPath,
const ProjectDatabase& projectDatabase)
: ObjectRecord_Impl(projectDatabase,
toString(projectDatabase.path()),
toString(projectDatabase.path().filename()),
""),
m_version(version),
m_runManagerDBPath(completeAndNormalize(runManagerDBPath))
{
}
示例11: getProjectDatabaseRecord
void ProjectDatabaseRecord::updatePathData(ProjectDatabase database,
const openstudio::path& originalBase,
const openstudio::path& newBase)
{
bool didStartTransaction = database.startTransaction();
ProjectDatabaseRecord record = getProjectDatabaseRecord(database);
record.getImpl<detail::ProjectDatabaseRecord_Impl>()->updatePathData(originalBase,newBase);
if (didStartTransaction) {
bool test = database.commitTransaction();
OS_ASSERT(test);
}
}
示例12: projectDatabase
std::vector<AttributeRecord> InputVariableRecord_Impl::attributeRecords() const {
AttributeRecordVector result;
ProjectDatabase database = projectDatabase();
QSqlQuery query(*(database.qSqlDatabase()));
query.prepare(toQString("SELECT * FROM " + AttributeRecord::databaseTableName() + " WHERE variableRecordId=:variableRecordId"));
query.bindValue(":variableRecordId",id());
assertExec(query);
while (query.next()) {
result.push_back(database.getFromQuery<AttributeRecord>(query));
}
return result;
}
示例13: TEST_F
// Test not yet to scale re: data points.
TEST_F(ProjectFixture,Profile_SaveAnalysis) {
Analysis analysis = getAnalysisToRun(100,500);
// time the process of saving to database
ptime start = microsec_clock::local_time();
ProjectDatabase db = getCleanDatabase(toPath("./SaveAnalysis"));
ASSERT_TRUE(db.startTransaction());
AnalysisRecord record(analysis,db);
db.save();
ASSERT_TRUE(db.commitTransaction());
time_duration saveTime = microsec_clock::local_time() - start;
std::cout << "Time: " << to_simple_string(saveTime) << std::endl;
}
示例14: catch
openstudio::runmanager::Workflow WorkflowRecord_Impl::workflow() const {
ProjectDatabase projectDatabase = this->projectDatabase();
openstudio::runmanager::Workflow result;
openstudio::runmanager::RunManager runManager = projectDatabase.runManager();
try {
result = runManager.loadWorkflow(m_runManagerWorkflowKey);
result.setUUID(handle());
}
catch (...) {
LOG(Error,"Unable to load workflow from RunManager using key "
<< m_runManagerWorkflowKey << ". Returning empty Workflow.");
}
return result;
}
示例15: projectDatabase
std::vector<OSArgumentRecord> RubyMeasureRecord_Impl::osArgumentRecords() const
{
OSArgumentRecordVector result;
ProjectDatabase database = projectDatabase();
QSqlQuery query(*(database.qSqlDatabase()));
query.prepare(toQString("SELECT * FROM " + OSArgumentRecord::databaseTableName() +
" WHERE rubyPerturbationRecordId=:rubyPerturbationId"));
query.bindValue(":rubyPerturbationRecordId",id());
assertExec(query);
while (query.next()) {
result.push_back(OSArgumentRecord(query,database));
}
return result;
}