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


C++ MetaData::set方法代码示例

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


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

示例1: writeProperty

void writeProperty(const std::string &archiveName)
{
    const unsigned int numSamples = 5;

    // Create an archive for writing. Indicate that we want Alembic to
    //   throw exceptions on errors.
    OArchive archive( Alembic::AbcCoreHDF5::WriteArchive(),
                      archiveName, ErrorHandler::kThrowPolicy );
    OObject archiveTop = archive.getTop();

    // Create a child, parented under the archive
    std::string name = "child";
    OObject child( archiveTop, name );
    OCompoundProperty childProps = child.getProperties();

    // Create a scalar property on this child object named 'mass'
    //  with metadata that indicates it's expressed in kilograms
    MetaData units;
    units.set( "units", "kilogram" );
    ODoubleProperty mass( childProps,    // owner
                          "mass",   // name
                          units );  // metadata
        
    for (int tt=0; tt<numSamples; tt++)
    {
        double mm = (33.0 + 0.1*tt); // vary the mass
        mass.set( mm,  OSampleSelector(tt) );
    }    

    std::cout << archiveName << " was successfully written" << std::endl;
    // Done - the archive closes itself
}
开发者ID:ryutaro765,项目名称:Alembic,代码行数:32,代码来源:IdentityPropertyTest.cpp

示例2: onRightClick

void ItemFood::onRightClick(User* user, Item* item)
{
	int healammount = 0;
	switch (item->getType()) {
	case ITEM_GOLDEN_APPLE:
		healammount = 20;
		break;
	case ITEM_MUSHROOM_SOUP:
		healammount = 10;
		break;
	case ITEM_GRILLED_PORK:
		healammount = 8;
		break;
	case ITEM_PORK:
		healammount = 3;
		break;
	case ITEM_BREAD:
		healammount = 5;
		break;
	case ITEM_COOKED_FISH:
		healammount = 5;
		break;
	case ITEM_RAW_FISH:
		healammount = 2;
		break;
	case ITEM_APPLE:
		healammount = 4;
		break;
	}

	int newhealth = user->health + healammount;
	if (newhealth > 20) {
		newhealth = 20;
	}

	user->sethealth(newhealth);

	//Accept eating
	user->buffer << Protocol::entityStatus(user->UID, 9);

	//Eating animation
	MetaData meta;
	meta.set(MetaDataElem(0,0x10));
	Packet pkt = Protocol::animation(user->UID,5);
	//pkt << Protocol::entityMetadata(user->UID, meta);
	//ToDo: add timer stop animation

	sChunk* chunk = ServerInstance->map(user->pos.map)->getChunk(blockToChunk((int32_t)user->pos.x), blockToChunk((int32_t)user->pos.z));
	if (chunk != nullptr) {
		chunk->sendPacket(pkt);
	}

	if(item->getCount() > 1) {
		item->setCount(item->getCount()-1);
	} else {
		item->setType(-1);
		item->setCount(0);
	}
}
开发者ID:chtisgit,项目名称:mine152,代码行数:59,代码来源:food.cpp

示例3: createCallBack

void GenomeMetaTest::createCallBack(Alignment *alignment) {
    hal_size_t alignmentSize = alignment->getNumGenomes();
    CuAssertTrue(_testCase, alignmentSize == 0);

    Genome *ancGenome = alignment->addRootGenome("AncGenome", 0);

    MetaData *ancMeta = ancGenome->getMetaData();
    ancMeta->set("Young", "Jeezy");
}
开发者ID:glennhickey,项目名称:hal,代码行数:9,代码来源:halGenomeTest.cpp

示例4: writeProperty

void writeProperty(const std::string &archiveName, bool useOgawa)
{
    unsigned int numSamples = 5;

    // Create an archive for writing. Indicate that we want Alembic to
    //   throw exceptions on errors.
    OArchive archive;
    if ( useOgawa )
    {
        archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(),
                            archiveName, ErrorHandler::kThrowPolicy );
    }
#ifdef ALEMBIC_WITH_HDF5
    else
    {
        archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(),
                            archiveName, ErrorHandler::kThrowPolicy );
    }
#endif

    OObject archiveTop = archive.getTop();

    // Create a child, parented under the archive
    std::string name = "child";
    OObject child( archiveTop, name );
    OCompoundProperty childProps = child.getProperties();

    // Create cyclic time sampling
     std::vector<chrono_t> tvec;
    tvec.push_back(  g_startTime );
    tvec.push_back(  g_startTime + g_dt/3.0 );
    tvec.push_back(  g_startTime + 2.0*g_dt/3.0 );
    const chrono_t timePerCycle = g_dt;
    const size_t numSamplesPerCycle = 3;

    numSamples *= numSamplesPerCycle;
    const TimeSamplingType tSampTyp( numSamplesPerCycle, timePerCycle );
    TimeSamplingPtr ts( new TimeSampling( tSampTyp, tvec ) );

    // Create a scalar property on this child object named 'mass'
    //  with metadata that indicates it's expressed in kilograms
    MetaData units;
    units.set( "units", "kilogram" );
    ODoubleProperty mass( childProps,  // owner
                          "mass", // name
                          units,
                          ts ); // cyclic, specified above

    for (unsigned int tt=0; tt<numSamples; tt++)
    {
        double mm = (1.0 + 0.1*tt); // vary the mass
        mass.set( mm );
    }

    std::cout << archiveName << " was successfully written" << std::endl;
    // Done - the archive closes itself
}
开发者ID:AWhetter,项目名称:alembic,代码行数:57,代码来源:CyclicPropertyTest.cpp

示例5: entity_crouch

int PacketHandler::entity_crouch(User* user)
{
  int32_t EID;
  int8_t action;
  MetaData meta;
  MetaDataElemByte *element;

  user->buffer >> EID >> action;
  Packet pkt;
  bool packetData = false;

  //ToDo: handle other actions
  switch(action)
  {
  //Crouch
  case 1:    
    element = new MetaDataElemByte(0,0x02);
    meta.set(element);
    pkt << Protocol::animation(user->UID, 104) << Protocol::entityMetadata(user->UID,meta);
    packetData = true;
    break;
    //Uncrouch
  case 2:
    element = new MetaDataElemByte(0,0x00);
    meta.set(element);
    pkt << Protocol::animation(user->UID, 105) << Protocol::entityMetadata(user->UID,meta);
    packetData = true;
    break;
  default:
    break;
  }
  
  if(packetData)
  {
    sChunk* chunk = ServerInstance->map(user->pos.map)->getChunk(blockToChunk((int32_t)user->pos.x), blockToChunk((int32_t)user->pos.z));
    if (chunk != NULL)
    {
      chunk->sendPacket(pkt);
    }
  }

  user->buffer.removePacket();
  return PACKET_OK;
}
开发者ID:C-plus-plus,项目名称:mineserver,代码行数:44,代码来源:packets.cpp

示例6: createCallBack

void MetaDataTest::createCallBack(Alignment *alignment) {
    hal_size_t alignmentSize = alignment->getNumGenomes();
    CuAssertTrue(_testCase, alignmentSize == 0);

    MetaData *meta = alignment->getMetaData();
    CuAssertTrue(_testCase, meta->getMap().empty() == true);
    meta->set("colour", "red");
    meta->set("number", "1");
    meta->set("animal", "cat");
    meta->set("colour", "black");

    CuAssertTrue(_testCase, meta->get("colour") == "black");
    CuAssertTrue(_testCase, meta->get("number") == "1");
    CuAssertTrue(_testCase, meta->get("animal") == "cat");

    CuAssertTrue(_testCase, meta->has("colour") == true);
    CuAssertTrue(_testCase, meta->has("city") == false);

    CuAssertTrue(_testCase, meta->getMap().size() == 3);
}
开发者ID:glennhickey,项目名称:hal,代码行数:20,代码来源:halMetaDataTest.cpp

示例7: main

int main(int argc, char *argv[])
{
  CLParserPtr optParser = initParser();
  string inPath, bottomAlignmentFile, topAlignmentFile, genomeName;
  bool noMarkAncestors;
  try {
    optParser->parseOptions(argc, argv);
    inPath = optParser->getArgument<string>("inFile");
    bottomAlignmentFile = optParser->getOption<string>("bottomAlignmentFile");
    topAlignmentFile = optParser->getOption<string>("topAlignmentFile");
    genomeName = optParser->getArgument<string>("genomeName");
    noMarkAncestors = optParser->getFlag("noMarkAncestors");
  } catch (exception &e) {
    optParser->printUsage(cerr);
    return 1;
  }
  AlignmentPtr mainAlignment = openHalAlignment(inPath, optParser);
  AlignmentConstPtr bottomAlignment;
  AlignmentConstPtr topAlignment;
  bool useTopAlignment = mainAlignment->getRootName() != genomeName;
  bool useBottomAlignment = mainAlignment->getChildNames(genomeName).size() != 0;
  Genome *mainReplacedGenome = mainAlignment->openGenome(genomeName);
  if (useTopAlignment) {
    // Not a root genome. Can update using a top alignment.
    if (topAlignmentFile == "\"\"") {
      throw hal_exception("Cannot replace non-root genome without a top "
                          "alignment file.");
    }
    topAlignment = openHalAlignment(topAlignmentFile,
                                    optParser);
    const Genome *topReplacedGenome = topAlignment->openGenome(genomeName);
    topReplacedGenome->copyDimensions(mainReplacedGenome);
    topReplacedGenome->copySequence(mainReplacedGenome);
    
  }
  if (useBottomAlignment) {
    // Not a leaf genome. Can update using a bottom alignment.
    if (bottomAlignmentFile == "\"\"") {
      throw hal_exception("Cannot replace non-leaf genome without a bottom "
                          "alignment file.");
    }
    bottomAlignment = openHalAlignment(bottomAlignmentFile, optParser);
    const Genome *botReplacedGenome = bottomAlignment->openGenome(genomeName);
    botReplacedGenome->copyDimensions(mainReplacedGenome);
    botReplacedGenome->copySequence(mainReplacedGenome);
  }
  if (!useTopAlignment && !useBottomAlignment) {
    throw hal_exception("Root genome is also a leaf genome.");
  }
  if (useBottomAlignment) {
    copyFromBottomAlignment(bottomAlignment, mainAlignment, genomeName);
  }
  if (useTopAlignment) {
    copyFromTopAlignment(topAlignment, mainAlignment, genomeName);
  }

  // Clear update flag if present, since the genome has just been updated.
  MetaData *metaData = mainReplacedGenome->getMetaData();
  if (metaData->has("needsUpdate")) {
    metaData->set("needsUpdate", "false");
  }

  if (!noMarkAncestors) {
    markAncestorsForUpdate(mainAlignment, genomeName);
  }
  if (useTopAlignment) {
    topAlignment->close();
  }
  if (useBottomAlignment) {
    bottomAlignment->close();
  }
  mainAlignment->close();
}
开发者ID:dayin1989,项目名称:hal,代码行数:73,代码来源:halReplaceGenome.cpp


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