📄 simple-test.cc
字号:
else state_good = false; if (state_good) cout << "ok.\n"; else cout <<"failed.\n"; cout << "Checking EdgeIterator::next_n () ..." << flush; contains->get_edges (0, edges, edge_iterator); if (!CORBA::is_nil (edge_iterator)) { edge_iterator->next_n (1, edges); tmp_obr = Documents::Figure::_narrow (CosCompoundLifeCycle::Node::_narrow ((*edges)[0].relatives[0].the_role.the_role ->related_object ())->related_object ()); if (strcmp (tmp_obr->name (), obr3->name ()) != 0) state_good = false; edge_iterator->next_one (edge); edge_iterator->next_one (edge); if (edge_iterator->next_one (edge)) state_good = false; edge_iterator->destroy (); } else state_good = false; contains->get_edges (0, edges, edge_iterator); if (!CORBA::is_nil (edge_iterator)) { edge_iterator->next_n (3, edges); tmp_obr = Documents::Figure::_narrow (CosCompoundLifeCycle::Node::_narrow ((*edges)[0].relatives[0].the_role.the_role ->related_object ())->related_object ()); if (strcmp (tmp_obr->name (), obr3->name ()) != 0) state_good = false; tmp_obr = Documents::Figure::_narrow (CosCompoundLifeCycle::Node::_narrow ((*edges)[1].relatives[0].the_role.the_role ->related_object ())->related_object ()); if (strcmp (tmp_obr->name (), obr1->name ()) != 0) state_good = false; tmp_obr = Documents::Figure::_narrow (CosCompoundLifeCycle::Node::_narrow ((*edges)[2].relatives[0].the_role.the_role ->related_object ())->related_object ()); if (strcmp (tmp_obr->name (), obr2->name ()) != 0) state_good = false; if (edge_iterator->next_one (edge)) state_good = false; edge_iterator->destroy (); } else state_good = false; contains->get_edges (0, edges, edge_iterator); if (!CORBA::is_nil (edge_iterator)) { edge_iterator->next_n (30, edges); tmp_obr = Documents::Figure::_narrow (CosCompoundLifeCycle::Node::_narrow ((*edges)[0].relatives[0].the_role.the_role ->related_object ())->related_object ()); if (strcmp (tmp_obr->name (), obr3->name ()) != 0) state_good = false; tmp_obr = Documents::Figure::_narrow (CosCompoundLifeCycle::Node::_narrow ((*edges)[1].relatives[0].the_role.the_role ->related_object ())->related_object ()); if (strcmp (tmp_obr->name (), obr1->name ()) != 0) state_good = false; tmp_obr = Documents::Figure::_narrow (CosCompoundLifeCycle::Node::_narrow ((*edges)[2].relatives[0].the_role.the_role ->related_object ())->related_object ()); if (strcmp (tmp_obr->name (), obr2->name ()) != 0) state_good = false; if (edge_iterator->next_one (edge)) state_good = false; edge_iterator->destroy (); } else state_good = false; contains->get_edges (0, edges, edge_iterator); if (!CORBA::is_nil (edge_iterator)) { edge_iterator->next_n (0, edges); if (!edge_iterator->next_one (edge)) state_good = false; if (!edge_iterator->next_one (edge)) state_good = false; if (!edge_iterator->next_one (edge)) state_good = false; if (edge_iterator->next_one (edge)) state_good = false; edge_iterator->destroy (); } else state_good = false; if (state_good) cout << "ok.\n"; else cout <<"failed.\n"; state_good = true; cout << "Checking TraversalFactory_impl::create_traversal_on () ..." << flush; CosGraphs::TraversalCriteria_ptr criteria = criteria_factory->create (CosCompoundLifeCycle::copy); if (CORBA::is_nil (criteria)) state_good = false; CosGraphs::NodeHandle node_text_handle; CosGraphs::Traversal::ScopedEdge* scoped_edge; node_text_handle.the_node = CosCompoundLifeCycle::Node::_duplicate (node_text); node_text_handle.constant_random_id = node_text->constant_random_id (); CosGraphs::Traversal_ptr traversal = traversal_factory->create_traversal_on //(node_text_handle, criteria, CosGraphs::breadthFirst); (node_text_handle, criteria, CosGraphs::depthFirst); if (CORBA::is_nil (traversal)) state_good = false; if (state_good) cout << "ok.\n"; else cout <<"failed.\n"; cout << "Checking traversing graphs of related objects - depthFirst\n"; assert (!CORBA::is_nil (traversal)); while (traversal->next_one (scoped_edge)) { cout << "from: " << Documents::AbstractDocument::_narrow (scoped_edge->from.point.the_node.the_node->related_object ())->name () << "\n"; cout << "role: " << scoped_edge->from.point.the_role.the_name << "\n"; cout << "to: " << Documents::AbstractDocument::_narrow (scoped_edge->relatives[0].point.the_node.the_node->related_object ())->name () << "\n"; cout << "role: " << scoped_edge->relatives[0].point.the_role.the_name << "\n"; cout << "\n"; } state_good = true; traversal->destroy (); CosGraphs::TraversalCriteria_ptr criteria2 = criteria_factory->create (CosCompoundLifeCycle::copy); assert (!CORBA::is_nil (criteria2)); CosGraphs::NodeHandle node_obr1_handle; node_obr1_handle.the_node = CosCompoundLifeCycle::Node::_duplicate (node_obr1); node_obr1_handle.constant_random_id = node_obr1->constant_random_id (); CosGraphs::Traversal_ptr traversal2 = traversal_factory->create_traversal_on (node_text_handle, criteria2, CosGraphs::breadthFirst); assert (!CORBA::is_nil (traversal2)); cout << "Checking traversing graphs of related objects - breadthFirst\n"; CosGraphs::Traversal::ScopedEdge* scoped_edge2; while (traversal2->next_one (scoped_edge2)) { assert (scoped_edge2 != NULL); assert (!CORBA::is_nil (scoped_edge2->from.point.the_node.the_node)); cout << "from: " << Documents::AbstractDocument::_narrow (scoped_edge2->from.point.the_node.the_node->related_object ())->name () << "\n"; cout << "role: " << scoped_edge2->from.point.the_role.the_name << "\n"; cout << "to: " << Documents::AbstractDocument::_narrow (scoped_edge2->relatives[0].point.the_node.the_node->related_object ())->name () << "\n"; cout << "role: " << scoped_edge2->relatives[0].point.the_role.the_name << "\n"; cout << "\n"; } cout << "Binding to FactoryFinder ..." << flush; CORBA::ORB::ObjectTag_var tagff = CORBA::ORB::string_to_tag ("FactoryFinder_impl"); CORBA::Object_var objff = orb->bind ("IDL:omg.org/CosLifeCycle/FactoryFinder:1.0", tagff.in()); assert (!CORBA::is_nil (objff)); CosLifeCycle::FactoryFinder_var factory_finder; if (factory_finder = CosLifeCycle::FactoryFinder::_narrow (objff)) cout << "done.\n" << flush; else cout << "ERROR!\n" << flush; cout << "Binding to OperationsFactory ..." << flush; CORBA::ORB::ObjectTag_var tagof = CORBA::ORB::string_to_tag ("Operations_impl"); CORBA::Object_var objof = orb->bind ("IDL:omg.org/CosCompoundLifeCycle/OperationsFactory:1.0", tagof.in()); assert (!CORBA::is_nil (objof)); CosCompoundLifeCycle::OperationsFactory_var operations_factory; if (operations_factory = CosCompoundLifeCycle::OperationsFactory::_narrow (objof)) cout << "done.\n" << flush; else cout << "ERROR!\n" << flush; CosCompoundLifeCycle::Operations_ptr oper = operations_factory->create_compound_operations(); CosLifeCycle::Criteria the_criteria; the_criteria.length(0); cout << "Checking copy operations for graphs of related objects\n"; exception=FALSE; CosCompoundLifeCycle::Node_var new_node; try { CORBA::Object_ptr __obj = oper->copy(node_text,CosLifeCycle::FactoryFinder::_duplicate(factory_finder),the_criteria); new_node = CosCompoundLifeCycle::Node::_narrow(__obj); } catch (CORBA::SystemException& e) { cout << "system exception\n"; exception = TRUE; } catch (CosLifeCycle::NoFactory& e) { cout << "NoFactory exception\n"; exception = TRUE; } catch (CosLifeCycle::NotCopyable& e) { cout << "NotCopyable exception\n"; exception = TRUE; } catch (CosLifeCycle::InvalidCriteria& e) { cout << "InvalidCriteria exception\n"; exception = TRUE; } catch (CosLifeCycle::CannotMeetCriteria& e) { cout << "CannotMeetCriteria exception\n"; exception = TRUE; } if (exception) cout << "error\n"; else cout << "ok\n"; CosGraphs::TraversalCriteria_ptr criteria3 = criteria_factory->create (CosCompoundLifeCycle::copy); assert (!CORBA::is_nil (criteria3)); CosGraphs::NodeHandle new_node_handle; new_node_handle.the_node = CosCompoundLifeCycle::Node::_duplicate (new_node); new_node_handle.constant_random_id = new_node->constant_random_id (); CosGraphs::Traversal_ptr traversal3 = traversal_factory->create_traversal_on (new_node_handle, criteria3, CosGraphs::breadthFirst); assert (!CORBA::is_nil (traversal3)); cout << "Checking traversing graphs of coped related objects - breadthFirst\n"; CosGraphs::Traversal::ScopedEdge* scoped_edge3; while (traversal3->next_one (scoped_edge3)) { assert (scoped_edge3 != NULL); assert (!CORBA::is_nil (scoped_edge3->from.point.the_node.the_node)); cout << "from: " << Documents::AbstractDocument::_narrow (scoped_edge3->from.point.the_node.the_node->related_object ())->name () << "\n"; cout << "role: " << scoped_edge3->from.point.the_role.the_name << "\n"; cout << "to: " << Documents::AbstractDocument::_narrow (scoped_edge3->relatives[0].point.the_node.the_node->related_object ())->name () << "\n"; cout << "role: " << scoped_edge3->relatives[0].point.the_role.the_name << "\n"; cout << "\n"; } cout << "Checking LifeCycle remove operation ..."; exception=FALSE; try { oper->remove(new_node.inout()); } catch (CORBA::SystemException& e) { cout << "system exception\n"; exception = TRUE; } catch (CosLifeCycle::NoFactory& e) { cout << "NoFactory exception\n"; exception = TRUE; } catch (CosLifeCycle::NotRemovable& e) { cout << "NotCopyable exception\n"; exception = TRUE; } catch (CosLifeCycle::InvalidCriteria& e) { cout << "InvalidCriteria exception\n"; exception = TRUE; } catch (CosLifeCycle::CannotMeetCriteria& e) { cout << "CannotMeetCriteria exception\n"; exception = TRUE; } if (exception) cout << "error\n"; else cout << "ok\n"; state_good = true; cout << "Destroing objects" << flush; // containment relationships.. containment1->destroy (); cout << "." << flush; containment2->destroy (); cout << "." << flush; containment3->destroy (); cout << "." << flush; containment4->destroy (); cout << "." << flush; containment5->destroy (); cout << "." << flush; // containment roles contains->destroy (); cout << "." << flush; containedin1->destroy (); cout << "." << flush; containedin2->destroy (); cout << "." << flush; containedin3->destroy (); cout << "." << flush; // traversals //traversal->destroy (); traversal2->destroy (); cout << "." << flush; traversal3->destroy (); cout << "." << flush; // criterias criteria->destroy (); criteria2->destroy (); criteria3->destroy (); cout << "." << flush; //operations oper->destroy(); cout << "." << flush; if (!CORBA::is_nil (iterator)) { iterator->destroy (); cout << "." << flush; } if (!CORBA::is_nil (relship1)) { relship1->destroy (); cout << "." << flush; } if (!CORBA::is_nil (role1)) { role1->destroy (); cout << "." << flush; } if (!CORBA::is_nil (role2)) { role2->destroy (); cout << "." << flush; } cout << "done.\n" << flush; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -