TEST(InformationSet, filtered_list) { auto handler = std::make_shared<ice::EventHandler>(2, 100); auto spec = std::make_shared<ice::InformationSpecification>("", "type", "scope", "rep"); std::map<std::string, int> metadatas; auto description = std::make_shared<ice::CollectionDescription>(spec, "name,", "provider", "source", metadatas); auto set = std::make_shared<ice::InformationSet<int>>(description, handler); auto vec = std::make_shared<std::vector<std::shared_ptr<ice::InformationElement<int>>> >(); for (int i = 0; i < 1000; ++i) { std::unique_ptr<int> ptr(new int(i)); set->add(std::to_string(i), std::move(ptr)); } int count = set->getFilteredList(vec, [] (std::shared_ptr<ice::InformationElement<int>> &element) { return true;}); EXPECT_EQ(1000, count); vec->clear(); int num = 500; count = set->getFilteredList(vec, [&] (std::shared_ptr<ice::InformationElement<int>> element) { return *element->getInformation() < num;}); EXPECT_EQ(500, count); }
/** * Creates the <UML:Entity> element including its entityliterals. */ void UMLEntity::saveToXMI(QDomDocument& qDoc, QDomElement& qElement) { QDomElement entityElement = UMLObject::save("UML:Entity", qDoc); //save operations UMLClassifierListItemList entityAttributes = getFilteredList(UMLObject::ot_EntityAttribute); UMLClassifierListItem* pEntityAttribute = 0; foreach (pEntityAttribute, entityAttributes) { pEntityAttribute->saveToXMI(qDoc, entityElement); }
/** * Returns the number of entityAttributes for the class. * @return The number of entityAttributes for the class. */ int UMLEntity::entityAttributes() { UMLClassifierListItemList entityAttributes = getFilteredList(UMLObject::ot_EntityAttribute); return entityAttributes.count(); }
} /** * Creates the <UML:Entity> element including its entityliterals. */ void UMLEntity::saveToXMI(QDomDocument& qDoc, QDomElement& qElement) { QDomElement entityElement = UMLObject::save("UML:Entity", qDoc); //save operations UMLClassifierListItemList entityAttributes = getFilteredList(UMLObject::ot_EntityAttribute); UMLClassifierListItem* pEntityAttribute = 0; foreach (pEntityAttribute, entityAttributes) { pEntityAttribute->saveToXMI(qDoc, entityElement); } UMLClassifierListItemList entityConstraints = getFilteredList(UMLObject::ot_EntityConstraint); foreach(UMLClassifierListItem* cli, entityConstraints) { cli->saveToXMI(qDoc,entityElement); } qElement.appendChild(entityElement); } /** * Loads the <UML:Entity> element including its entityAttributes. */ bool UMLEntity::load(QDomElement& element) { QDomNode node = element.firstChild(); while( !node.isNull() ) { if (node.isComment()) {