当前位置: 首页>>代码示例>>C++>>正文


C++ ProjectDatabase::isNewRecord方法代码示例

本文整理汇总了C++中ProjectDatabase::isNewRecord方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectDatabase::isNewRecord方法的具体用法?C++ ProjectDatabase::isNewRecord怎么用?C++ ProjectDatabase::isNewRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectDatabase的用法示例。


在下文中一共展示了ProjectDatabase::isNewRecord方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: constructMeasureRecords

void MeasureGroupRecord::constructMeasureRecords(const analysis::MeasureGroup& measureGroup) {
  MeasureGroupRecord copyOfThis(getImpl<detail::MeasureGroupRecord_Impl>());
  ProjectDatabase database = copyOfThis.projectDatabase();
  bool isNew = database.isNewRecord(copyOfThis);

  int i = 0;
  std::vector<UUID> measureUUIDs;
  for (const Measure& measure : measureGroup.measures(false)) {
    measureUUIDs.push_back(measure.uuid());
    if (measure.isDirty() || isNew) {
      MeasureRecord newMeasureRecord =
          MeasureRecord::factoryFromMeasure(measure,copyOfThis,i);
    }
    ++i;
  }
  if (!isNew) {
    removeMeasureRecords(measureUUIDs,database);
  }
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:19,代码来源:MeasureGroupRecord.cpp

示例2: constructRelatedRecords

void CloudSessionRecord::constructRelatedRecords(const CloudSession& cloudSession,
                                                 ProjectDatabase& database)
{
  CloudSessionRecord copyOfThis(getImpl<detail::CloudSessionRecord_Impl>());
  bool isNew = database.isNewRecord(copyOfThis);
  if (!isNew) {
    getImpl<detail::CloudSessionRecord_Impl>()->revertToLastRecordIds();
  }
  
  if (isNew || (getImpl<detail::CloudSessionRecord_Impl>()->lastUuidLast() != cloudSession.versionUUID())) {
    // remove any existing UrlRecords that have this object as its parent
    ObjectRecordVector childUrls = children();
    for (ObjectRecord& childUrl : childUrls) {
      database.removeRecord(childUrl);
    }
    // create new UrlRecords 
    OptionalAWSSession awsSession = cloudSession.optionalCast<AWSSession>();
    if (OptionalUrl serverUrl = cloudSession.serverUrl()) {
      UrlRecord serverRecord(*serverUrl,copyOfThis);
      if (awsSession) {
        serverRecord.setName(awsSession->serverId());
      }
      getImpl<detail::CloudSessionRecord_Impl>()->setServerUrlRecordId(serverRecord.id());
    }
    StringVector workerIds;
    if (awsSession) {
      workerIds = awsSession->workerIds();
    }
    unsigned index(0);
    for (const Url& workerUrl : cloudSession.workerUrls()) {
      UrlRecord workerRecord(workerUrl,copyOfThis);
      if (index < workerIds.size()) {
        workerRecord.setName(workerIds[index]);
      }
      ++index;
    }
  }
}
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:38,代码来源:CloudSessionRecord.cpp

示例3: constructRelatedRecords

void RubyContinuousVariableRecord::constructRelatedRecords(const analysis::Variable& variable)
{
  analysis::RubyContinuousVariable rubyContinuousVariable = variable.cast<analysis::RubyContinuousVariable>();
  RubyContinuousVariableRecord copyOfThis(getImpl<detail::RubyContinuousVariableRecord_Impl>());
  ProjectDatabase database = projectDatabase();
  bool isNew = database.isNewRecord(copyOfThis);
  if (!isNew) {
    getImpl<detail::RubyContinuousVariableRecord_Impl>()->revertToLastRecordIds();
  }

  // Save resource RubyMeasure
  if (isNew || rubyContinuousVariable.perturbation().isDirty()) {
    RubyMeasureRecord rubyMeasureRecord(rubyContinuousVariable.measure(),database);
    getImpl<detail::RubyContinuousVariableRecord_Impl>()->setRubyMeasureRecordId(rubyMeasureRecord.id());
  }

  // Save child OSArgument
  OSArgument argument = rubyContinuousVariable.argument();
  bool saveArgument = false;
  if (!isNew) {
    {
      // see if old argument record should be removed
      OSArgumentRecord oldArgumentRecord = osArgumentRecord();
      if (oldArgumentRecord.handle() != argument.uuid()) {
        database.removeRecord(oldArgumentRecord);
        saveArgument = true;
      }
      else if (oldArgumentRecord.uuidLast() != argument.versionUUID()) {
        saveArgument = true;
      }
    }
    database.unloadUnusedCleanRecords();
  }
  if (saveArgument || isNew) {
    OSArgumentRecord osArgumentRecord(argument,copyOfThis);
  }
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:37,代码来源:RubyContinuousVariableRecord.cpp

示例4: attribute

// this is a monster test that is more for testing the database than attributes
TEST_F(ProjectFixture, AttributeRecord_LoadSave)
{
  int id;
  UUID handle;
  Attribute attribute("name", 1.0, std::string("m"));
  {
    ProjectDatabase database = getCleanDatabase("AttributeRecord_LoadSave");

    EXPECT_EQ(static_cast<unsigned>(0), AttributeRecord::getAttributeRecords(database).size());

    FileReferenceRecord model(FileReference(toPath("./in.osm")),database);

    AttributeRecord attributeRecord(attribute,model);
    id = attributeRecord.id();
    handle = attributeRecord.handle();
    EXPECT_EQ("name", attributeRecord.name());
    EXPECT_EQ("name", attributeRecord.displayName());
    EXPECT_EQ("", attributeRecord.description());
    EXPECT_EQ(AttributeValueType::Double, attributeRecord.attributeValueType().value());
    EXPECT_EQ(1.0, attributeRecord.attributeValueAsDouble());
    ASSERT_TRUE(attributeRecord.attributeUnits());
    EXPECT_EQ("m", attributeRecord.attributeUnits().get());

    EXPECT_TRUE(database.includesRecord(attributeRecord));
    EXPECT_TRUE(database.isNewRecord(attributeRecord));
    EXPECT_FALSE(database.isDirtyRecord(attributeRecord));
    EXPECT_FALSE(database.isCleanRecord(attributeRecord));
    EXPECT_FALSE(database.isRemovedRecord(attributeRecord));
    EXPECT_EQ(static_cast<unsigned>(2), attributeRecord.useCount());
  }

  {
    // open existing database
    ProjectDatabase database = getExistingDatabase("AttributeRecord_LoadSave");

    // new objects were removed
    EXPECT_EQ(static_cast<unsigned>(0), AnalysisRecord::getAnalysisRecords(database).size());
    EXPECT_EQ(static_cast<unsigned>(0), FileReferenceRecord::getFileReferenceRecords(database).size());
    EXPECT_EQ(static_cast<unsigned>(0), AttributeRecord::getAttributeRecords(database).size());

    FileReferenceRecord model(FileReference(toPath("./in.osm")),database);

    // create AttributeRecord
    AttributeRecord attributeRecord(attribute, model);
    id = attributeRecord.id();
    handle = attributeRecord.handle();
    EXPECT_EQ("name", attributeRecord.name());
    EXPECT_EQ("name", attributeRecord.displayName());
    EXPECT_EQ("", attributeRecord.description());
    EXPECT_EQ(AttributeValueType::Double, attributeRecord.attributeValueType().value());
    EXPECT_EQ(1.0, attributeRecord.attributeValueAsDouble());
    ASSERT_TRUE(attributeRecord.attributeUnits());
    EXPECT_EQ("m", attributeRecord.attributeUnits().get());

    EXPECT_TRUE(database.includesRecord(attributeRecord));
    EXPECT_TRUE(database.isNewRecord(attributeRecord));
    EXPECT_FALSE(database.isDirtyRecord(attributeRecord));
    EXPECT_FALSE(database.isCleanRecord(attributeRecord));
    EXPECT_FALSE(database.isRemovedRecord(attributeRecord));
    EXPECT_EQ(static_cast<unsigned>(2), attributeRecord.useCount());

    // save to database
    EXPECT_TRUE(database.save());

    EXPECT_TRUE(database.includesRecord(attributeRecord));
    EXPECT_FALSE(database.isNewRecord(attributeRecord));
    EXPECT_FALSE(database.isDirtyRecord(attributeRecord));
    EXPECT_TRUE(database.isCleanRecord(attributeRecord));
    EXPECT_FALSE(database.isRemovedRecord(attributeRecord));
    EXPECT_EQ(static_cast<unsigned>(2), attributeRecord.useCount());
  }

  {
    // open existing database
    ProjectDatabase database = getExistingDatabase("AttributeRecord_LoadSave");

    // saved objects were not removed
    ASSERT_EQ(static_cast<unsigned>(1), FileReferenceRecord::getFileReferenceRecords(database).size());
    ASSERT_EQ(static_cast<unsigned>(1), AttributeRecord::getAttributeRecords(database).size());

    std::vector<FileReferenceRecord> fileReferenceRecords = FileReferenceRecord::getFileReferenceRecords(database);
    FileReferenceRecord model = fileReferenceRecords.at(0);
    EXPECT_EQ(static_cast<unsigned>(1), model.attributeRecords().size());
    AttributeRecord attributeRecord = model.attributeRecords()[0];

    EXPECT_EQ(id, attributeRecord.id());
    EXPECT_EQ(handle, attributeRecord.handle());
    EXPECT_EQ("name", attributeRecord.name());
    EXPECT_EQ("name", attributeRecord.displayName());
    EXPECT_EQ("", attributeRecord.description());
    EXPECT_EQ(AttributeValueType::Double, attributeRecord.attributeValueType().value());
    EXPECT_EQ(1.0, attributeRecord.attributeValueAsDouble());
    ASSERT_TRUE(attributeRecord.attributeUnits());
    EXPECT_EQ("m", attributeRecord.attributeUnits().get());

    EXPECT_TRUE(database.includesRecord(attributeRecord));
    EXPECT_FALSE(database.isNewRecord(attributeRecord));
    EXPECT_FALSE(database.isDirtyRecord(attributeRecord));
    EXPECT_TRUE(database.isCleanRecord(attributeRecord));
//.........这里部分代码省略.........
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:101,代码来源:AttributeRecord_GTest.cpp


注:本文中的ProjectDatabase::isNewRecord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。