本文整理汇总了C++中dtn::data::Bundle::getPayloadLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Bundle::getPayloadLength方法的具体用法?C++ Bundle::getPayloadLength怎么用?C++ Bundle::getPayloadLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtn::data::Bundle
的用法示例。
在下文中一共展示了Bundle::getPayloadLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testFragment
void BundleStorageTest::testFragment(dtn::storage::BundleStorage &storage)
{
// Add fragment of a bundle to the storage
dtn::data::Bundle b;
// set standard variables
b.source = dtn::data::EID("dtn://node-one/test");
b.lifetime = 1;
b.destination = dtn::data::EID("dtn://node-two/test");
// add some payload
ibrcommon::BLOB::Reference ref = ibrcommon::BLOB::create();
b.push_back(ref);
(*ref.iostream()) << "Hallo Welt" << std::endl;
// transform bundle into a fragment
b.procflags.setBit(dtn::data::PrimaryBlock::FRAGMENT, true);
b.fragmentoffset = 4;
b.appdatalength = 50;
// store the bundle
storage.store(b);
CPPUNIT_ASSERT_EQUAL((size_t)1, storage.count());
// create a non-fragment meta bundle
const dtn::data::BundleID id(b);
const dtn::data::Bundle retrieved = storage.get(id);
CPPUNIT_ASSERT_EQUAL(id.getPayloadLength(), retrieved.getPayloadLength());
CPPUNIT_ASSERT_EQUAL(id, (const dtn::data::BundleID&)retrieved);
}
示例2: testStore
void BundleStorageTest::testStore(dtn::storage::BundleStorage &storage)
{
dtn::data::Bundle b;
b.source = dtn::data::EID("dtn://node-one/test");
// set standard variable.sourceurce = dtn::data::EID("dtn://node-one/test");
b.lifetime = 120;
b.destination = dtn::data::EID("dtn://node-two/test");
// add some payload
ibrcommon::BLOB::Reference ref = ibrcommon::BLOB::create();
b.push_back(ref);
(*ref.iostream()) << "Hallo Welt" << std::endl;
CPPUNIT_ASSERT_EQUAL((dtn::data::Size)0, storage.count());
storage.store(b);
CPPUNIT_ASSERT_EQUAL((dtn::data::Size)1, storage.count());
// create a bundle id
const dtn::data::BundleID id(b);
CPPUNIT_ASSERT_EQUAL(id, (const dtn::data::BundleID&)b);
const dtn::data::Bundle retrieved = storage.get(id);
CPPUNIT_ASSERT_EQUAL(id.getPayloadLength(), retrieved.getPayloadLength());
CPPUNIT_ASSERT_EQUAL(id, (const dtn::data::BundleID&)retrieved);
}