本文整理汇总了C++中MultiTag::id方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiTag::id方法的具体用法?C++ MultiTag::id怎么用?C++ MultiTag::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiTag
的用法示例。
在下文中一共展示了MultiTag::id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testUnits
void BaseTestMultiTag::testUnits() {
MultiTag dt = block.createMultiTag("TestMultiTag1", "Tag", positions);
std::vector<std::string> valid_units = {"mV", "cm", "m^2"};
std::vector<std::string> invalid_units = {"mV", "haha", "qm^2"};
std::vector<std::string> insane_units = {"muV ", " muS"};
CPPUNIT_ASSERT_NO_THROW(dt.units(valid_units));
CPPUNIT_ASSERT(dt.units().size() == valid_units.size());
std::vector<std::string> retrieved_units = dt.units();
for (size_t i = 0; i < retrieved_units.size(); i++) {
CPPUNIT_ASSERT(retrieved_units[i] == valid_units[i]);
}
dt.units(none);
CPPUNIT_ASSERT(dt.units().size() == 0);
CPPUNIT_ASSERT_THROW(dt.units(invalid_units), InvalidUnit);
CPPUNIT_ASSERT(dt.units().size() == 0);
dt.units(insane_units);
retrieved_units = dt.units();
CPPUNIT_ASSERT(retrieved_units.size() == 2);
CPPUNIT_ASSERT(retrieved_units[0] == "uV");
CPPUNIT_ASSERT(retrieved_units[1] == "uS");
block.deleteMultiTag(dt.id());
}
示例2: testRead
void BaseTestReadOnly::testRead() {
File file = File::open("test_read_only.h5", FileMode::ReadOnly);
Section section = file.getSection(section_id);
Block block = file.getBlock(block_id);
DataArray data_array = block.getDataArray(data_array_id);
Dimension dim = data_array.getDimension(dim_index);
SampledDimension dim_sampled = data_array.getDimension(dim_sampled_index).asSampledDimension();
RangeDimension dim_range = data_array.getDimension(dim_range_index).asRangeDimension();
SetDimension dim_set = data_array.getDimension(dim_set_index).asSetDimension();
Tag tag = block.getTag(tag_id);
MultiTag mtag = block.getMultiTag(mtag_id);
Feature feature = tag.getFeature(feature_id);
Property property = section.getProperty(property_id);
// TODO use assertions here
s << block.id() << block.name();
s << data_array.id() << data_array.name();
s << tag.id() << tag.name();
s << mtag.id() << mtag.name();
s << feature.id();
s << property.id() << property.name();
s << dim.index();
s << dim_sampled.index();
s << dim_range.index();
s << dim_set.index();
file.close();
}
示例3: init
void BaseTestReadOnly::init(nix::File &file) {
startup_time = time(NULL);
std::vector<nix::Value> values = { nix::Value(1.0),
nix::Value(2.0),
nix::Value(-99.99) };
std::vector<double> ticks = {1.0, 2.0, 3.4, 42.0};
Section section = file.createSection("foo_section", "metadata");
Block block = file.createBlock("block_one", "dataset");
DataArray positions = block.createDataArray("positions_DataArray", "dataArray",
DataType::Double, NDSize({ 0, 0 }));
DataArray data_array = block.createDataArray("array_one",
"testdata",
nix::DataType::Double,
nix::NDSize({ 0, 0, 0 }));
Dimension dim = data_array.appendSampledDimension(3.14);
SampledDimension dim_sampled = data_array.appendSampledDimension(3.14);
RangeDimension dim_range = data_array.appendRangeDimension(ticks);
SetDimension dim_set = data_array.appendSetDimension();
Tag tag = block.createTag("featureTest", "Test", {0.0, 2.0, 3.4});
MultiTag mtag = block.createMultiTag("tag_one", "test_tag", positions);
Feature feature = tag.createFeature(data_array, nix::LinkType::Tagged);
Property property = section.createProperty("doubleProperty", values);
section_id = section.id(); feature_id = feature.id(); tag_id = tag.id();
mtag_id = mtag.id(); property_id = property.id(); block_id = block.id();
data_array_id = data_array.id(); dim_index = dim.index();
dim_sampled_index = dim_sampled.index(); dim_range_index = dim_range.index();
dim_set_index = dim_set.index();
file.close();
}
示例4: testMultiTagAccess
void TestBlock::testMultiTagAccess() {
vector<string> names = { "tag_a", "tag_b", "tag_c", "tag_d", "tag_e" };
// create a valid positions data array below
typedef boost::multi_array<double, 3>::index index;
DataArray positions = block.createDataArray("array_one",
"testdata",
DataType::Double,
nix::NDSize({ 3, 4, 2 }));
boost::multi_array<double, 3> A(boost::extents[3][4][2]);
int values = 0;
for(index i = 0; i != 3; ++i)
for(index j = 0; j != 4; ++j)
for(index k = 0; k != 2; ++k)
A[i][j][k] = values++;
positions.setData(A);
CPPUNIT_ASSERT(block.multiTagCount() == 0);
CPPUNIT_ASSERT(block.multiTags().size() == 0);
CPPUNIT_ASSERT(block.getMultiTag("invalid_id") == false);
vector<string> ids;
for (auto it = names.begin(); it != names.end(); it++) {
MultiTag tag = block.createMultiTag(*it, "segment", positions);
CPPUNIT_ASSERT(tag.name() == *it);
ids.push_back(tag.id());
}
CPPUNIT_ASSERT_THROW(block.createMultiTag(names[0], "segment", positions),
DuplicateName);
CPPUNIT_ASSERT(block.multiTagCount() == names.size());
CPPUNIT_ASSERT(block.multiTags().size() == names.size());
for (auto it = ids.begin(); it != ids.end(); it++) {
MultiTag tag = block.getMultiTag(*it);
CPPUNIT_ASSERT(block.hasMultiTag(*it) == true);
CPPUNIT_ASSERT(tag.id() == *it);
block.deleteMultiTag(*it);
}
CPPUNIT_ASSERT(block.multiTagCount() == 0);
CPPUNIT_ASSERT(block.multiTags().size() == 0);
CPPUNIT_ASSERT(block.getMultiTag("invalid_id") == false);
}
示例5: testReferences
void BaseTestMultiTag::testReferences(){
DataArray da_1 = block.createDataArray("TestReference 1",
"Reference",
DataType::Double,
NDSize({ 0 }));
DataArray da_2 = block.createDataArray("TestReference 2", "Reference",
DataType::Double,
NDSize({ 0 }));
DataArray a;
MultiTag dt = block.createMultiTag("TestMultiTag1", "Tag", positions);
CPPUNIT_ASSERT_THROW(dt.getReference(42), OutOfBounds);
CPPUNIT_ASSERT(!dt.hasReference(a));
std::stringstream counterrmsg;
counterrmsg << "BaseTestMultiTag::testReference: Counts do not match!";
CPPUNIT_ASSERT_MESSAGE(counterrmsg.str(), dt.referenceCount() == 0);
dt.addReference(da_1);
dt.addReference(da_2);
CPPUNIT_ASSERT_THROW(dt.addReference(a), UninitializedEntity);
CPPUNIT_ASSERT_THROW(dt.removeReference(a), UninitializedEntity);
CPPUNIT_ASSERT_MESSAGE(counterrmsg.str(), dt.referenceCount() == 2);
CPPUNIT_ASSERT(dt.hasReference(da_1));
CPPUNIT_ASSERT(dt.hasReference(da_2));
std::stringstream haserrmsg;
haserrmsg << "BaseTestMultiTag::testReference: Has method did not work!";
CPPUNIT_ASSERT_MESSAGE(haserrmsg.str(), dt.hasReference(da_1.id()));
CPPUNIT_ASSERT_MESSAGE(haserrmsg.str(), dt.hasReference(da_1.name()));
DataArray ref1 = dt.getReference(da_1.id());
std::stringstream retrieveerrmsg;
retrieveerrmsg << "BaseTestMultiTag::testReference: Retrieval did not work!";
CPPUNIT_ASSERT_MESSAGE(retrieveerrmsg.str(), ref1.id() == da_1.id());
DataArray ref2 = dt.getReference(da_1.name());
retrieveerrmsg << "BaseTestMultiTag::testReference: Retrieval by name did not work!";
CPPUNIT_ASSERT_MESSAGE(retrieveerrmsg.str(), ref2.id() == da_1.id());
std::vector<DataArray> arrays = dt.references();
CPPUNIT_ASSERT_MESSAGE(retrieveerrmsg.str(), arrays.size() == 2);
std::stringstream hasReferrmsg;
hasReferrmsg << "BaseTestMultiTag::testReference: hadReference did not work!";
CPPUNIT_ASSERT_MESSAGE(hasReferrmsg.str(), dt.hasReference(da_1.id()));
CPPUNIT_ASSERT_MESSAGE(hasReferrmsg.str(), dt.hasReference(da_2.id()));
std::stringstream delReferrmsg;
delReferrmsg << "BaseTestMultiTag::testReference: removeReference did not work!";
dt.removeReference(da_1.id());
CPPUNIT_ASSERT_MESSAGE(delReferrmsg.str(), dt.referenceCount() == 1);
dt.removeReference("NONEXISTENT");
CPPUNIT_ASSERT_MESSAGE(delReferrmsg.str(), dt.referenceCount() == 1);
dt.removeReference(da_2.name());
CPPUNIT_ASSERT_MESSAGE(delReferrmsg.str(), dt.referenceCount() == 0);
dt.addReference(da_1);
CPPUNIT_ASSERT(dt.referenceCount() == 1);
CPPUNIT_ASSERT_NO_THROW(dt.removeReference(da_1));
CPPUNIT_ASSERT(dt.referenceCount() == 0);
// delete data arrays
std::vector<std::string> ids = {da_1.id(), da_2.id()};
block.deleteDataArray(da_1.id());
block.deleteDataArray(da_2.id());
// check if references are gone too!
CPPUNIT_ASSERT(dt.referenceCount() == 0);
CPPUNIT_ASSERT(!dt.hasReference(ids[0]));
CPPUNIT_ASSERT(!dt.hasReference(ids[1]));
block.deleteMultiTag(dt.id());
}
示例6: removeMultiTag
bool Group::removeMultiTag(const MultiTag &multi_tag) {
if (!util::checkEntityInput(multi_tag, false)) {
return false;
}
return backend()->removeMultiTag(multi_tag.id());
}
示例7: addMultiTag
void Group::addMultiTag(const MultiTag &multi_tag) {
if (!util::checkEntityInput(multi_tag)) {
throw UninitializedEntity();
}
backend()->addMultiTag(multi_tag.id());
}