#include "TreeMergeC.h" #include "CipresHelper.h" #include "CipresFacilitator.h" #include "orbsvcs/CosNamingC.h" #include #include using namespace std; void usage(const char *cmd) { cerr << "Usage: " << cmd << " [-CipresIOR ]|[-CipresImpl ] [<-ORBxxx>]" << endl; cerr << "or " << cmd << " -ns [<-ORBxxx>]" << endl; cerr << "servicename must be 'TreeMerge'" << endl; } int main(int argc, char *argv[]) { CipresFacilitator * facilitator = NULL; try { facilitator = CipresFacilitator::getSingletonPtr(); CORBA::Object_var object; if (facilitator->lookupWithNameService() && facilitator->getImplName()) { CipresNameService &ns = facilitator->getCipresNameService(); object = ns.nsFind(facilitator->getImplName()); } else if (facilitator->getIORFile()) { object = facilitator->getObjectFromFile(facilitator->getIORFile()); } else { usage(argv[0]); throw 0; } if (CORBA::is_nil(object.in())) { cerr << "Nil object ref" << endl; throw 0; } CipresIDL_api1::TreeMerge_var tm_var = CipresIDL_api1::TreeMerge::_narrow(object.in()); if (CORBA::is_nil(tm_var.in())) { cerr << "Object ref is not of type TreeMerge" << endl; throw 0; } CipresIDL_api1::TreeSeq treeList; treeList.length(4); for (int i = 0; i < 4; i++) { treeList[i].m_newick = (const char *)"(((1,2),3),4);"; treeList[i].m_leafSet.length(4); for (int j = 0; j < 4; j++) { treeList[i].m_leafSet[j] = j + 1; } } cout << "calling mergeTrees" << endl; CipresIDL_api1::Tree_var resultTree = tm_var->mergeTrees(treeList); cout << "got tree: " << resultTree->m_newick << endl; } catch(CORBA::Exception &ex) { cerr << "CORBA Exception raised: " << ex << endl; return 1; } if (facilitator != NULL) facilitator->cleanup(); return 0; }