本文整理汇总了C++中MeiDocument::getElementById方法的典型用法代码示例。如果您正苦于以下问题:C++ MeiDocument::getElementById方法的具体用法?C++ MeiDocument::getElementById怎么用?C++ MeiDocument::getElementById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeiDocument
的用法示例。
在下文中一共展示了MeiDocument::getElementById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMeiDocument
TEST(CmnModuleTest, TestTieMembership) {
MeiDocument* doc = createMeiDocument();
MeiElement* layer = doc->getElementById("id-layer");
MeiElement* measure = doc->getElementById("id-measure");
Note* n1 = new Note();
Note* n2 = new Note();
Note* n3 = new Note();
Note* n4 = new Note();
layer->addChild(n1);
layer->addChild(n2);
layer->addChild(n3);
layer->addChild(n4);
Tie* t1 = new Tie();
measure->addChild(t1);
t1->m_Startid.setStartid(n1->getId());
t1->m_Startendid.setEndid(n4->getId());
t1->m_Staffident.setStaff("staffname");
vector<MeiElement*> members = t1->getMembers();
ASSERT_EQ(4, members.size());
}
示例2: Mei
// after adding a root to a document, you can find an element
TEST(TestMeiDocument, ElementById) {
Mei *mei = new Mei();
Music *mus = new Music();
Body *body = new Body();
Staff *staff = new Staff();
Staff *s2 = new Staff();
Note *n1 = new Note();
string wantedId = n1->getId();
Note *n2 = new Note();
Note *n3 = new Note();
Note *n4 = new Note();
MeiDocument *doc = new MeiDocument();
ASSERT_EQ(NULL, doc->getElementById(wantedId));
mei->addChild(mus);
mus->addChild(body);
body->addChild(staff);
body->addChild(s2);
staff->addChild(n1);
staff->addChild(n2);
staff->addChild(n3);
s2->addChild(n4);
doc->setRootElement(mei);
ASSERT_EQ(n1, doc->getElementById(wantedId));
ASSERT_EQ(NULL, doc->getElementById("some-unknown-id"));
// After adding the root element, making a new element works
Note *n5 = new Note();
string newid = n5->getId();
s2->addChild(n5);
ASSERT_EQ(n5, doc->getElementById(newid));
// removing the element from the document, clear from document map
s2->removeChild(n5);
ASSERT_EQ(NULL, doc->getElementById(newid));
}